babylon.module.d.ts 5.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077
  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. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  466. * @param convertedColor defines the Color3 object where to store the linear space version
  467. * @returns the unmodified Color3
  468. */
  469. toLinearSpaceToRef(convertedColor: Color3): Color3;
  470. /**
  471. * Computes a new Color3 converted from the current one to gamma space
  472. * @returns a new Color3 object
  473. */
  474. toGammaSpace(): Color3;
  475. /**
  476. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  477. * @param convertedColor defines the Color3 object where to store the gamma space version
  478. * @returns the unmodified Color3
  479. */
  480. toGammaSpaceToRef(convertedColor: Color3): Color3;
  481. private static _BlackReadOnly;
  482. /**
  483. * Creates a new Color3 from the string containing valid hexadecimal values
  484. * @param hex defines a string containing valid hexadecimal values
  485. * @returns a new Color3 object
  486. */
  487. static FromHexString(hex: string): Color3;
  488. /**
  489. * Creates a new Color3 from the starting index of the given array
  490. * @param array defines the source array
  491. * @param offset defines an offset in the source array
  492. * @returns a new Color3 object
  493. */
  494. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  495. /**
  496. * Creates a new Color3 from integer values (< 256)
  497. * @param r defines the red component to read from (value between 0 and 255)
  498. * @param g defines the green component to read from (value between 0 and 255)
  499. * @param b defines the blue component to read from (value between 0 and 255)
  500. * @returns a new Color3 object
  501. */
  502. static FromInts(r: number, g: number, b: number): Color3;
  503. /**
  504. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  505. * @param start defines the start Color3 value
  506. * @param end defines the end Color3 value
  507. * @param amount defines the gradient value between start and end
  508. * @returns a new Color3 object
  509. */
  510. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  511. /**
  512. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  513. * @param left defines the start value
  514. * @param right defines the end value
  515. * @param amount defines the gradient factor
  516. * @param result defines the Color3 object where to store the result
  517. */
  518. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  519. /**
  520. * Returns a Color3 value containing a red color
  521. * @returns a new Color3 object
  522. */
  523. static Red(): Color3;
  524. /**
  525. * Returns a Color3 value containing a green color
  526. * @returns a new Color3 object
  527. */
  528. static Green(): Color3;
  529. /**
  530. * Returns a Color3 value containing a blue color
  531. * @returns a new Color3 object
  532. */
  533. static Blue(): Color3;
  534. /**
  535. * Returns a Color3 value containing a black color
  536. * @returns a new Color3 object
  537. */
  538. static Black(): Color3;
  539. /**
  540. * Gets a Color3 value containing a black color that must not be updated
  541. */
  542. static readonly BlackReadOnly: DeepImmutable<Color3>;
  543. /**
  544. * Returns a Color3 value containing a white color
  545. * @returns a new Color3 object
  546. */
  547. static White(): Color3;
  548. /**
  549. * Returns a Color3 value containing a purple color
  550. * @returns a new Color3 object
  551. */
  552. static Purple(): Color3;
  553. /**
  554. * Returns a Color3 value containing a magenta color
  555. * @returns a new Color3 object
  556. */
  557. static Magenta(): Color3;
  558. /**
  559. * Returns a Color3 value containing a yellow color
  560. * @returns a new Color3 object
  561. */
  562. static Yellow(): Color3;
  563. /**
  564. * Returns a Color3 value containing a gray color
  565. * @returns a new Color3 object
  566. */
  567. static Gray(): Color3;
  568. /**
  569. * Returns a Color3 value containing a teal color
  570. * @returns a new Color3 object
  571. */
  572. static Teal(): Color3;
  573. /**
  574. * Returns a Color3 value containing a random color
  575. * @returns a new Color3 object
  576. */
  577. static Random(): Color3;
  578. }
  579. /**
  580. * Class used to hold a RBGA color
  581. */
  582. export class Color4 {
  583. /**
  584. * Defines the red component (between 0 and 1, default is 0)
  585. */
  586. r: number;
  587. /**
  588. * Defines the green component (between 0 and 1, default is 0)
  589. */
  590. g: number;
  591. /**
  592. * Defines the blue component (between 0 and 1, default is 0)
  593. */
  594. b: number;
  595. /**
  596. * Defines the alpha component (between 0 and 1, default is 1)
  597. */
  598. a: number;
  599. /**
  600. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  601. * @param r defines the red component (between 0 and 1, default is 0)
  602. * @param g defines the green component (between 0 and 1, default is 0)
  603. * @param b defines the blue component (between 0 and 1, default is 0)
  604. * @param a defines the alpha component (between 0 and 1, default is 1)
  605. */
  606. constructor(
  607. /**
  608. * Defines the red component (between 0 and 1, default is 0)
  609. */
  610. r?: number,
  611. /**
  612. * Defines the green component (between 0 and 1, default is 0)
  613. */
  614. g?: number,
  615. /**
  616. * Defines the blue component (between 0 and 1, default is 0)
  617. */
  618. b?: number,
  619. /**
  620. * Defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. a?: number);
  623. /**
  624. * Adds in place the given Color4 values to the current Color4 object
  625. * @param right defines the second operand
  626. * @returns the current updated Color4 object
  627. */
  628. addInPlace(right: DeepImmutable<Color4>): Color4;
  629. /**
  630. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  631. * @returns the new array
  632. */
  633. asArray(): number[];
  634. /**
  635. * Stores from the starting index in the given array the Color4 successive values
  636. * @param array defines the array where to store the r,g,b components
  637. * @param index defines an optional index in the target array to define where to start storing values
  638. * @returns the current Color4 object
  639. */
  640. toArray(array: number[], index?: number): Color4;
  641. /**
  642. * Determines equality between Color4 objects
  643. * @param otherColor defines the second operand
  644. * @returns true if the rgba values are equal to the given ones
  645. */
  646. equals(otherColor: DeepImmutable<Color4>): boolean;
  647. /**
  648. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  649. * @param right defines the second operand
  650. * @returns a new Color4 object
  651. */
  652. add(right: DeepImmutable<Color4>): Color4;
  653. /**
  654. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  655. * @param right defines the second operand
  656. * @returns a new Color4 object
  657. */
  658. subtract(right: DeepImmutable<Color4>): Color4;
  659. /**
  660. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  661. * @param right defines the second operand
  662. * @param result defines the Color4 object where to store the result
  663. * @returns the current Color4 object
  664. */
  665. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  666. /**
  667. * Creates a new Color4 with the current Color4 values multiplied by scale
  668. * @param scale defines the scaling factor to apply
  669. * @returns a new Color4 object
  670. */
  671. scale(scale: number): Color4;
  672. /**
  673. * Multiplies the current Color4 values by scale and stores the result in "result"
  674. * @param scale defines the scaling factor to apply
  675. * @param result defines the Color4 object where to store the result
  676. * @returns the current unmodified Color4
  677. */
  678. scaleToRef(scale: number, result: Color4): Color4;
  679. /**
  680. * Scale the current Color4 values by a factor and add the result to a given Color4
  681. * @param scale defines the scale factor
  682. * @param result defines the Color4 object where to store the result
  683. * @returns the unmodified current Color4
  684. */
  685. scaleAndAddToRef(scale: number, result: Color4): Color4;
  686. /**
  687. * Clamps the rgb values by the min and max values and stores the result into "result"
  688. * @param min defines minimum clamping value (default is 0)
  689. * @param max defines maximum clamping value (default is 1)
  690. * @param result defines color to store the result into.
  691. * @returns the cuurent Color4
  692. */
  693. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  694. /**
  695. * Multipy an Color4 value by another and return a new Color4 object
  696. * @param color defines the Color4 value to multiply by
  697. * @returns a new Color4 object
  698. */
  699. multiply(color: Color4): Color4;
  700. /**
  701. * Multipy a Color4 value by another and push the result in a reference value
  702. * @param color defines the Color4 value to multiply by
  703. * @param result defines the Color4 to fill the result in
  704. * @returns the result Color4
  705. */
  706. multiplyToRef(color: Color4, result: Color4): Color4;
  707. /**
  708. * Creates a string with the Color4 current values
  709. * @returns the string representation of the Color4 object
  710. */
  711. toString(): string;
  712. /**
  713. * Returns the string "Color4"
  714. * @returns "Color4"
  715. */
  716. getClassName(): string;
  717. /**
  718. * Compute the Color4 hash code
  719. * @returns an unique number that can be used to hash Color4 objects
  720. */
  721. getHashCode(): number;
  722. /**
  723. * Creates a new Color4 copied from the current one
  724. * @returns a new Color4 object
  725. */
  726. clone(): Color4;
  727. /**
  728. * Copies the given Color4 values into the current one
  729. * @param source defines the source Color4 object
  730. * @returns the current updated Color4 object
  731. */
  732. copyFrom(source: Color4): Color4;
  733. /**
  734. * Copies the given float values into the current one
  735. * @param r defines the red component to read from
  736. * @param g defines the green component to read from
  737. * @param b defines the blue component to read from
  738. * @param a defines the alpha component to read from
  739. * @returns the current updated Color4 object
  740. */
  741. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  742. /**
  743. * Copies the given float values into the current one
  744. * @param r defines the red component to read from
  745. * @param g defines the green component to read from
  746. * @param b defines the blue component to read from
  747. * @param a defines the alpha component to read from
  748. * @returns the current updated Color4 object
  749. */
  750. set(r: number, g: number, b: number, a: number): Color4;
  751. /**
  752. * Compute the Color4 hexadecimal code as a string
  753. * @returns a string containing the hexadecimal representation of the Color4 object
  754. */
  755. toHexString(): string;
  756. /**
  757. * Computes a new Color4 converted from the current one to linear space
  758. * @returns a new Color4 object
  759. */
  760. toLinearSpace(): Color4;
  761. /**
  762. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  763. * @param convertedColor defines the Color4 object where to store the linear space version
  764. * @returns the unmodified Color4
  765. */
  766. toLinearSpaceToRef(convertedColor: Color4): Color4;
  767. /**
  768. * Computes a new Color4 converted from the current one to gamma space
  769. * @returns a new Color4 object
  770. */
  771. toGammaSpace(): Color4;
  772. /**
  773. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  774. * @param convertedColor defines the Color4 object where to store the gamma space version
  775. * @returns the unmodified Color4
  776. */
  777. toGammaSpaceToRef(convertedColor: Color4): Color4;
  778. /**
  779. * Creates a new Color4 from the string containing valid hexadecimal values
  780. * @param hex defines a string containing valid hexadecimal values
  781. * @returns a new Color4 object
  782. */
  783. static FromHexString(hex: string): Color4;
  784. /**
  785. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  786. * @param left defines the start value
  787. * @param right defines the end value
  788. * @param amount defines the gradient factor
  789. * @returns a new Color4 object
  790. */
  791. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  792. /**
  793. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  794. * @param left defines the start value
  795. * @param right defines the end value
  796. * @param amount defines the gradient factor
  797. * @param result defines the Color4 object where to store data
  798. */
  799. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  800. /**
  801. * Creates a new Color4 from a Color3 and an alpha value
  802. * @param color3 defines the source Color3 to read from
  803. * @param alpha defines the alpha component (1.0 by default)
  804. * @returns a new Color4 object
  805. */
  806. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  807. /**
  808. * Creates a new Color4 from the starting index element of the given array
  809. * @param array defines the source array to read from
  810. * @param offset defines the offset in the source array
  811. * @returns a new Color4 object
  812. */
  813. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  814. /**
  815. * Creates a new Color3 from integer values (< 256)
  816. * @param r defines the red component to read from (value between 0 and 255)
  817. * @param g defines the green component to read from (value between 0 and 255)
  818. * @param b defines the blue component to read from (value between 0 and 255)
  819. * @param a defines the alpha component to read from (value between 0 and 255)
  820. * @returns a new Color3 object
  821. */
  822. static FromInts(r: number, g: number, b: number, a: number): Color4;
  823. /**
  824. * Check the content of a given array and convert it to an array containing RGBA data
  825. * If the original array was already containing count * 4 values then it is returned directly
  826. * @param colors defines the array to check
  827. * @param count defines the number of RGBA data to expect
  828. * @returns an array containing count * 4 values (RGBA)
  829. */
  830. static CheckColors4(colors: number[], count: number): number[];
  831. }
  832. /**
  833. * Class representing a vector containing 2 coordinates
  834. */
  835. export class Vector2 {
  836. /** defines the first coordinate */
  837. x: number;
  838. /** defines the second coordinate */
  839. y: number;
  840. /**
  841. * Creates a new Vector2 from the given x and y coordinates
  842. * @param x defines the first coordinate
  843. * @param y defines the second coordinate
  844. */
  845. constructor(
  846. /** defines the first coordinate */
  847. x?: number,
  848. /** defines the second coordinate */
  849. y?: number);
  850. /**
  851. * Gets a string with the Vector2 coordinates
  852. * @returns a string with the Vector2 coordinates
  853. */
  854. toString(): string;
  855. /**
  856. * Gets class name
  857. * @returns the string "Vector2"
  858. */
  859. getClassName(): string;
  860. /**
  861. * Gets current vector hash code
  862. * @returns the Vector2 hash code as a number
  863. */
  864. getHashCode(): number;
  865. /**
  866. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  867. * @param array defines the source array
  868. * @param index defines the offset in source array
  869. * @returns the current Vector2
  870. */
  871. toArray(array: FloatArray, index?: number): Vector2;
  872. /**
  873. * Copy the current vector to an array
  874. * @returns a new array with 2 elements: the Vector2 coordinates.
  875. */
  876. asArray(): number[];
  877. /**
  878. * Sets the Vector2 coordinates with the given Vector2 coordinates
  879. * @param source defines the source Vector2
  880. * @returns the current updated Vector2
  881. */
  882. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  883. /**
  884. * Sets the Vector2 coordinates with the given floats
  885. * @param x defines the first coordinate
  886. * @param y defines the second coordinate
  887. * @returns the current updated Vector2
  888. */
  889. copyFromFloats(x: number, y: number): Vector2;
  890. /**
  891. * Sets the Vector2 coordinates with the given floats
  892. * @param x defines the first coordinate
  893. * @param y defines the second coordinate
  894. * @returns the current updated Vector2
  895. */
  896. set(x: number, y: number): Vector2;
  897. /**
  898. * Add another vector with the current one
  899. * @param otherVector defines the other vector
  900. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  901. */
  902. add(otherVector: DeepImmutable<Vector2>): Vector2;
  903. /**
  904. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  905. * @param otherVector defines the other vector
  906. * @param result defines the target vector
  907. * @returns the unmodified current Vector2
  908. */
  909. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  910. /**
  911. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  912. * @param otherVector defines the other vector
  913. * @returns the current updated Vector2
  914. */
  915. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  916. /**
  917. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  918. * @param otherVector defines the other vector
  919. * @returns a new Vector2
  920. */
  921. addVector3(otherVector: Vector3): Vector2;
  922. /**
  923. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  924. * @param otherVector defines the other vector
  925. * @returns a new Vector2
  926. */
  927. subtract(otherVector: Vector2): Vector2;
  928. /**
  929. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  930. * @param otherVector defines the other vector
  931. * @param result defines the target vector
  932. * @returns the unmodified current Vector2
  933. */
  934. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  935. /**
  936. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  937. * @param otherVector defines the other vector
  938. * @returns the current updated Vector2
  939. */
  940. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  941. /**
  942. * Multiplies in place the current Vector2 coordinates by the given ones
  943. * @param otherVector defines the other vector
  944. * @returns the current updated Vector2
  945. */
  946. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  947. /**
  948. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  949. * @param otherVector defines the other vector
  950. * @returns a new Vector2
  951. */
  952. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  953. /**
  954. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @param result defines the target vector
  957. * @returns the unmodified current Vector2
  958. */
  959. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  960. /**
  961. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  962. * @param x defines the first coordinate
  963. * @param y defines the second coordinate
  964. * @returns a new Vector2
  965. */
  966. multiplyByFloats(x: number, y: number): Vector2;
  967. /**
  968. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  969. * @param otherVector defines the other vector
  970. * @returns a new Vector2
  971. */
  972. divide(otherVector: Vector2): Vector2;
  973. /**
  974. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  975. * @param otherVector defines the other vector
  976. * @param result defines the target vector
  977. * @returns the unmodified current Vector2
  978. */
  979. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  980. /**
  981. * Divides the current Vector2 coordinates by the given ones
  982. * @param otherVector defines the other vector
  983. * @returns the current updated Vector2
  984. */
  985. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  986. /**
  987. * Gets a new Vector2 with current Vector2 negated coordinates
  988. * @returns a new Vector2
  989. */
  990. negate(): Vector2;
  991. /**
  992. * Multiply the Vector2 coordinates by scale
  993. * @param scale defines the scaling factor
  994. * @returns the current updated Vector2
  995. */
  996. scaleInPlace(scale: number): Vector2;
  997. /**
  998. * Returns a new Vector2 scaled by "scale" from the current Vector2
  999. * @param scale defines the scaling factor
  1000. * @returns a new Vector2
  1001. */
  1002. scale(scale: number): Vector2;
  1003. /**
  1004. * Scale the current Vector2 values by a factor to a given Vector2
  1005. * @param scale defines the scale factor
  1006. * @param result defines the Vector2 object where to store the result
  1007. * @returns the unmodified current Vector2
  1008. */
  1009. scaleToRef(scale: number, result: Vector2): Vector2;
  1010. /**
  1011. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1012. * @param scale defines the scale factor
  1013. * @param result defines the Vector2 object where to store the result
  1014. * @returns the unmodified current Vector2
  1015. */
  1016. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1017. /**
  1018. * Gets a boolean if two vectors are equals
  1019. * @param otherVector defines the other vector
  1020. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1021. */
  1022. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1023. /**
  1024. * Gets a boolean if two vectors are equals (using an epsilon value)
  1025. * @param otherVector defines the other vector
  1026. * @param epsilon defines the minimal distance to consider equality
  1027. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1028. */
  1029. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1030. /**
  1031. * Gets a new Vector2 from current Vector2 floored values
  1032. * @returns a new Vector2
  1033. */
  1034. floor(): Vector2;
  1035. /**
  1036. * Gets a new Vector2 from current Vector2 floored values
  1037. * @returns a new Vector2
  1038. */
  1039. fract(): Vector2;
  1040. /**
  1041. * Gets the length of the vector
  1042. * @returns the vector length (float)
  1043. */
  1044. length(): number;
  1045. /**
  1046. * Gets the vector squared length
  1047. * @returns the vector squared length (float)
  1048. */
  1049. lengthSquared(): number;
  1050. /**
  1051. * Normalize the vector
  1052. * @returns the current updated Vector2
  1053. */
  1054. normalize(): Vector2;
  1055. /**
  1056. * Gets a new Vector2 copied from the Vector2
  1057. * @returns a new Vector2
  1058. */
  1059. clone(): Vector2;
  1060. /**
  1061. * Gets a new Vector2(0, 0)
  1062. * @returns a new Vector2
  1063. */
  1064. static Zero(): Vector2;
  1065. /**
  1066. * Gets a new Vector2(1, 1)
  1067. * @returns a new Vector2
  1068. */
  1069. static One(): Vector2;
  1070. /**
  1071. * Gets a new Vector2 set from the given index element of the given array
  1072. * @param array defines the data source
  1073. * @param offset defines the offset in the data source
  1074. * @returns a new Vector2
  1075. */
  1076. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1077. /**
  1078. * Sets "result" from the given index element of the given array
  1079. * @param array defines the data source
  1080. * @param offset defines the offset in the data source
  1081. * @param result defines the target vector
  1082. */
  1083. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1084. /**
  1085. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1086. * @param value1 defines 1st point of control
  1087. * @param value2 defines 2nd point of control
  1088. * @param value3 defines 3rd point of control
  1089. * @param value4 defines 4th point of control
  1090. * @param amount defines the interpolation factor
  1091. * @returns a new Vector2
  1092. */
  1093. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1094. /**
  1095. * 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".
  1096. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1097. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1098. * @param value defines the value to clamp
  1099. * @param min defines the lower limit
  1100. * @param max defines the upper limit
  1101. * @returns a new Vector2
  1102. */
  1103. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1104. /**
  1105. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1106. * @param value1 defines the 1st control point
  1107. * @param tangent1 defines the outgoing tangent
  1108. * @param value2 defines the 2nd control point
  1109. * @param tangent2 defines the incoming tangent
  1110. * @param amount defines the interpolation factor
  1111. * @returns a new Vector2
  1112. */
  1113. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1114. /**
  1115. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1116. * @param start defines the start vector
  1117. * @param end defines the end vector
  1118. * @param amount defines the interpolation factor
  1119. * @returns a new Vector2
  1120. */
  1121. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1122. /**
  1123. * Gets the dot product of the vector "left" and the vector "right"
  1124. * @param left defines first vector
  1125. * @param right defines second vector
  1126. * @returns the dot product (float)
  1127. */
  1128. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1129. /**
  1130. * Returns a new Vector2 equal to the normalized given vector
  1131. * @param vector defines the vector to normalize
  1132. * @returns a new Vector2
  1133. */
  1134. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1135. /**
  1136. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1137. * @param left defines 1st vector
  1138. * @param right defines 2nd vector
  1139. * @returns a new Vector2
  1140. */
  1141. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1142. /**
  1143. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1144. * @param left defines 1st vector
  1145. * @param right defines 2nd vector
  1146. * @returns a new Vector2
  1147. */
  1148. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1149. /**
  1150. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1151. * @param vector defines the vector to transform
  1152. * @param transformation defines the matrix to apply
  1153. * @returns a new Vector2
  1154. */
  1155. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1156. /**
  1157. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1158. * @param vector defines the vector to transform
  1159. * @param transformation defines the matrix to apply
  1160. * @param result defines the target vector
  1161. */
  1162. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1163. /**
  1164. * Determines if a given vector is included in a triangle
  1165. * @param p defines the vector to test
  1166. * @param p0 defines 1st triangle point
  1167. * @param p1 defines 2nd triangle point
  1168. * @param p2 defines 3rd triangle point
  1169. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1170. */
  1171. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1172. /**
  1173. * Gets the distance between the vectors "value1" and "value2"
  1174. * @param value1 defines first vector
  1175. * @param value2 defines second vector
  1176. * @returns the distance between vectors
  1177. */
  1178. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1179. /**
  1180. * Returns the squared distance between the vectors "value1" and "value2"
  1181. * @param value1 defines first vector
  1182. * @param value2 defines second vector
  1183. * @returns the squared distance between vectors
  1184. */
  1185. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1186. /**
  1187. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1188. * @param value1 defines first vector
  1189. * @param value2 defines second vector
  1190. * @returns a new Vector2
  1191. */
  1192. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1193. /**
  1194. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1195. * @param p defines the middle point
  1196. * @param segA defines one point of the segment
  1197. * @param segB defines the other point of the segment
  1198. * @returns the shortest distance
  1199. */
  1200. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1201. }
  1202. /**
  1203. * Classed used to store (x,y,z) vector representation
  1204. * A Vector3 is the main object used in 3D geometry
  1205. * It can represent etiher the coordinates of a point the space, either a direction
  1206. * Reminder: js uses a left handed forward facing system
  1207. */
  1208. export class Vector3 {
  1209. /**
  1210. * Defines the first coordinates (on X axis)
  1211. */
  1212. x: number;
  1213. /**
  1214. * Defines the second coordinates (on Y axis)
  1215. */
  1216. y: number;
  1217. /**
  1218. * Defines the third coordinates (on Z axis)
  1219. */
  1220. z: number;
  1221. private static _UpReadOnly;
  1222. /**
  1223. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1224. * @param x defines the first coordinates (on X axis)
  1225. * @param y defines the second coordinates (on Y axis)
  1226. * @param z defines the third coordinates (on Z axis)
  1227. */
  1228. constructor(
  1229. /**
  1230. * Defines the first coordinates (on X axis)
  1231. */
  1232. x?: number,
  1233. /**
  1234. * Defines the second coordinates (on Y axis)
  1235. */
  1236. y?: number,
  1237. /**
  1238. * Defines the third coordinates (on Z axis)
  1239. */
  1240. z?: number);
  1241. /**
  1242. * Creates a string representation of the Vector3
  1243. * @returns a string with the Vector3 coordinates.
  1244. */
  1245. toString(): string;
  1246. /**
  1247. * Gets the class name
  1248. * @returns the string "Vector3"
  1249. */
  1250. getClassName(): string;
  1251. /**
  1252. * Creates the Vector3 hash code
  1253. * @returns a number which tends to be unique between Vector3 instances
  1254. */
  1255. getHashCode(): number;
  1256. /**
  1257. * Creates an array containing three elements : the coordinates of the Vector3
  1258. * @returns a new array of numbers
  1259. */
  1260. asArray(): number[];
  1261. /**
  1262. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1263. * @param array defines the destination array
  1264. * @param index defines the offset in the destination array
  1265. * @returns the current Vector3
  1266. */
  1267. toArray(array: FloatArray, index?: number): Vector3;
  1268. /**
  1269. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1270. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1271. */
  1272. toQuaternion(): Quaternion;
  1273. /**
  1274. * Adds the given vector to the current Vector3
  1275. * @param otherVector defines the second operand
  1276. * @returns the current updated Vector3
  1277. */
  1278. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1279. /**
  1280. * Adds the given coordinates to the current Vector3
  1281. * @param x defines the x coordinate of the operand
  1282. * @param y defines the y coordinate of the operand
  1283. * @param z defines the z coordinate of the operand
  1284. * @returns the current updated Vector3
  1285. */
  1286. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1287. /**
  1288. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1289. * @param otherVector defines the second operand
  1290. * @returns the resulting Vector3
  1291. */
  1292. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1293. /**
  1294. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1295. * @param otherVector defines the second operand
  1296. * @param result defines the Vector3 object where to store the result
  1297. * @returns the current Vector3
  1298. */
  1299. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1300. /**
  1301. * Subtract the given vector from the current Vector3
  1302. * @param otherVector defines the second operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1306. /**
  1307. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1321. * @param x defines the x coordinate of the operand
  1322. * @param y defines the y coordinate of the operand
  1323. * @param z defines the z coordinate of the operand
  1324. * @returns the resulting Vector3
  1325. */
  1326. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1327. /**
  1328. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1329. * @param x defines the x coordinate of the operand
  1330. * @param y defines the y coordinate of the operand
  1331. * @param z defines the z coordinate of the operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1336. /**
  1337. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1338. * @returns a new Vector3
  1339. */
  1340. negate(): Vector3;
  1341. /**
  1342. * Multiplies the Vector3 coordinates by the float "scale"
  1343. * @param scale defines the multiplier factor
  1344. * @returns the current updated Vector3
  1345. */
  1346. scaleInPlace(scale: number): Vector3;
  1347. /**
  1348. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1349. * @param scale defines the multiplier factor
  1350. * @returns a new Vector3
  1351. */
  1352. scale(scale: number): Vector3;
  1353. /**
  1354. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1355. * @param scale defines the multiplier factor
  1356. * @param result defines the Vector3 object where to store the result
  1357. * @returns the current Vector3
  1358. */
  1359. scaleToRef(scale: number, result: Vector3): Vector3;
  1360. /**
  1361. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1362. * @param scale defines the scale factor
  1363. * @param result defines the Vector3 object where to store the result
  1364. * @returns the unmodified current Vector3
  1365. */
  1366. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1367. /**
  1368. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1369. * @param otherVector defines the second operand
  1370. * @returns true if both vectors are equals
  1371. */
  1372. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1373. /**
  1374. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1375. * @param otherVector defines the second operand
  1376. * @param epsilon defines the minimal distance to define values as equals
  1377. * @returns true if both vectors are distant less than epsilon
  1378. */
  1379. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1380. /**
  1381. * Returns true if the current Vector3 coordinates equals the given floats
  1382. * @param x defines the x coordinate of the operand
  1383. * @param y defines the y coordinate of the operand
  1384. * @param z defines the z coordinate of the operand
  1385. * @returns true if both vectors are equals
  1386. */
  1387. equalsToFloats(x: number, y: number, z: number): boolean;
  1388. /**
  1389. * Multiplies the current Vector3 coordinates by the given ones
  1390. * @param otherVector defines the second operand
  1391. * @returns the current updated Vector3
  1392. */
  1393. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1394. /**
  1395. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1396. * @param otherVector defines the second operand
  1397. * @returns the new Vector3
  1398. */
  1399. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1400. /**
  1401. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1402. * @param otherVector defines the second operand
  1403. * @param result defines the Vector3 object where to store the result
  1404. * @returns the current Vector3
  1405. */
  1406. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1407. /**
  1408. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1409. * @param x defines the x coordinate of the operand
  1410. * @param y defines the y coordinate of the operand
  1411. * @param z defines the z coordinate of the operand
  1412. * @returns the new Vector3
  1413. */
  1414. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1415. /**
  1416. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1417. * @param otherVector defines the second operand
  1418. * @returns the new Vector3
  1419. */
  1420. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1421. /**
  1422. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1423. * @param otherVector defines the second operand
  1424. * @param result defines the Vector3 object where to store the result
  1425. * @returns the current Vector3
  1426. */
  1427. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1428. /**
  1429. * Divides the current Vector3 coordinates by the given ones.
  1430. * @param otherVector defines the second operand
  1431. * @returns the current updated Vector3
  1432. */
  1433. divideInPlace(otherVector: Vector3): Vector3;
  1434. /**
  1435. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1436. * @param other defines the second operand
  1437. * @returns the current updated Vector3
  1438. */
  1439. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1442. * @param other defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1448. * @param x defines the x coordinate of the operand
  1449. * @param y defines the y coordinate of the operand
  1450. * @param z defines the z coordinate of the operand
  1451. * @returns the current updated Vector3
  1452. */
  1453. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1454. /**
  1455. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1456. * @param x defines the x coordinate of the operand
  1457. * @param y defines the y coordinate of the operand
  1458. * @param z defines the z coordinate of the operand
  1459. * @returns the current updated Vector3
  1460. */
  1461. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1462. /**
  1463. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1464. * Check if is non uniform within a certain amount of decimal places to account for this
  1465. * @param epsilon the amount the values can differ
  1466. * @returns if the the vector is non uniform to a certain number of decimal places
  1467. */
  1468. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1469. /**
  1470. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1471. */
  1472. readonly isNonUniform: boolean;
  1473. /**
  1474. * Gets a new Vector3 from current Vector3 floored values
  1475. * @returns a new Vector3
  1476. */
  1477. floor(): Vector3;
  1478. /**
  1479. * Gets a new Vector3 from current Vector3 floored values
  1480. * @returns a new Vector3
  1481. */
  1482. fract(): Vector3;
  1483. /**
  1484. * Gets the length of the Vector3
  1485. * @returns the length of the Vecto3
  1486. */
  1487. length(): number;
  1488. /**
  1489. * Gets the squared length of the Vector3
  1490. * @returns squared length of the Vector3
  1491. */
  1492. lengthSquared(): number;
  1493. /**
  1494. * Normalize the current Vector3.
  1495. * Please note that this is an in place operation.
  1496. * @returns the current updated Vector3
  1497. */
  1498. normalize(): Vector3;
  1499. /**
  1500. * Reorders the x y z properties of the vector in place
  1501. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1502. * @returns the current updated vector
  1503. */
  1504. reorderInPlace(order: string): this;
  1505. /**
  1506. * Rotates the vector around 0,0,0 by a quaternion
  1507. * @param quaternion the rotation quaternion
  1508. * @param result vector to store the result
  1509. * @returns the resulting vector
  1510. */
  1511. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1512. /**
  1513. * Rotates a vector around a given point
  1514. * @param quaternion the rotation quaternion
  1515. * @param point the point to rotate around
  1516. * @param result vector to store the result
  1517. * @returns the resulting vector
  1518. */
  1519. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1520. /**
  1521. * Normalize the current Vector3 with the given input length.
  1522. * Please note that this is an in place operation.
  1523. * @param len the length of the vector
  1524. * @returns the current updated Vector3
  1525. */
  1526. normalizeFromLength(len: number): Vector3;
  1527. /**
  1528. * Normalize the current Vector3 to a new vector
  1529. * @returns the new Vector3
  1530. */
  1531. normalizeToNew(): Vector3;
  1532. /**
  1533. * Normalize the current Vector3 to the reference
  1534. * @param reference define the Vector3 to update
  1535. * @returns the updated Vector3
  1536. */
  1537. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1538. /**
  1539. * Creates a new Vector3 copied from the current Vector3
  1540. * @returns the new Vector3
  1541. */
  1542. clone(): Vector3;
  1543. /**
  1544. * Copies the given vector coordinates to the current Vector3 ones
  1545. * @param source defines the source Vector3
  1546. * @returns the current updated Vector3
  1547. */
  1548. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1549. /**
  1550. * Copies the given floats to the current Vector3 coordinates
  1551. * @param x defines the x coordinate of the operand
  1552. * @param y defines the y coordinate of the operand
  1553. * @param z defines the z coordinate of the operand
  1554. * @returns the current updated Vector3
  1555. */
  1556. copyFromFloats(x: number, y: number, z: number): Vector3;
  1557. /**
  1558. * Copies the given floats to the current Vector3 coordinates
  1559. * @param x defines the x coordinate of the operand
  1560. * @param y defines the y coordinate of the operand
  1561. * @param z defines the z coordinate of the operand
  1562. * @returns the current updated Vector3
  1563. */
  1564. set(x: number, y: number, z: number): Vector3;
  1565. /**
  1566. * Copies the given float to the current Vector3 coordinates
  1567. * @param v defines the x, y and z coordinates of the operand
  1568. * @returns the current updated Vector3
  1569. */
  1570. setAll(v: number): Vector3;
  1571. /**
  1572. * Get the clip factor between two vectors
  1573. * @param vector0 defines the first operand
  1574. * @param vector1 defines the second operand
  1575. * @param axis defines the axis to use
  1576. * @param size defines the size along the axis
  1577. * @returns the clip factor
  1578. */
  1579. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1580. /**
  1581. * Get angle between two vectors
  1582. * @param vector0 angle between vector0 and vector1
  1583. * @param vector1 angle between vector0 and vector1
  1584. * @param normal direction of the normal
  1585. * @return the angle between vector0 and vector1
  1586. */
  1587. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1588. /**
  1589. * Returns a new Vector3 set from the index "offset" of the given array
  1590. * @param array defines the source array
  1591. * @param offset defines the offset in the source array
  1592. * @returns the new Vector3
  1593. */
  1594. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1595. /**
  1596. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1597. * This function is deprecated. Use FromArray instead
  1598. * @param array defines the source array
  1599. * @param offset defines the offset in the source array
  1600. * @returns the new Vector3
  1601. */
  1602. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1603. /**
  1604. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1605. * @param array defines the source array
  1606. * @param offset defines the offset in the source array
  1607. * @param result defines the Vector3 where to store the result
  1608. */
  1609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1610. /**
  1611. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1612. * This function is deprecated. Use FromArrayToRef instead.
  1613. * @param array defines the source array
  1614. * @param offset defines the offset in the source array
  1615. * @param result defines the Vector3 where to store the result
  1616. */
  1617. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1618. /**
  1619. * Sets the given vector "result" with the given floats.
  1620. * @param x defines the x coordinate of the source
  1621. * @param y defines the y coordinate of the source
  1622. * @param z defines the z coordinate of the source
  1623. * @param result defines the Vector3 where to store the result
  1624. */
  1625. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1626. /**
  1627. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1628. * @returns a new empty Vector3
  1629. */
  1630. static Zero(): Vector3;
  1631. /**
  1632. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1633. * @returns a new unit Vector3
  1634. */
  1635. static One(): Vector3;
  1636. /**
  1637. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1638. * @returns a new up Vector3
  1639. */
  1640. static Up(): Vector3;
  1641. /**
  1642. * Gets a up Vector3 that must not be updated
  1643. */
  1644. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1647. * @returns a new down Vector3
  1648. */
  1649. static Down(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1652. * @returns a new forward Vector3
  1653. */
  1654. static Forward(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1657. * @returns a new forward Vector3
  1658. */
  1659. static Backward(): Vector3;
  1660. /**
  1661. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1662. * @returns a new right Vector3
  1663. */
  1664. static Right(): Vector3;
  1665. /**
  1666. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1667. * @returns a new left Vector3
  1668. */
  1669. static Left(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1672. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1673. * @param vector defines the Vector3 to transform
  1674. * @param transformation defines the transformation matrix
  1675. * @returns the transformed Vector3
  1676. */
  1677. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1678. /**
  1679. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1680. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1681. * @param vector defines the Vector3 to transform
  1682. * @param transformation defines the transformation matrix
  1683. * @param result defines the Vector3 where to store the result
  1684. */
  1685. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1686. /**
  1687. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1688. * This method computes tranformed coordinates only, not transformed direction vectors
  1689. * @param x define the x coordinate of the source vector
  1690. * @param y define the y coordinate of the source vector
  1691. * @param z define the z coordinate of the source vector
  1692. * @param transformation defines the transformation matrix
  1693. * @param result defines the Vector3 where to store the result
  1694. */
  1695. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1696. /**
  1697. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1698. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1699. * @param vector defines the Vector3 to transform
  1700. * @param transformation defines the transformation matrix
  1701. * @returns the new Vector3
  1702. */
  1703. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1704. /**
  1705. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1706. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1707. * @param vector defines the Vector3 to transform
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param x define the x coordinate of the source vector
  1716. * @param y define the y coordinate of the source vector
  1717. * @param z define the z coordinate of the source vector
  1718. * @param transformation defines the transformation matrix
  1719. * @param result defines the Vector3 where to store the result
  1720. */
  1721. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1722. /**
  1723. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1724. * @param value1 defines the first control point
  1725. * @param value2 defines the second control point
  1726. * @param value3 defines the third control point
  1727. * @param value4 defines the fourth control point
  1728. * @param amount defines the amount on the spline to use
  1729. * @returns the new Vector3
  1730. */
  1731. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1732. /**
  1733. * 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"
  1734. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1735. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1736. * @param value defines the current value
  1737. * @param min defines the lower range value
  1738. * @param max defines the upper range value
  1739. * @returns the new Vector3
  1740. */
  1741. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1742. /**
  1743. * 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"
  1744. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1745. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1746. * @param value defines the current value
  1747. * @param min defines the lower range value
  1748. * @param max defines the upper range value
  1749. * @param result defines the Vector3 where to store the result
  1750. */
  1751. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1752. /**
  1753. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1754. * @param value1 defines the first control point
  1755. * @param tangent1 defines the first tangent vector
  1756. * @param value2 defines the second control point
  1757. * @param tangent2 defines the second tangent vector
  1758. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1759. * @returns the new Vector3
  1760. */
  1761. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1762. /**
  1763. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1764. * @param start defines the start value
  1765. * @param end defines the end value
  1766. * @param amount max defines amount between both (between 0 and 1)
  1767. * @returns the new Vector3
  1768. */
  1769. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1770. /**
  1771. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1772. * @param start defines the start value
  1773. * @param end defines the end value
  1774. * @param amount max defines amount between both (between 0 and 1)
  1775. * @param result defines the Vector3 where to store the result
  1776. */
  1777. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1778. /**
  1779. * Returns the dot product (float) between the vectors "left" and "right"
  1780. * @param left defines the left operand
  1781. * @param right defines the right operand
  1782. * @returns the dot product
  1783. */
  1784. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1785. /**
  1786. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1787. * The cross product is then orthogonal to both "left" and "right"
  1788. * @param left defines the left operand
  1789. * @param right defines the right operand
  1790. * @returns the cross product
  1791. */
  1792. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the cross product of "left" and "right"
  1795. * The cross product is then orthogonal to both "left" and "right"
  1796. * @param left defines the left operand
  1797. * @param right defines the right operand
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1801. /**
  1802. * Returns a new Vector3 as the normalization of the given vector
  1803. * @param vector defines the Vector3 to normalize
  1804. * @returns the new Vector3
  1805. */
  1806. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1807. /**
  1808. * Sets the given vector "result" with the normalization of the given first vector
  1809. * @param vector defines the Vector3 to normalize
  1810. * @param result defines the Vector3 where to store the result
  1811. */
  1812. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1813. /**
  1814. * Project a Vector3 onto screen space
  1815. * @param vector defines the Vector3 to project
  1816. * @param world defines the world matrix to use
  1817. * @param transform defines the transform (view x projection) matrix to use
  1818. * @param viewport defines the screen viewport to use
  1819. * @returns the new Vector3
  1820. */
  1821. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1822. /** @hidden */
  1823. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1824. /**
  1825. * Unproject from screen space to object space
  1826. * @param source defines the screen space Vector3 to use
  1827. * @param viewportWidth defines the current width of the viewport
  1828. * @param viewportHeight defines the current height of the viewport
  1829. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1830. * @param transform defines the transform (view x projection) matrix to use
  1831. * @returns the new Vector3
  1832. */
  1833. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1834. /**
  1835. * Unproject from screen space to object space
  1836. * @param source defines the screen space Vector3 to use
  1837. * @param viewportWidth defines the current width of the viewport
  1838. * @param viewportHeight defines the current height of the viewport
  1839. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1840. * @param view defines the view matrix to use
  1841. * @param projection defines the projection matrix to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param view defines the view matrix to use
  1852. * @param projection defines the projection matrix to use
  1853. * @param result defines the Vector3 where to store the result
  1854. */
  1855. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1856. /**
  1857. * Unproject from screen space to object space
  1858. * @param sourceX defines the screen space x coordinate to use
  1859. * @param sourceY defines the screen space y coordinate to use
  1860. * @param sourceZ defines the screen space z coordinate to use
  1861. * @param viewportWidth defines the current width of the viewport
  1862. * @param viewportHeight defines the current height of the viewport
  1863. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1864. * @param view defines the view matrix to use
  1865. * @param projection defines the projection matrix to use
  1866. * @param result defines the Vector3 where to store the result
  1867. */
  1868. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1869. /**
  1870. * Gets the minimal coordinate values between two Vector3
  1871. * @param left defines the first operand
  1872. * @param right defines the second operand
  1873. * @returns the new Vector3
  1874. */
  1875. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1876. /**
  1877. * Gets the maximal coordinate values between two Vector3
  1878. * @param left defines the first operand
  1879. * @param right defines the second operand
  1880. * @returns the new Vector3
  1881. */
  1882. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1883. /**
  1884. * Returns the distance between the vectors "value1" and "value2"
  1885. * @param value1 defines the first operand
  1886. * @param value2 defines the second operand
  1887. * @returns the distance
  1888. */
  1889. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1890. /**
  1891. * Returns the squared distance between the vectors "value1" and "value2"
  1892. * @param value1 defines the first operand
  1893. * @param value2 defines the second operand
  1894. * @returns the squared distance
  1895. */
  1896. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1897. /**
  1898. * Returns a new Vector3 located at the center between "value1" and "value2"
  1899. * @param value1 defines the first operand
  1900. * @param value2 defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1906. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1907. * to something in order to rotate it from its local system to the given target system
  1908. * Note: axis1, axis2 and axis3 are normalized during this operation
  1909. * @param axis1 defines the first axis
  1910. * @param axis2 defines the second axis
  1911. * @param axis3 defines the third axis
  1912. * @returns a new Vector3
  1913. */
  1914. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1915. /**
  1916. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1917. * @param axis1 defines the first axis
  1918. * @param axis2 defines the second axis
  1919. * @param axis3 defines the third axis
  1920. * @param ref defines the Vector3 where to store the result
  1921. */
  1922. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1923. }
  1924. /**
  1925. * Vector4 class created for EulerAngle class conversion to Quaternion
  1926. */
  1927. export class Vector4 {
  1928. /** x value of the vector */
  1929. x: number;
  1930. /** y value of the vector */
  1931. y: number;
  1932. /** z value of the vector */
  1933. z: number;
  1934. /** w value of the vector */
  1935. w: number;
  1936. /**
  1937. * Creates a Vector4 object from the given floats.
  1938. * @param x x value of the vector
  1939. * @param y y value of the vector
  1940. * @param z z value of the vector
  1941. * @param w w value of the vector
  1942. */
  1943. constructor(
  1944. /** x value of the vector */
  1945. x: number,
  1946. /** y value of the vector */
  1947. y: number,
  1948. /** z value of the vector */
  1949. z: number,
  1950. /** w value of the vector */
  1951. w: number);
  1952. /**
  1953. * Returns the string with the Vector4 coordinates.
  1954. * @returns a string containing all the vector values
  1955. */
  1956. toString(): string;
  1957. /**
  1958. * Returns the string "Vector4".
  1959. * @returns "Vector4"
  1960. */
  1961. getClassName(): string;
  1962. /**
  1963. * Returns the Vector4 hash code.
  1964. * @returns a unique hash code
  1965. */
  1966. getHashCode(): number;
  1967. /**
  1968. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1969. * @returns the resulting array
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Populates the given array from the given index with the Vector4 coordinates.
  1974. * @param array array to populate
  1975. * @param index index of the array to start at (default: 0)
  1976. * @returns the Vector4.
  1977. */
  1978. toArray(array: FloatArray, index?: number): Vector4;
  1979. /**
  1980. * Adds the given vector to the current Vector4.
  1981. * @param otherVector the vector to add
  1982. * @returns the updated Vector4.
  1983. */
  1984. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1985. /**
  1986. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1987. * @param otherVector the vector to add
  1988. * @returns the resulting vector
  1989. */
  1990. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1991. /**
  1992. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1993. * @param otherVector the vector to add
  1994. * @param result the vector to store the result
  1995. * @returns the current Vector4.
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1998. /**
  1999. * Subtract in place the given vector from the current Vector4.
  2000. * @param otherVector the vector to subtract
  2001. * @returns the updated Vector4.
  2002. */
  2003. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2004. /**
  2005. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2006. * @param otherVector the vector to add
  2007. * @returns the new vector with the result
  2008. */
  2009. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2010. /**
  2011. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2012. * @param otherVector the vector to subtract
  2013. * @param result the vector to store the result
  2014. * @returns the current Vector4.
  2015. */
  2016. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. */
  2020. /**
  2021. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2022. * @param x value to subtract
  2023. * @param y value to subtract
  2024. * @param z value to subtract
  2025. * @param w value to subtract
  2026. * @returns new vector containing the result
  2027. */
  2028. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2029. /**
  2030. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2031. * @param x value to subtract
  2032. * @param y value to subtract
  2033. * @param z value to subtract
  2034. * @param w value to subtract
  2035. * @param result the vector to store the result in
  2036. * @returns the current Vector4.
  2037. */
  2038. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2039. /**
  2040. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2041. * @returns a new vector with the negated values
  2042. */
  2043. negate(): Vector4;
  2044. /**
  2045. * Multiplies the current Vector4 coordinates by scale (float).
  2046. * @param scale the number to scale with
  2047. * @returns the updated Vector4.
  2048. */
  2049. scaleInPlace(scale: number): Vector4;
  2050. /**
  2051. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2052. * @param scale the number to scale with
  2053. * @returns a new vector with the result
  2054. */
  2055. scale(scale: number): Vector4;
  2056. /**
  2057. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2058. * @param scale the number to scale with
  2059. * @param result a vector to store the result in
  2060. * @returns the current Vector4.
  2061. */
  2062. scaleToRef(scale: number, result: Vector4): Vector4;
  2063. /**
  2064. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2065. * @param scale defines the scale factor
  2066. * @param result defines the Vector4 object where to store the result
  2067. * @returns the unmodified current Vector4
  2068. */
  2069. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2070. /**
  2071. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2072. * @param otherVector the vector to compare against
  2073. * @returns true if they are equal
  2074. */
  2075. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2076. /**
  2077. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2078. * @param otherVector vector to compare against
  2079. * @param epsilon (Default: very small number)
  2080. * @returns true if they are equal
  2081. */
  2082. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2083. /**
  2084. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2085. * @param x x value to compare against
  2086. * @param y y value to compare against
  2087. * @param z z value to compare against
  2088. * @param w w value to compare against
  2089. * @returns true if equal
  2090. */
  2091. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2092. /**
  2093. * Multiplies in place the current Vector4 by the given one.
  2094. * @param otherVector vector to multiple with
  2095. * @returns the updated Vector4.
  2096. */
  2097. multiplyInPlace(otherVector: Vector4): Vector4;
  2098. /**
  2099. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2100. * @param otherVector vector to multiple with
  2101. * @returns resulting new vector
  2102. */
  2103. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2104. /**
  2105. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2106. * @param otherVector vector to multiple with
  2107. * @param result vector to store the result
  2108. * @returns the current Vector4.
  2109. */
  2110. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2111. /**
  2112. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2113. * @param x x value multiply with
  2114. * @param y y value multiply with
  2115. * @param z z value multiply with
  2116. * @param w w value multiply with
  2117. * @returns resulting new vector
  2118. */
  2119. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2120. /**
  2121. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2122. * @param otherVector vector to devide with
  2123. * @returns resulting new vector
  2124. */
  2125. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2126. /**
  2127. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2128. * @param otherVector vector to devide with
  2129. * @param result vector to store the result
  2130. * @returns the current Vector4.
  2131. */
  2132. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2133. /**
  2134. * Divides the current Vector3 coordinates by the given ones.
  2135. * @param otherVector vector to devide with
  2136. * @returns the updated Vector3.
  2137. */
  2138. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2139. /**
  2140. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2141. * @param other defines the second operand
  2142. * @returns the current updated Vector4
  2143. */
  2144. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2145. /**
  2146. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2147. * @param other defines the second operand
  2148. * @returns the current updated Vector4
  2149. */
  2150. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2151. /**
  2152. * Gets a new Vector4 from current Vector4 floored values
  2153. * @returns a new Vector4
  2154. */
  2155. floor(): Vector4;
  2156. /**
  2157. * Gets a new Vector4 from current Vector3 floored values
  2158. * @returns a new Vector4
  2159. */
  2160. fract(): Vector4;
  2161. /**
  2162. * Returns the Vector4 length (float).
  2163. * @returns the length
  2164. */
  2165. length(): number;
  2166. /**
  2167. * Returns the Vector4 squared length (float).
  2168. * @returns the length squared
  2169. */
  2170. lengthSquared(): number;
  2171. /**
  2172. * Normalizes in place the Vector4.
  2173. * @returns the updated Vector4.
  2174. */
  2175. normalize(): Vector4;
  2176. /**
  2177. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2178. * @returns this converted to a new vector3
  2179. */
  2180. toVector3(): Vector3;
  2181. /**
  2182. * Returns a new Vector4 copied from the current one.
  2183. * @returns the new cloned vector
  2184. */
  2185. clone(): Vector4;
  2186. /**
  2187. * Updates the current Vector4 with the given one coordinates.
  2188. * @param source the source vector to copy from
  2189. * @returns the updated Vector4.
  2190. */
  2191. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2192. /**
  2193. * Updates the current Vector4 coordinates with the given floats.
  2194. * @param x float to copy from
  2195. * @param y float to copy from
  2196. * @param z float to copy from
  2197. * @param w float to copy from
  2198. * @returns the updated Vector4.
  2199. */
  2200. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2201. /**
  2202. * Updates the current Vector4 coordinates with the given floats.
  2203. * @param x float to set from
  2204. * @param y float to set from
  2205. * @param z float to set from
  2206. * @param w float to set from
  2207. * @returns the updated Vector4.
  2208. */
  2209. set(x: number, y: number, z: number, w: number): Vector4;
  2210. /**
  2211. * Copies the given float to the current Vector3 coordinates
  2212. * @param v defines the x, y, z and w coordinates of the operand
  2213. * @returns the current updated Vector3
  2214. */
  2215. setAll(v: number): Vector4;
  2216. /**
  2217. * Returns a new Vector4 set from the starting index of the given array.
  2218. * @param array the array to pull values from
  2219. * @param offset the offset into the array to start at
  2220. * @returns the new vector
  2221. */
  2222. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2223. /**
  2224. * Updates the given vector "result" from the starting index of the given array.
  2225. * @param array the array to pull values from
  2226. * @param offset the offset into the array to start at
  2227. * @param result the vector to store the result in
  2228. */
  2229. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2230. /**
  2231. * Updates the given vector "result" from the starting index of the given Float32Array.
  2232. * @param array the array to pull values from
  2233. * @param offset the offset into the array to start at
  2234. * @param result the vector to store the result in
  2235. */
  2236. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2237. /**
  2238. * Updates the given vector "result" coordinates from the given floats.
  2239. * @param x float to set from
  2240. * @param y float to set from
  2241. * @param z float to set from
  2242. * @param w float to set from
  2243. * @param result the vector to the floats in
  2244. */
  2245. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2246. /**
  2247. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2248. * @returns the new vector
  2249. */
  2250. static Zero(): Vector4;
  2251. /**
  2252. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2253. * @returns the new vector
  2254. */
  2255. static One(): Vector4;
  2256. /**
  2257. * Returns a new normalized Vector4 from the given one.
  2258. * @param vector the vector to normalize
  2259. * @returns the vector
  2260. */
  2261. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2262. /**
  2263. * Updates the given vector "result" from the normalization of the given one.
  2264. * @param vector the vector to normalize
  2265. * @param result the vector to store the result in
  2266. */
  2267. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2268. /**
  2269. * Returns a vector with the minimum values from the left and right vectors
  2270. * @param left left vector to minimize
  2271. * @param right right vector to minimize
  2272. * @returns a new vector with the minimum of the left and right vector values
  2273. */
  2274. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2275. /**
  2276. * Returns a vector with the maximum values from the left and right vectors
  2277. * @param left left vector to maximize
  2278. * @param right right vector to maximize
  2279. * @returns a new vector with the maximum of the left and right vector values
  2280. */
  2281. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Returns the distance (float) between the vectors "value1" and "value2".
  2284. * @param value1 value to calulate the distance between
  2285. * @param value2 value to calulate the distance between
  2286. * @return the distance between the two vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2289. /**
  2290. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2291. * @param value1 value to calulate the distance between
  2292. * @param value2 value to calulate the distance between
  2293. * @return the distance between the two vectors squared
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2296. /**
  2297. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2298. * @param value1 value to calulate the center between
  2299. * @param value2 value to calulate the center between
  2300. * @return the center between the two vectors
  2301. */
  2302. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2305. * This methods computes transformed normalized direction vectors only.
  2306. * @param vector the vector to transform
  2307. * @param transformation the transformation matrix to apply
  2308. * @returns the new vector
  2309. */
  2310. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2311. /**
  2312. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2313. * This methods computes transformed normalized direction vectors only.
  2314. * @param vector the vector to transform
  2315. * @param transformation the transformation matrix to apply
  2316. * @param result the vector to store the result in
  2317. */
  2318. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2319. /**
  2320. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2321. * This methods computes transformed normalized direction vectors only.
  2322. * @param x value to transform
  2323. * @param y value to transform
  2324. * @param z value to transform
  2325. * @param w value to transform
  2326. * @param transformation the transformation matrix to apply
  2327. * @param result the vector to store the results in
  2328. */
  2329. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2330. /**
  2331. * Creates a new Vector4 from a Vector3
  2332. * @param source defines the source data
  2333. * @param w defines the 4th component (default is 0)
  2334. * @returns a new Vector4
  2335. */
  2336. static FromVector3(source: Vector3, w?: number): Vector4;
  2337. }
  2338. /**
  2339. * Interface for the size containing width and height
  2340. */
  2341. export interface ISize {
  2342. /**
  2343. * Width
  2344. */
  2345. width: number;
  2346. /**
  2347. * Heighht
  2348. */
  2349. height: number;
  2350. }
  2351. /**
  2352. * Size containing widht and height
  2353. */
  2354. export class Size implements ISize {
  2355. /**
  2356. * Width
  2357. */
  2358. width: number;
  2359. /**
  2360. * Height
  2361. */
  2362. height: number;
  2363. /**
  2364. * Creates a Size object from the given width and height (floats).
  2365. * @param width width of the new size
  2366. * @param height height of the new size
  2367. */
  2368. constructor(width: number, height: number);
  2369. /**
  2370. * Returns a string with the Size width and height
  2371. * @returns a string with the Size width and height
  2372. */
  2373. toString(): string;
  2374. /**
  2375. * "Size"
  2376. * @returns the string "Size"
  2377. */
  2378. getClassName(): string;
  2379. /**
  2380. * Returns the Size hash code.
  2381. * @returns a hash code for a unique width and height
  2382. */
  2383. getHashCode(): number;
  2384. /**
  2385. * Updates the current size from the given one.
  2386. * @param src the given size
  2387. */
  2388. copyFrom(src: Size): void;
  2389. /**
  2390. * Updates in place the current Size from the given floats.
  2391. * @param width width of the new size
  2392. * @param height height of the new size
  2393. * @returns the updated Size.
  2394. */
  2395. copyFromFloats(width: number, height: number): Size;
  2396. /**
  2397. * Updates in place the current Size from the given floats.
  2398. * @param width width to set
  2399. * @param height height to set
  2400. * @returns the updated Size.
  2401. */
  2402. set(width: number, height: number): Size;
  2403. /**
  2404. * Multiplies the width and height by numbers
  2405. * @param w factor to multiple the width by
  2406. * @param h factor to multiple the height by
  2407. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2408. */
  2409. multiplyByFloats(w: number, h: number): Size;
  2410. /**
  2411. * Clones the size
  2412. * @returns a new Size copied from the given one.
  2413. */
  2414. clone(): Size;
  2415. /**
  2416. * True if the current Size and the given one width and height are strictly equal.
  2417. * @param other the other size to compare against
  2418. * @returns True if the current Size and the given one width and height are strictly equal.
  2419. */
  2420. equals(other: Size): boolean;
  2421. /**
  2422. * The surface of the Size : width * height (float).
  2423. */
  2424. readonly surface: number;
  2425. /**
  2426. * Create a new size of zero
  2427. * @returns a new Size set to (0.0, 0.0)
  2428. */
  2429. static Zero(): Size;
  2430. /**
  2431. * Sums the width and height of two sizes
  2432. * @param otherSize size to add to this size
  2433. * @returns a new Size set as the addition result of the current Size and the given one.
  2434. */
  2435. add(otherSize: Size): Size;
  2436. /**
  2437. * Subtracts the width and height of two
  2438. * @param otherSize size to subtract to this size
  2439. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2440. */
  2441. subtract(otherSize: Size): Size;
  2442. /**
  2443. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2444. * @param start starting size to lerp between
  2445. * @param end end size to lerp between
  2446. * @param amount amount to lerp between the start and end values
  2447. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2448. */
  2449. static Lerp(start: Size, end: Size, amount: number): Size;
  2450. }
  2451. /**
  2452. * Class used to store quaternion data
  2453. * @see https://en.wikipedia.org/wiki/Quaternion
  2454. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2455. */
  2456. export class Quaternion {
  2457. /** defines the first component (0 by default) */
  2458. x: number;
  2459. /** defines the second component (0 by default) */
  2460. y: number;
  2461. /** defines the third component (0 by default) */
  2462. z: number;
  2463. /** defines the fourth component (1.0 by default) */
  2464. w: number;
  2465. /**
  2466. * Creates a new Quaternion from the given floats
  2467. * @param x defines the first component (0 by default)
  2468. * @param y defines the second component (0 by default)
  2469. * @param z defines the third component (0 by default)
  2470. * @param w defines the fourth component (1.0 by default)
  2471. */
  2472. constructor(
  2473. /** defines the first component (0 by default) */
  2474. x?: number,
  2475. /** defines the second component (0 by default) */
  2476. y?: number,
  2477. /** defines the third component (0 by default) */
  2478. z?: number,
  2479. /** defines the fourth component (1.0 by default) */
  2480. w?: number);
  2481. /**
  2482. * Gets a string representation for the current quaternion
  2483. * @returns a string with the Quaternion coordinates
  2484. */
  2485. toString(): string;
  2486. /**
  2487. * Gets the class name of the quaternion
  2488. * @returns the string "Quaternion"
  2489. */
  2490. getClassName(): string;
  2491. /**
  2492. * Gets a hash code for this quaternion
  2493. * @returns the quaternion hash code
  2494. */
  2495. getHashCode(): number;
  2496. /**
  2497. * Copy the quaternion to an array
  2498. * @returns a new array populated with 4 elements from the quaternion coordinates
  2499. */
  2500. asArray(): number[];
  2501. /**
  2502. * Check if two quaternions are equals
  2503. * @param otherQuaternion defines the second operand
  2504. * @return true if the current quaternion and the given one coordinates are strictly equals
  2505. */
  2506. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2507. /**
  2508. * Clone the current quaternion
  2509. * @returns a new quaternion copied from the current one
  2510. */
  2511. clone(): Quaternion;
  2512. /**
  2513. * Copy a quaternion to the current one
  2514. * @param other defines the other quaternion
  2515. * @returns the updated current quaternion
  2516. */
  2517. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2518. /**
  2519. * Updates the current quaternion with the given float coordinates
  2520. * @param x defines the x coordinate
  2521. * @param y defines the y coordinate
  2522. * @param z defines the z coordinate
  2523. * @param w defines the w coordinate
  2524. * @returns the updated current quaternion
  2525. */
  2526. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2527. /**
  2528. * Updates the current quaternion from the given float coordinates
  2529. * @param x defines the x coordinate
  2530. * @param y defines the y coordinate
  2531. * @param z defines the z coordinate
  2532. * @param w defines the w coordinate
  2533. * @returns the updated current quaternion
  2534. */
  2535. set(x: number, y: number, z: number, w: number): Quaternion;
  2536. /**
  2537. * Adds two quaternions
  2538. * @param other defines the second operand
  2539. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2540. */
  2541. add(other: DeepImmutable<Quaternion>): Quaternion;
  2542. /**
  2543. * Add a quaternion to the current one
  2544. * @param other defines the quaternion to add
  2545. * @returns the current quaternion
  2546. */
  2547. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2548. /**
  2549. * Subtract two quaternions
  2550. * @param other defines the second operand
  2551. * @returns a new quaternion as the subtraction result of the given one from the current one
  2552. */
  2553. subtract(other: Quaternion): Quaternion;
  2554. /**
  2555. * Multiplies the current quaternion by a scale factor
  2556. * @param value defines the scale factor
  2557. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2558. */
  2559. scale(value: number): Quaternion;
  2560. /**
  2561. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2562. * @param scale defines the scale factor
  2563. * @param result defines the Quaternion object where to store the result
  2564. * @returns the unmodified current quaternion
  2565. */
  2566. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2567. /**
  2568. * Multiplies in place the current quaternion by a scale factor
  2569. * @param value defines the scale factor
  2570. * @returns the current modified quaternion
  2571. */
  2572. scaleInPlace(value: number): Quaternion;
  2573. /**
  2574. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2575. * @param scale defines the scale factor
  2576. * @param result defines the Quaternion object where to store the result
  2577. * @returns the unmodified current quaternion
  2578. */
  2579. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2580. /**
  2581. * Multiplies two quaternions
  2582. * @param q1 defines the second operand
  2583. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2584. */
  2585. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2586. /**
  2587. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2588. * @param q1 defines the second operand
  2589. * @param result defines the target quaternion
  2590. * @returns the current quaternion
  2591. */
  2592. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2593. /**
  2594. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2595. * @param q1 defines the second operand
  2596. * @returns the currentupdated quaternion
  2597. */
  2598. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2599. /**
  2600. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2601. * @param ref defines the target quaternion
  2602. * @returns the current quaternion
  2603. */
  2604. conjugateToRef(ref: Quaternion): Quaternion;
  2605. /**
  2606. * Conjugates in place (1-q) the current quaternion
  2607. * @returns the current updated quaternion
  2608. */
  2609. conjugateInPlace(): Quaternion;
  2610. /**
  2611. * Conjugates in place (1-q) the current quaternion
  2612. * @returns a new quaternion
  2613. */
  2614. conjugate(): Quaternion;
  2615. /**
  2616. * Gets length of current quaternion
  2617. * @returns the quaternion length (float)
  2618. */
  2619. length(): number;
  2620. /**
  2621. * Normalize in place the current quaternion
  2622. * @returns the current updated quaternion
  2623. */
  2624. normalize(): Quaternion;
  2625. /**
  2626. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2627. * @param order is a reserved parameter and is ignore for now
  2628. * @returns a new Vector3 containing the Euler angles
  2629. */
  2630. toEulerAngles(order?: string): Vector3;
  2631. /**
  2632. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2633. * @param result defines the vector which will be filled with the Euler angles
  2634. * @param order is a reserved parameter and is ignore for now
  2635. * @returns the current unchanged quaternion
  2636. */
  2637. toEulerAnglesToRef(result: Vector3): Quaternion;
  2638. /**
  2639. * Updates the given rotation matrix with the current quaternion values
  2640. * @param result defines the target matrix
  2641. * @returns the current unchanged quaternion
  2642. */
  2643. toRotationMatrix(result: Matrix): Quaternion;
  2644. /**
  2645. * Updates the current quaternion from the given rotation matrix values
  2646. * @param matrix defines the source matrix
  2647. * @returns the current updated quaternion
  2648. */
  2649. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2650. /**
  2651. * Creates a new quaternion from a rotation matrix
  2652. * @param matrix defines the source matrix
  2653. * @returns a new quaternion created from the given rotation matrix values
  2654. */
  2655. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2656. /**
  2657. * Updates the given quaternion with the given rotation matrix values
  2658. * @param matrix defines the source matrix
  2659. * @param result defines the target quaternion
  2660. */
  2661. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2662. /**
  2663. * Returns the dot product (float) between the quaternions "left" and "right"
  2664. * @param left defines the left operand
  2665. * @param right defines the right operand
  2666. * @returns the dot product
  2667. */
  2668. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2669. /**
  2670. * Checks if the two quaternions are close to each other
  2671. * @param quat0 defines the first quaternion to check
  2672. * @param quat1 defines the second quaternion to check
  2673. * @returns true if the two quaternions are close to each other
  2674. */
  2675. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2676. /**
  2677. * Creates an empty quaternion
  2678. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2679. */
  2680. static Zero(): Quaternion;
  2681. /**
  2682. * Inverse a given quaternion
  2683. * @param q defines the source quaternion
  2684. * @returns a new quaternion as the inverted current quaternion
  2685. */
  2686. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2687. /**
  2688. * Inverse a given quaternion
  2689. * @param q defines the source quaternion
  2690. * @param result the quaternion the result will be stored in
  2691. * @returns the result quaternion
  2692. */
  2693. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2694. /**
  2695. * Creates an identity quaternion
  2696. * @returns the identity quaternion
  2697. */
  2698. static Identity(): Quaternion;
  2699. /**
  2700. * Gets a boolean indicating if the given quaternion is identity
  2701. * @param quaternion defines the quaternion to check
  2702. * @returns true if the quaternion is identity
  2703. */
  2704. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2705. /**
  2706. * Creates a quaternion from a rotation around an axis
  2707. * @param axis defines the axis to use
  2708. * @param angle defines the angle to use
  2709. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2710. */
  2711. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2712. /**
  2713. * Creates a rotation around an axis and stores it into the given quaternion
  2714. * @param axis defines the axis to use
  2715. * @param angle defines the angle to use
  2716. * @param result defines the target quaternion
  2717. * @returns the target quaternion
  2718. */
  2719. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2720. /**
  2721. * Creates a new quaternion from data stored into an array
  2722. * @param array defines the data source
  2723. * @param offset defines the offset in the source array where the data starts
  2724. * @returns a new quaternion
  2725. */
  2726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2727. /**
  2728. * Create a quaternion from Euler rotation angles
  2729. * @param x Pitch
  2730. * @param y Yaw
  2731. * @param z Roll
  2732. * @returns the new Quaternion
  2733. */
  2734. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2735. /**
  2736. * Updates a quaternion from Euler rotation angles
  2737. * @param x Pitch
  2738. * @param y Yaw
  2739. * @param z Roll
  2740. * @param result the quaternion to store the result
  2741. * @returns the updated quaternion
  2742. */
  2743. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2744. /**
  2745. * Create a quaternion from Euler rotation vector
  2746. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2747. * @returns the new Quaternion
  2748. */
  2749. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2750. /**
  2751. * Updates a quaternion from Euler rotation vector
  2752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2753. * @param result the quaternion to store the result
  2754. * @returns the updated quaternion
  2755. */
  2756. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2757. /**
  2758. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2759. * @param yaw defines the rotation around Y axis
  2760. * @param pitch defines the rotation around X axis
  2761. * @param roll defines the rotation around Z axis
  2762. * @returns the new quaternion
  2763. */
  2764. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2765. /**
  2766. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2767. * @param yaw defines the rotation around Y axis
  2768. * @param pitch defines the rotation around X axis
  2769. * @param roll defines the rotation around Z axis
  2770. * @param result defines the target quaternion
  2771. */
  2772. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2773. /**
  2774. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2775. * @param alpha defines the rotation around first axis
  2776. * @param beta defines the rotation around second axis
  2777. * @param gamma defines the rotation around third axis
  2778. * @returns the new quaternion
  2779. */
  2780. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2781. /**
  2782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2783. * @param alpha defines the rotation around first axis
  2784. * @param beta defines the rotation around second axis
  2785. * @param gamma defines the rotation around third axis
  2786. * @param result defines the target quaternion
  2787. */
  2788. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2789. /**
  2790. * 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)
  2791. * @param axis1 defines the first axis
  2792. * @param axis2 defines the second axis
  2793. * @param axis3 defines the third axis
  2794. * @returns the new quaternion
  2795. */
  2796. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2797. /**
  2798. * 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
  2799. * @param axis1 defines the first axis
  2800. * @param axis2 defines the second axis
  2801. * @param axis3 defines the third axis
  2802. * @param ref defines the target quaternion
  2803. */
  2804. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2805. /**
  2806. * Interpolates between two quaternions
  2807. * @param left defines first quaternion
  2808. * @param right defines second quaternion
  2809. * @param amount defines the gradient to use
  2810. * @returns the new interpolated quaternion
  2811. */
  2812. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2813. /**
  2814. * Interpolates between two quaternions and stores it into a target quaternion
  2815. * @param left defines first quaternion
  2816. * @param right defines second quaternion
  2817. * @param amount defines the gradient to use
  2818. * @param result defines the target quaternion
  2819. */
  2820. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2821. /**
  2822. * Interpolate between two quaternions using Hermite interpolation
  2823. * @param value1 defines first quaternion
  2824. * @param tangent1 defines the incoming tangent
  2825. * @param value2 defines second quaternion
  2826. * @param tangent2 defines the outgoing tangent
  2827. * @param amount defines the target quaternion
  2828. * @returns the new interpolated quaternion
  2829. */
  2830. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2831. }
  2832. /**
  2833. * Class used to store matrix data (4x4)
  2834. */
  2835. export class Matrix {
  2836. private static _updateFlagSeed;
  2837. private static _identityReadOnly;
  2838. private _isIdentity;
  2839. private _isIdentityDirty;
  2840. private _isIdentity3x2;
  2841. private _isIdentity3x2Dirty;
  2842. /**
  2843. * Gets the update flag of the matrix which is an unique number for the matrix.
  2844. * It will be incremented every time the matrix data change.
  2845. * You can use it to speed the comparison between two versions of the same matrix.
  2846. */
  2847. updateFlag: number;
  2848. private readonly _m;
  2849. /**
  2850. * Gets the internal data of the matrix
  2851. */
  2852. readonly m: DeepImmutable<Float32Array>;
  2853. /** @hidden */
  2854. _markAsUpdated(): void;
  2855. /** @hidden */
  2856. private _updateIdentityStatus;
  2857. /**
  2858. * Creates an empty matrix (filled with zeros)
  2859. */
  2860. constructor();
  2861. /**
  2862. * Check if the current matrix is identity
  2863. * @returns true is the matrix is the identity matrix
  2864. */
  2865. isIdentity(): boolean;
  2866. /**
  2867. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2868. * @returns true is the matrix is the identity matrix
  2869. */
  2870. isIdentityAs3x2(): boolean;
  2871. /**
  2872. * Gets the determinant of the matrix
  2873. * @returns the matrix determinant
  2874. */
  2875. determinant(): number;
  2876. /**
  2877. * Returns the matrix as a Float32Array
  2878. * @returns the matrix underlying array
  2879. */
  2880. toArray(): DeepImmutable<Float32Array>;
  2881. /**
  2882. * Returns the matrix as a Float32Array
  2883. * @returns the matrix underlying array.
  2884. */
  2885. asArray(): DeepImmutable<Float32Array>;
  2886. /**
  2887. * Inverts the current matrix in place
  2888. * @returns the current inverted matrix
  2889. */
  2890. invert(): Matrix;
  2891. /**
  2892. * Sets all the matrix elements to zero
  2893. * @returns the current matrix
  2894. */
  2895. reset(): Matrix;
  2896. /**
  2897. * Adds the current matrix with a second one
  2898. * @param other defines the matrix to add
  2899. * @returns a new matrix as the addition of the current matrix and the given one
  2900. */
  2901. add(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2904. * @param other defines the matrix to add
  2905. * @param result defines the target matrix
  2906. * @returns the current matrix
  2907. */
  2908. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2909. /**
  2910. * Adds in place the given matrix to the current matrix
  2911. * @param other defines the second operand
  2912. * @returns the current updated matrix
  2913. */
  2914. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2915. /**
  2916. * Sets the given matrix to the current inverted Matrix
  2917. * @param other defines the target matrix
  2918. * @returns the unmodified current matrix
  2919. */
  2920. invertToRef(other: Matrix): Matrix;
  2921. /**
  2922. * add a value at the specified position in the current Matrix
  2923. * @param index the index of the value within the matrix. between 0 and 15.
  2924. * @param value the value to be added
  2925. * @returns the current updated matrix
  2926. */
  2927. addAtIndex(index: number, value: number): Matrix;
  2928. /**
  2929. * mutiply the specified position in the current Matrix by a value
  2930. * @param index the index of the value within the matrix. between 0 and 15.
  2931. * @param value the value to be added
  2932. * @returns the current updated matrix
  2933. */
  2934. multiplyAtIndex(index: number, value: number): Matrix;
  2935. /**
  2936. * Inserts the translation vector (using 3 floats) in the current matrix
  2937. * @param x defines the 1st component of the translation
  2938. * @param y defines the 2nd component of the translation
  2939. * @param z defines the 3rd component of the translation
  2940. * @returns the current updated matrix
  2941. */
  2942. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2943. /**
  2944. * Adds the translation vector (using 3 floats) in the current matrix
  2945. * @param x defines the 1st component of the translation
  2946. * @param y defines the 2nd component of the translation
  2947. * @param z defines the 3rd component of the translation
  2948. * @returns the current updated matrix
  2949. */
  2950. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2951. /**
  2952. * Inserts the translation vector in the current matrix
  2953. * @param vector3 defines the translation to insert
  2954. * @returns the current updated matrix
  2955. */
  2956. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2957. /**
  2958. * Gets the translation value of the current matrix
  2959. * @returns a new Vector3 as the extracted translation from the matrix
  2960. */
  2961. getTranslation(): Vector3;
  2962. /**
  2963. * Fill a Vector3 with the extracted translation from the matrix
  2964. * @param result defines the Vector3 where to store the translation
  2965. * @returns the current matrix
  2966. */
  2967. getTranslationToRef(result: Vector3): Matrix;
  2968. /**
  2969. * Remove rotation and scaling part from the matrix
  2970. * @returns the updated matrix
  2971. */
  2972. removeRotationAndScaling(): Matrix;
  2973. /**
  2974. * Multiply two matrices
  2975. * @param other defines the second operand
  2976. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2977. */
  2978. multiply(other: DeepImmutable<Matrix>): Matrix;
  2979. /**
  2980. * Copy the current matrix from the given one
  2981. * @param other defines the source matrix
  2982. * @returns the current updated matrix
  2983. */
  2984. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2985. /**
  2986. * Populates the given array from the starting index with the current matrix values
  2987. * @param array defines the target array
  2988. * @param offset defines the offset in the target array where to start storing values
  2989. * @returns the current matrix
  2990. */
  2991. copyToArray(array: Float32Array, offset?: number): Matrix;
  2992. /**
  2993. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2994. * @param other defines the second operand
  2995. * @param result defines the matrix where to store the multiplication
  2996. * @returns the current matrix
  2997. */
  2998. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2999. /**
  3000. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3001. * @param other defines the second operand
  3002. * @param result defines the array where to store the multiplication
  3003. * @param offset defines the offset in the target array where to start storing values
  3004. * @returns the current matrix
  3005. */
  3006. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3007. /**
  3008. * Check equality between this matrix and a second one
  3009. * @param value defines the second matrix to compare
  3010. * @returns true is the current matrix and the given one values are strictly equal
  3011. */
  3012. equals(value: DeepImmutable<Matrix>): boolean;
  3013. /**
  3014. * Clone the current matrix
  3015. * @returns a new matrix from the current matrix
  3016. */
  3017. clone(): Matrix;
  3018. /**
  3019. * Returns the name of the current matrix class
  3020. * @returns the string "Matrix"
  3021. */
  3022. getClassName(): string;
  3023. /**
  3024. * Gets the hash code of the current matrix
  3025. * @returns the hash code
  3026. */
  3027. getHashCode(): number;
  3028. /**
  3029. * Decomposes the current Matrix into a translation, rotation and scaling components
  3030. * @param scale defines the scale vector3 given as a reference to update
  3031. * @param rotation defines the rotation quaternion given as a reference to update
  3032. * @param translation defines the translation vector3 given as a reference to update
  3033. * @returns true if operation was successful
  3034. */
  3035. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3036. /**
  3037. * Gets specific row of the matrix
  3038. * @param index defines the number of the row to get
  3039. * @returns the index-th row of the current matrix as a new Vector4
  3040. */
  3041. getRow(index: number): Nullable<Vector4>;
  3042. /**
  3043. * Sets the index-th row of the current matrix to the vector4 values
  3044. * @param index defines the number of the row to set
  3045. * @param row defines the target vector4
  3046. * @returns the updated current matrix
  3047. */
  3048. setRow(index: number, row: Vector4): Matrix;
  3049. /**
  3050. * Compute the transpose of the matrix
  3051. * @returns the new transposed matrix
  3052. */
  3053. transpose(): Matrix;
  3054. /**
  3055. * Compute the transpose of the matrix and store it in a given matrix
  3056. * @param result defines the target matrix
  3057. * @returns the current matrix
  3058. */
  3059. transposeToRef(result: Matrix): Matrix;
  3060. /**
  3061. * Sets the index-th row of the current matrix with the given 4 x float values
  3062. * @param index defines the row index
  3063. * @param x defines the x component to set
  3064. * @param y defines the y component to set
  3065. * @param z defines the z component to set
  3066. * @param w defines the w component to set
  3067. * @returns the updated current matrix
  3068. */
  3069. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3070. /**
  3071. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3072. * @param scale defines the scale factor
  3073. * @returns a new matrix
  3074. */
  3075. scale(scale: number): Matrix;
  3076. /**
  3077. * Scale the current matrix values by a factor to a given result matrix
  3078. * @param scale defines the scale factor
  3079. * @param result defines the matrix to store the result
  3080. * @returns the current matrix
  3081. */
  3082. scaleToRef(scale: number, result: Matrix): Matrix;
  3083. /**
  3084. * Scale the current matrix values by a factor and add the result to a given matrix
  3085. * @param scale defines the scale factor
  3086. * @param result defines the Matrix to store the result
  3087. * @returns the current matrix
  3088. */
  3089. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3090. /**
  3091. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3092. * @param ref matrix to store the result
  3093. */
  3094. toNormalMatrix(ref: Matrix): void;
  3095. /**
  3096. * Gets only rotation part of the current matrix
  3097. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3098. */
  3099. getRotationMatrix(): Matrix;
  3100. /**
  3101. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3102. * @param result defines the target matrix to store data to
  3103. * @returns the current matrix
  3104. */
  3105. getRotationMatrixToRef(result: Matrix): Matrix;
  3106. /**
  3107. * Toggles model matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleModelMatrixHandInPlace(): void;
  3110. /**
  3111. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3112. */
  3113. toggleProjectionMatrixHandInPlace(): void;
  3114. /**
  3115. * Creates a matrix from an array
  3116. * @param array defines the source array
  3117. * @param offset defines an offset in the source array
  3118. * @returns a new Matrix set from the starting index of the given array
  3119. */
  3120. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3121. /**
  3122. * Copy the content of an array into a given matrix
  3123. * @param array defines the source array
  3124. * @param offset defines an offset in the source array
  3125. * @param result defines the target matrix
  3126. */
  3127. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3128. /**
  3129. * Stores an array into a matrix after having multiplied each component by a given factor
  3130. * @param array defines the source array
  3131. * @param offset defines the offset in the source array
  3132. * @param scale defines the scaling factor
  3133. * @param result defines the target matrix
  3134. */
  3135. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3136. /**
  3137. * Gets an identity matrix that must not be updated
  3138. */
  3139. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3140. /**
  3141. * Stores a list of values (16) inside a given matrix
  3142. * @param initialM11 defines 1st value of 1st row
  3143. * @param initialM12 defines 2nd value of 1st row
  3144. * @param initialM13 defines 3rd value of 1st row
  3145. * @param initialM14 defines 4th value of 1st row
  3146. * @param initialM21 defines 1st value of 2nd row
  3147. * @param initialM22 defines 2nd value of 2nd row
  3148. * @param initialM23 defines 3rd value of 2nd row
  3149. * @param initialM24 defines 4th value of 2nd row
  3150. * @param initialM31 defines 1st value of 3rd row
  3151. * @param initialM32 defines 2nd value of 3rd row
  3152. * @param initialM33 defines 3rd value of 3rd row
  3153. * @param initialM34 defines 4th value of 3rd row
  3154. * @param initialM41 defines 1st value of 4th row
  3155. * @param initialM42 defines 2nd value of 4th row
  3156. * @param initialM43 defines 3rd value of 4th row
  3157. * @param initialM44 defines 4th value of 4th row
  3158. * @param result defines the target matrix
  3159. */
  3160. 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;
  3161. /**
  3162. * Creates new matrix from a list of values (16)
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @returns the new matrix
  3180. */
  3181. 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;
  3182. /**
  3183. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3184. * @param scale defines the scale vector3
  3185. * @param rotation defines the rotation quaternion
  3186. * @param translation defines the translation vector3
  3187. * @returns a new matrix
  3188. */
  3189. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3190. /**
  3191. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3192. * @param scale defines the scale vector3
  3193. * @param rotation defines the rotation quaternion
  3194. * @param translation defines the translation vector3
  3195. * @param result defines the target matrix
  3196. */
  3197. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3198. /**
  3199. * Creates a new identity matrix
  3200. * @returns a new identity matrix
  3201. */
  3202. static Identity(): Matrix;
  3203. /**
  3204. * Creates a new identity matrix and stores the result in a given matrix
  3205. * @param result defines the target matrix
  3206. */
  3207. static IdentityToRef(result: Matrix): void;
  3208. /**
  3209. * Creates a new zero matrix
  3210. * @returns a new zero matrix
  3211. */
  3212. static Zero(): Matrix;
  3213. /**
  3214. * Creates a new rotation matrix for "angle" radians around the X axis
  3215. * @param angle defines the angle (in radians) to use
  3216. * @return the new matrix
  3217. */
  3218. static RotationX(angle: number): Matrix;
  3219. /**
  3220. * Creates a new matrix as the invert of a given matrix
  3221. * @param source defines the source matrix
  3222. * @returns the new matrix
  3223. */
  3224. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3225. /**
  3226. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3227. * @param angle defines the angle (in radians) to use
  3228. * @param result defines the target matrix
  3229. */
  3230. static RotationXToRef(angle: number, result: Matrix): void;
  3231. /**
  3232. * Creates a new rotation matrix for "angle" radians around the Y axis
  3233. * @param angle defines the angle (in radians) to use
  3234. * @return the new matrix
  3235. */
  3236. static RotationY(angle: number): Matrix;
  3237. /**
  3238. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3239. * @param angle defines the angle (in radians) to use
  3240. * @param result defines the target matrix
  3241. */
  3242. static RotationYToRef(angle: number, result: Matrix): void;
  3243. /**
  3244. * Creates a new rotation matrix for "angle" radians around the Z axis
  3245. * @param angle defines the angle (in radians) to use
  3246. * @return the new matrix
  3247. */
  3248. static RotationZ(angle: number): Matrix;
  3249. /**
  3250. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3251. * @param angle defines the angle (in radians) to use
  3252. * @param result defines the target matrix
  3253. */
  3254. static RotationZToRef(angle: number, result: Matrix): void;
  3255. /**
  3256. * Creates a new rotation matrix for "angle" radians around the given axis
  3257. * @param axis defines the axis to use
  3258. * @param angle defines the angle (in radians) to use
  3259. * @return the new matrix
  3260. */
  3261. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3262. /**
  3263. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3264. * @param axis defines the axis to use
  3265. * @param angle defines the angle (in radians) to use
  3266. * @param result defines the target matrix
  3267. */
  3268. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3269. /**
  3270. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3271. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3272. * @param from defines the vector to align
  3273. * @param to defines the vector to align to
  3274. * @param result defines the target matrix
  3275. */
  3276. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3277. /**
  3278. * Creates a rotation matrix
  3279. * @param yaw defines the yaw angle in radians (Y axis)
  3280. * @param pitch defines the pitch angle in radians (X axis)
  3281. * @param roll defines the roll angle in radians (X axis)
  3282. * @returns the new rotation matrix
  3283. */
  3284. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3285. /**
  3286. * Creates a rotation matrix and stores it in a given matrix
  3287. * @param yaw defines the yaw angle in radians (Y axis)
  3288. * @param pitch defines the pitch angle in radians (X axis)
  3289. * @param roll defines the roll angle in radians (X axis)
  3290. * @param result defines the target matrix
  3291. */
  3292. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3293. /**
  3294. * Creates a scaling matrix
  3295. * @param x defines the scale factor on X axis
  3296. * @param y defines the scale factor on Y axis
  3297. * @param z defines the scale factor on Z axis
  3298. * @returns the new matrix
  3299. */
  3300. static Scaling(x: number, y: number, z: number): Matrix;
  3301. /**
  3302. * Creates a scaling matrix and stores it in a given matrix
  3303. * @param x defines the scale factor on X axis
  3304. * @param y defines the scale factor on Y axis
  3305. * @param z defines the scale factor on Z axis
  3306. * @param result defines the target matrix
  3307. */
  3308. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3309. /**
  3310. * Creates a translation matrix
  3311. * @param x defines the translation on X axis
  3312. * @param y defines the translation on Y axis
  3313. * @param z defines the translationon Z axis
  3314. * @returns the new matrix
  3315. */
  3316. static Translation(x: number, y: number, z: number): Matrix;
  3317. /**
  3318. * Creates a translation matrix and stores it in a given matrix
  3319. * @param x defines the translation on X axis
  3320. * @param y defines the translation on Y axis
  3321. * @param z defines the translationon Z axis
  3322. * @param result defines the target matrix
  3323. */
  3324. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3325. /**
  3326. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3327. * @param startValue defines the start value
  3328. * @param endValue defines the end value
  3329. * @param gradient defines the gradient factor
  3330. * @returns the new matrix
  3331. */
  3332. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3333. /**
  3334. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3335. * @param startValue defines the start value
  3336. * @param endValue defines the end value
  3337. * @param gradient defines the gradient factor
  3338. * @param result defines the Matrix object where to store data
  3339. */
  3340. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3341. /**
  3342. * Builds a new matrix whose values are computed by:
  3343. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3344. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3345. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3346. * @param startValue defines the first matrix
  3347. * @param endValue defines the second matrix
  3348. * @param gradient defines the gradient between the two matrices
  3349. * @returns the new matrix
  3350. */
  3351. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3352. /**
  3353. * Update a matrix to values which are computed by:
  3354. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3355. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3356. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3357. * @param startValue defines the first matrix
  3358. * @param endValue defines the second matrix
  3359. * @param gradient defines the gradient between the two matrices
  3360. * @param result defines the target matrix
  3361. */
  3362. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3363. /**
  3364. * 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"
  3365. * This function works in left handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * 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".
  3374. * This function works in left handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * 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"
  3383. * This function works in right handed mode
  3384. * @param eye defines the final position of the entity
  3385. * @param target defines where the entity should look at
  3386. * @param up defines the up vector for the entity
  3387. * @returns the new matrix
  3388. */
  3389. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3390. /**
  3391. * 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".
  3392. * This function works in right handed mode
  3393. * @param eye defines the final position of the entity
  3394. * @param target defines where the entity should look at
  3395. * @param up defines the up vector for the entity
  3396. * @param result defines the target matrix
  3397. */
  3398. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param width defines the viewport width
  3402. * @param height defines the viewport height
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed orthographic projection matrix
  3406. */
  3407. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Store a left-handed orthographic projection to a given matrix
  3410. * @param width defines the viewport width
  3411. * @param height defines the viewport height
  3412. * @param znear defines the near clip plane
  3413. * @param zfar defines the far clip plane
  3414. * @param result defines the target matrix
  3415. */
  3416. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3417. /**
  3418. * Create a left-handed orthographic projection matrix
  3419. * @param left defines the viewport left coordinate
  3420. * @param right defines the viewport right coordinate
  3421. * @param bottom defines the viewport bottom coordinate
  3422. * @param top defines the viewport top coordinate
  3423. * @param znear defines the near clip plane
  3424. * @param zfar defines the far clip plane
  3425. * @returns a new matrix as a left-handed orthographic projection matrix
  3426. */
  3427. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3428. /**
  3429. * Stores a left-handed orthographic projection into a given matrix
  3430. * @param left defines the viewport left coordinate
  3431. * @param right defines the viewport right coordinate
  3432. * @param bottom defines the viewport bottom coordinate
  3433. * @param top defines the viewport top coordinate
  3434. * @param znear defines the near clip plane
  3435. * @param zfar defines the far clip plane
  3436. * @param result defines the target matrix
  3437. */
  3438. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3439. /**
  3440. * Creates a right-handed orthographic projection matrix
  3441. * @param left defines the viewport left coordinate
  3442. * @param right defines the viewport right coordinate
  3443. * @param bottom defines the viewport bottom coordinate
  3444. * @param top defines the viewport top coordinate
  3445. * @param znear defines the near clip plane
  3446. * @param zfar defines the far clip plane
  3447. * @returns a new matrix as a right-handed orthographic projection matrix
  3448. */
  3449. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3450. /**
  3451. * Stores a right-handed orthographic projection into a given matrix
  3452. * @param left defines the viewport left coordinate
  3453. * @param right defines the viewport right coordinate
  3454. * @param bottom defines the viewport bottom coordinate
  3455. * @param top defines the viewport top coordinate
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @param result defines the target matrix
  3459. */
  3460. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3461. /**
  3462. * Creates a left-handed perspective projection matrix
  3463. * @param width defines the viewport width
  3464. * @param height defines the viewport height
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @returns a new matrix as a left-handed perspective projection matrix
  3468. */
  3469. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3470. /**
  3471. * Creates a left-handed perspective projection matrix
  3472. * @param fov defines the horizontal field of view
  3473. * @param aspect defines the aspect ratio
  3474. * @param znear defines the near clip plane
  3475. * @param zfar defines the far clip plane
  3476. * @returns a new matrix as a left-handed perspective projection matrix
  3477. */
  3478. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3479. /**
  3480. * Stores a left-handed perspective projection into a given matrix
  3481. * @param fov defines the horizontal field of view
  3482. * @param aspect defines the aspect ratio
  3483. * @param znear defines the near clip plane
  3484. * @param zfar defines the far clip plane
  3485. * @param result defines the target matrix
  3486. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3487. */
  3488. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3489. /**
  3490. * Creates a right-handed perspective projection matrix
  3491. * @param fov defines the horizontal field of view
  3492. * @param aspect defines the aspect ratio
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @returns a new matrix as a right-handed perspective projection matrix
  3496. */
  3497. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3498. /**
  3499. * Stores a right-handed perspective projection into a given matrix
  3500. * @param fov defines the horizontal field of view
  3501. * @param aspect defines the aspect ratio
  3502. * @param znear defines the near clip plane
  3503. * @param zfar defines the far clip plane
  3504. * @param result defines the target matrix
  3505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3506. */
  3507. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3508. /**
  3509. * Stores a perspective projection for WebVR info a given matrix
  3510. * @param fov defines the field of view
  3511. * @param znear defines the near clip plane
  3512. * @param zfar defines the far clip plane
  3513. * @param result defines the target matrix
  3514. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3515. */
  3516. static PerspectiveFovWebVRToRef(fov: {
  3517. upDegrees: number;
  3518. downDegrees: number;
  3519. leftDegrees: number;
  3520. rightDegrees: number;
  3521. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3522. /**
  3523. * Computes a complete transformation matrix
  3524. * @param viewport defines the viewport to use
  3525. * @param world defines the world matrix
  3526. * @param view defines the view matrix
  3527. * @param projection defines the projection matrix
  3528. * @param zmin defines the near clip plane
  3529. * @param zmax defines the far clip plane
  3530. * @returns the transformation matrix
  3531. */
  3532. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3533. /**
  3534. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3535. * @param matrix defines the matrix to use
  3536. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3537. */
  3538. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3539. /**
  3540. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3541. * @param matrix defines the matrix to use
  3542. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3543. */
  3544. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3545. /**
  3546. * Compute the transpose of a given matrix
  3547. * @param matrix defines the matrix to transpose
  3548. * @returns the new matrix
  3549. */
  3550. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3551. /**
  3552. * Compute the transpose of a matrix and store it in a target matrix
  3553. * @param matrix defines the matrix to transpose
  3554. * @param result defines the target matrix
  3555. */
  3556. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3557. /**
  3558. * Computes a reflection matrix from a plane
  3559. * @param plane defines the reflection plane
  3560. * @returns a new matrix
  3561. */
  3562. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3563. /**
  3564. * Computes a reflection matrix from a plane
  3565. * @param plane defines the reflection plane
  3566. * @param result defines the target matrix
  3567. */
  3568. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3569. /**
  3570. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3571. * @param xaxis defines the value of the 1st axis
  3572. * @param yaxis defines the value of the 2nd axis
  3573. * @param zaxis defines the value of the 3rd axis
  3574. * @param result defines the target matrix
  3575. */
  3576. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3577. /**
  3578. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3579. * @param quat defines the quaternion to use
  3580. * @param result defines the target matrix
  3581. */
  3582. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3583. }
  3584. /**
  3585. * Represens a plane by the equation ax + by + cz + d = 0
  3586. */
  3587. export class Plane {
  3588. /**
  3589. * Normal of the plane (a,b,c)
  3590. */
  3591. normal: Vector3;
  3592. /**
  3593. * d component of the plane
  3594. */
  3595. d: number;
  3596. /**
  3597. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3598. * @param a a component of the plane
  3599. * @param b b component of the plane
  3600. * @param c c component of the plane
  3601. * @param d d component of the plane
  3602. */
  3603. constructor(a: number, b: number, c: number, d: number);
  3604. /**
  3605. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3606. */
  3607. asArray(): number[];
  3608. /**
  3609. * @returns a new plane copied from the current Plane.
  3610. */
  3611. clone(): Plane;
  3612. /**
  3613. * @returns the string "Plane".
  3614. */
  3615. getClassName(): string;
  3616. /**
  3617. * @returns the Plane hash code.
  3618. */
  3619. getHashCode(): number;
  3620. /**
  3621. * Normalize the current Plane in place.
  3622. * @returns the updated Plane.
  3623. */
  3624. normalize(): Plane;
  3625. /**
  3626. * Applies a transformation the plane and returns the result
  3627. * @param transformation the transformation matrix to be applied to the plane
  3628. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3629. */
  3630. transform(transformation: DeepImmutable<Matrix>): Plane;
  3631. /**
  3632. * Calcualtte the dot product between the point and the plane normal
  3633. * @param point point to calculate the dot product with
  3634. * @returns the dot product (float) of the point coordinates and the plane normal.
  3635. */
  3636. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3637. /**
  3638. * Updates the current Plane from the plane defined by the three given points.
  3639. * @param point1 one of the points used to contruct the plane
  3640. * @param point2 one of the points used to contruct the plane
  3641. * @param point3 one of the points used to contruct the plane
  3642. * @returns the updated Plane.
  3643. */
  3644. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3645. /**
  3646. * Checks if the plane is facing a given direction
  3647. * @param direction the direction to check if the plane is facing
  3648. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3649. * @returns True is the vector "direction" is the same side than the plane normal.
  3650. */
  3651. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3652. /**
  3653. * Calculates the distance to a point
  3654. * @param point point to calculate distance to
  3655. * @returns the signed distance (float) from the given point to the Plane.
  3656. */
  3657. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Creates a plane from an array
  3660. * @param array the array to create a plane from
  3661. * @returns a new Plane from the given array.
  3662. */
  3663. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3664. /**
  3665. * Creates a plane from three points
  3666. * @param point1 point used to create the plane
  3667. * @param point2 point used to create the plane
  3668. * @param point3 point used to create the plane
  3669. * @returns a new Plane defined by the three given points.
  3670. */
  3671. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3672. /**
  3673. * Creates a plane from an origin point and a normal
  3674. * @param origin origin of the plane to be constructed
  3675. * @param normal normal of the plane to be constructed
  3676. * @returns a new Plane the normal vector to this plane at the given origin point.
  3677. * Note : the vector "normal" is updated because normalized.
  3678. */
  3679. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3680. /**
  3681. * Calculates the distance from a plane and a point
  3682. * @param origin origin of the plane to be constructed
  3683. * @param normal normal of the plane to be constructed
  3684. * @param point point to calculate distance to
  3685. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3686. */
  3687. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3688. }
  3689. /**
  3690. * Class used to represent a viewport on screen
  3691. */
  3692. export class Viewport {
  3693. /** viewport left coordinate */
  3694. x: number;
  3695. /** viewport top coordinate */
  3696. y: number;
  3697. /**viewport width */
  3698. width: number;
  3699. /** viewport height */
  3700. height: number;
  3701. /**
  3702. * Creates a Viewport object located at (x, y) and sized (width, height)
  3703. * @param x defines viewport left coordinate
  3704. * @param y defines viewport top coordinate
  3705. * @param width defines the viewport width
  3706. * @param height defines the viewport height
  3707. */
  3708. constructor(
  3709. /** viewport left coordinate */
  3710. x: number,
  3711. /** viewport top coordinate */
  3712. y: number,
  3713. /**viewport width */
  3714. width: number,
  3715. /** viewport height */
  3716. height: number);
  3717. /**
  3718. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3719. * @param renderWidth defines the rendering width
  3720. * @param renderHeight defines the rendering height
  3721. * @returns a new Viewport
  3722. */
  3723. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3724. /**
  3725. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3726. * @param renderWidth defines the rendering width
  3727. * @param renderHeight defines the rendering height
  3728. * @param ref defines the target viewport
  3729. * @returns the current viewport
  3730. */
  3731. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3732. /**
  3733. * Returns a new Viewport copied from the current one
  3734. * @returns a new Viewport
  3735. */
  3736. clone(): Viewport;
  3737. }
  3738. /**
  3739. * Reprasents a camera frustum
  3740. */
  3741. export class Frustum {
  3742. /**
  3743. * Gets the planes representing the frustum
  3744. * @param transform matrix to be applied to the returned planes
  3745. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3746. */
  3747. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3748. /**
  3749. * Gets the near frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the far frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the left frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Gets the right frustum plane transformed by the transform matrix
  3768. * @param transform transformation matrix to be applied to the resulting frustum plane
  3769. * @param frustumPlane the resuling frustum plane
  3770. */
  3771. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3772. /**
  3773. * Gets the top frustum plane transformed by the transform matrix
  3774. * @param transform transformation matrix to be applied to the resulting frustum plane
  3775. * @param frustumPlane the resuling frustum plane
  3776. */
  3777. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3778. /**
  3779. * Gets the bottom frustum plane transformed by the transform matrix
  3780. * @param transform transformation matrix to be applied to the resulting frustum plane
  3781. * @param frustumPlane the resuling frustum plane
  3782. */
  3783. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3784. /**
  3785. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3786. * @param transform transformation matrix to be applied to the resulting frustum planes
  3787. * @param frustumPlanes the resuling frustum planes
  3788. */
  3789. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3790. }
  3791. /** Defines supported spaces */
  3792. export enum Space {
  3793. /** Local (object) space */
  3794. LOCAL = 0,
  3795. /** World space */
  3796. WORLD = 1,
  3797. /** Bone space */
  3798. BONE = 2
  3799. }
  3800. /** Defines the 3 main axes */
  3801. export class Axis {
  3802. /** X axis */
  3803. static X: Vector3;
  3804. /** Y axis */
  3805. static Y: Vector3;
  3806. /** Z axis */
  3807. static Z: Vector3;
  3808. }
  3809. /** Class used to represent a Bezier curve */
  3810. export class BezierCurve {
  3811. /**
  3812. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3813. * @param t defines the time
  3814. * @param x1 defines the left coordinate on X axis
  3815. * @param y1 defines the left coordinate on Y axis
  3816. * @param x2 defines the right coordinate on X axis
  3817. * @param y2 defines the right coordinate on Y axis
  3818. * @returns the interpolated value
  3819. */
  3820. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3821. }
  3822. /**
  3823. * Defines potential orientation for back face culling
  3824. */
  3825. export enum Orientation {
  3826. /**
  3827. * Clockwise
  3828. */
  3829. CW = 0,
  3830. /** Counter clockwise */
  3831. CCW = 1
  3832. }
  3833. /**
  3834. * Defines angle representation
  3835. */
  3836. export class Angle {
  3837. private _radians;
  3838. /**
  3839. * Creates an Angle object of "radians" radians (float).
  3840. * @param radians the angle in radians
  3841. */
  3842. constructor(radians: number);
  3843. /**
  3844. * Get value in degrees
  3845. * @returns the Angle value in degrees (float)
  3846. */
  3847. degrees(): number;
  3848. /**
  3849. * Get value in radians
  3850. * @returns the Angle value in radians (float)
  3851. */
  3852. radians(): number;
  3853. /**
  3854. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3855. * @param a defines first vector
  3856. * @param b defines second vector
  3857. * @returns a new Angle
  3858. */
  3859. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3860. /**
  3861. * Gets a new Angle object from the given float in radians
  3862. * @param radians defines the angle value in radians
  3863. * @returns a new Angle
  3864. */
  3865. static FromRadians(radians: number): Angle;
  3866. /**
  3867. * Gets a new Angle object from the given float in degrees
  3868. * @param degrees defines the angle value in degrees
  3869. * @returns a new Angle
  3870. */
  3871. static FromDegrees(degrees: number): Angle;
  3872. }
  3873. /**
  3874. * This represents an arc in a 2d space.
  3875. */
  3876. export class Arc2 {
  3877. /** Defines the start point of the arc */
  3878. startPoint: Vector2;
  3879. /** Defines the mid point of the arc */
  3880. midPoint: Vector2;
  3881. /** Defines the end point of the arc */
  3882. endPoint: Vector2;
  3883. /**
  3884. * Defines the center point of the arc.
  3885. */
  3886. centerPoint: Vector2;
  3887. /**
  3888. * Defines the radius of the arc.
  3889. */
  3890. radius: number;
  3891. /**
  3892. * Defines the angle of the arc (from mid point to end point).
  3893. */
  3894. angle: Angle;
  3895. /**
  3896. * Defines the start angle of the arc (from start point to middle point).
  3897. */
  3898. startAngle: Angle;
  3899. /**
  3900. * Defines the orientation of the arc (clock wise/counter clock wise).
  3901. */
  3902. orientation: Orientation;
  3903. /**
  3904. * Creates an Arc object from the three given points : start, middle and end.
  3905. * @param startPoint Defines the start point of the arc
  3906. * @param midPoint Defines the midlle point of the arc
  3907. * @param endPoint Defines the end point of the arc
  3908. */
  3909. constructor(
  3910. /** Defines the start point of the arc */
  3911. startPoint: Vector2,
  3912. /** Defines the mid point of the arc */
  3913. midPoint: Vector2,
  3914. /** Defines the end point of the arc */
  3915. endPoint: Vector2);
  3916. }
  3917. /**
  3918. * Represents a 2D path made up of multiple 2D points
  3919. */
  3920. export class Path2 {
  3921. private _points;
  3922. private _length;
  3923. /**
  3924. * If the path start and end point are the same
  3925. */
  3926. closed: boolean;
  3927. /**
  3928. * Creates a Path2 object from the starting 2D coordinates x and y.
  3929. * @param x the starting points x value
  3930. * @param y the starting points y value
  3931. */
  3932. constructor(x: number, y: number);
  3933. /**
  3934. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3935. * @param x the added points x value
  3936. * @param y the added points y value
  3937. * @returns the updated Path2.
  3938. */
  3939. addLineTo(x: number, y: number): Path2;
  3940. /**
  3941. * 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.
  3942. * @param midX middle point x value
  3943. * @param midY middle point y value
  3944. * @param endX end point x value
  3945. * @param endY end point y value
  3946. * @param numberOfSegments (default: 36)
  3947. * @returns the updated Path2.
  3948. */
  3949. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3950. /**
  3951. * Closes the Path2.
  3952. * @returns the Path2.
  3953. */
  3954. close(): Path2;
  3955. /**
  3956. * Gets the sum of the distance between each sequential point in the path
  3957. * @returns the Path2 total length (float).
  3958. */
  3959. length(): number;
  3960. /**
  3961. * Gets the points which construct the path
  3962. * @returns the Path2 internal array of points.
  3963. */
  3964. getPoints(): Vector2[];
  3965. /**
  3966. * Retreives the point at the distance aways from the starting point
  3967. * @param normalizedLengthPosition the length along the path to retreive the point from
  3968. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3969. */
  3970. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3971. /**
  3972. * Creates a new path starting from an x and y position
  3973. * @param x starting x value
  3974. * @param y starting y value
  3975. * @returns a new Path2 starting at the coordinates (x, y).
  3976. */
  3977. static StartingAt(x: number, y: number): Path2;
  3978. }
  3979. /**
  3980. * Represents a 3D path made up of multiple 3D points
  3981. */
  3982. export class Path3D {
  3983. /**
  3984. * an array of Vector3, the curve axis of the Path3D
  3985. */
  3986. path: Vector3[];
  3987. private _curve;
  3988. private _distances;
  3989. private _tangents;
  3990. private _normals;
  3991. private _binormals;
  3992. private _raw;
  3993. /**
  3994. * new Path3D(path, normal, raw)
  3995. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3996. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3997. * @param path an array of Vector3, the curve axis of the Path3D
  3998. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3999. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4000. */
  4001. constructor(
  4002. /**
  4003. * an array of Vector3, the curve axis of the Path3D
  4004. */
  4005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4006. /**
  4007. * Returns the Path3D array of successive Vector3 designing its curve.
  4008. * @returns the Path3D array of successive Vector3 designing its curve.
  4009. */
  4010. getCurve(): Vector3[];
  4011. /**
  4012. * Returns an array populated with tangent vectors on each Path3D curve point.
  4013. * @returns an array populated with tangent vectors on each Path3D curve point.
  4014. */
  4015. getTangents(): Vector3[];
  4016. /**
  4017. * Returns an array populated with normal vectors on each Path3D curve point.
  4018. * @returns an array populated with normal vectors on each Path3D curve point.
  4019. */
  4020. getNormals(): Vector3[];
  4021. /**
  4022. * Returns an array populated with binormal vectors on each Path3D curve point.
  4023. * @returns an array populated with binormal vectors on each Path3D curve point.
  4024. */
  4025. getBinormals(): Vector3[];
  4026. /**
  4027. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4028. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4029. */
  4030. getDistances(): number[];
  4031. /**
  4032. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4033. * @param path path which all values are copied into the curves points
  4034. * @param firstNormal which should be projected onto the curve
  4035. * @returns the same object updated.
  4036. */
  4037. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4038. private _compute;
  4039. private _getFirstNonNullVector;
  4040. private _getLastNonNullVector;
  4041. private _normalVector;
  4042. }
  4043. /**
  4044. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4045. * A Curve3 is designed from a series of successive Vector3.
  4046. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4047. */
  4048. export class Curve3 {
  4049. private _points;
  4050. private _length;
  4051. /**
  4052. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4053. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4054. * @param v1 (Vector3) the control point
  4055. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4056. * @param nbPoints (integer) the wanted number of points in the curve
  4057. * @returns the created Curve3
  4058. */
  4059. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4060. /**
  4061. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4062. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4063. * @param v1 (Vector3) the first control point
  4064. * @param v2 (Vector3) the second control point
  4065. * @param v3 (Vector3) the end point of the Cubic Bezier
  4066. * @param nbPoints (integer) the wanted number of points in the curve
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4070. /**
  4071. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4072. * @param p1 (Vector3) the origin point of the Hermite Spline
  4073. * @param t1 (Vector3) the tangent vector at the origin point
  4074. * @param p2 (Vector3) the end point of the Hermite Spline
  4075. * @param t2 (Vector3) the tangent vector at the end point
  4076. * @param nbPoints (integer) the wanted number of points in the curve
  4077. * @returns the created Curve3
  4078. */
  4079. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4080. /**
  4081. * Returns a Curve3 object along a CatmullRom Spline curve :
  4082. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4083. * @param nbPoints (integer) the wanted number of points between each curve control points
  4084. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4085. * @returns the created Curve3
  4086. */
  4087. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4088. /**
  4089. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4090. * A Curve3 is designed from a series of successive Vector3.
  4091. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4092. * @param points points which make up the curve
  4093. */
  4094. constructor(points: Vector3[]);
  4095. /**
  4096. * @returns the Curve3 stored array of successive Vector3
  4097. */
  4098. getPoints(): Vector3[];
  4099. /**
  4100. * @returns the computed length (float) of the curve.
  4101. */
  4102. length(): number;
  4103. /**
  4104. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4105. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4106. * curveA and curveB keep unchanged.
  4107. * @param curve the curve to continue from this curve
  4108. * @returns the newly constructed curve
  4109. */
  4110. continue(curve: DeepImmutable<Curve3>): Curve3;
  4111. private _computeLength;
  4112. }
  4113. /**
  4114. * Contains position and normal vectors for a vertex
  4115. */
  4116. export class PositionNormalVertex {
  4117. /** the position of the vertex (defaut: 0,0,0) */
  4118. position: Vector3;
  4119. /** the normal of the vertex (defaut: 0,1,0) */
  4120. normal: Vector3;
  4121. /**
  4122. * Creates a PositionNormalVertex
  4123. * @param position the position of the vertex (defaut: 0,0,0)
  4124. * @param normal the normal of the vertex (defaut: 0,1,0)
  4125. */
  4126. constructor(
  4127. /** the position of the vertex (defaut: 0,0,0) */
  4128. position?: Vector3,
  4129. /** the normal of the vertex (defaut: 0,1,0) */
  4130. normal?: Vector3);
  4131. /**
  4132. * Clones the PositionNormalVertex
  4133. * @returns the cloned PositionNormalVertex
  4134. */
  4135. clone(): PositionNormalVertex;
  4136. }
  4137. /**
  4138. * Contains position, normal and uv vectors for a vertex
  4139. */
  4140. export class PositionNormalTextureVertex {
  4141. /** the position of the vertex (defaut: 0,0,0) */
  4142. position: Vector3;
  4143. /** the normal of the vertex (defaut: 0,1,0) */
  4144. normal: Vector3;
  4145. /** the uv of the vertex (default: 0,0) */
  4146. uv: Vector2;
  4147. /**
  4148. * Creates a PositionNormalTextureVertex
  4149. * @param position the position of the vertex (defaut: 0,0,0)
  4150. * @param normal the normal of the vertex (defaut: 0,1,0)
  4151. * @param uv the uv of the vertex (default: 0,0)
  4152. */
  4153. constructor(
  4154. /** the position of the vertex (defaut: 0,0,0) */
  4155. position?: Vector3,
  4156. /** the normal of the vertex (defaut: 0,1,0) */
  4157. normal?: Vector3,
  4158. /** the uv of the vertex (default: 0,0) */
  4159. uv?: Vector2);
  4160. /**
  4161. * Clones the PositionNormalTextureVertex
  4162. * @returns the cloned PositionNormalTextureVertex
  4163. */
  4164. clone(): PositionNormalTextureVertex;
  4165. }
  4166. /**
  4167. * @hidden
  4168. */
  4169. export class Tmp {
  4170. static Color3: Color3[];
  4171. static Color4: Color4[];
  4172. static Vector2: Vector2[];
  4173. static Vector3: Vector3[];
  4174. static Vector4: Vector4[];
  4175. static Quaternion: Quaternion[];
  4176. static Matrix: Matrix[];
  4177. }
  4178. }
  4179. declare module "babylonjs/Offline/IOfflineProvider" {
  4180. /**
  4181. * Class used to enable access to offline support
  4182. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4183. */
  4184. export interface IOfflineProvider {
  4185. /**
  4186. * Gets a boolean indicating if scene must be saved in the database
  4187. */
  4188. enableSceneOffline: boolean;
  4189. /**
  4190. * Gets a boolean indicating if textures must be saved in the database
  4191. */
  4192. enableTexturesOffline: boolean;
  4193. /**
  4194. * Open the offline support and make it available
  4195. * @param successCallback defines the callback to call on success
  4196. * @param errorCallback defines the callback to call on error
  4197. */
  4198. open(successCallback: () => void, errorCallback: () => void): void;
  4199. /**
  4200. * Loads an image from the offline support
  4201. * @param url defines the url to load from
  4202. * @param image defines the target DOM image
  4203. */
  4204. loadImage(url: string, image: HTMLImageElement): void;
  4205. /**
  4206. * Loads a file from offline support
  4207. * @param url defines the URL to load from
  4208. * @param sceneLoaded defines a callback to call on success
  4209. * @param progressCallBack defines a callback to call when progress changed
  4210. * @param errorCallback defines a callback to call on error
  4211. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4212. */
  4213. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4214. }
  4215. }
  4216. declare module "babylonjs/Misc/observable" {
  4217. import { Nullable } from "babylonjs/types";
  4218. /**
  4219. * A class serves as a medium between the observable and its observers
  4220. */
  4221. export class EventState {
  4222. /**
  4223. * Create a new EventState
  4224. * @param mask defines the mask associated with this state
  4225. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4226. * @param target defines the original target of the state
  4227. * @param currentTarget defines the current target of the state
  4228. */
  4229. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4230. /**
  4231. * Initialize the current event state
  4232. * @param mask defines the mask associated with this state
  4233. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4234. * @param target defines the original target of the state
  4235. * @param currentTarget defines the current target of the state
  4236. * @returns the current event state
  4237. */
  4238. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4239. /**
  4240. * An Observer can set this property to true to prevent subsequent observers of being notified
  4241. */
  4242. skipNextObservers: boolean;
  4243. /**
  4244. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4245. */
  4246. mask: number;
  4247. /**
  4248. * The object that originally notified the event
  4249. */
  4250. target?: any;
  4251. /**
  4252. * The current object in the bubbling phase
  4253. */
  4254. currentTarget?: any;
  4255. /**
  4256. * This will be populated with the return value of the last function that was executed.
  4257. * If it is the first function in the callback chain it will be the event data.
  4258. */
  4259. lastReturnValue?: any;
  4260. }
  4261. /**
  4262. * Represent an Observer registered to a given Observable object.
  4263. */
  4264. export class Observer<T> {
  4265. /**
  4266. * Defines the callback to call when the observer is notified
  4267. */
  4268. callback: (eventData: T, eventState: EventState) => void;
  4269. /**
  4270. * Defines the mask of the observer (used to filter notifications)
  4271. */
  4272. mask: number;
  4273. /**
  4274. * Defines the current scope used to restore the JS context
  4275. */
  4276. scope: any;
  4277. /** @hidden */
  4278. _willBeUnregistered: boolean;
  4279. /**
  4280. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4281. */
  4282. unregisterOnNextCall: boolean;
  4283. /**
  4284. * Creates a new observer
  4285. * @param callback defines the callback to call when the observer is notified
  4286. * @param mask defines the mask of the observer (used to filter notifications)
  4287. * @param scope defines the current scope used to restore the JS context
  4288. */
  4289. constructor(
  4290. /**
  4291. * Defines the callback to call when the observer is notified
  4292. */
  4293. callback: (eventData: T, eventState: EventState) => void,
  4294. /**
  4295. * Defines the mask of the observer (used to filter notifications)
  4296. */
  4297. mask: number,
  4298. /**
  4299. * Defines the current scope used to restore the JS context
  4300. */
  4301. scope?: any);
  4302. }
  4303. /**
  4304. * Represent a list of observers registered to multiple Observables object.
  4305. */
  4306. export class MultiObserver<T> {
  4307. private _observers;
  4308. private _observables;
  4309. /**
  4310. * Release associated resources
  4311. */
  4312. dispose(): void;
  4313. /**
  4314. * Raise a callback when one of the observable will notify
  4315. * @param observables defines a list of observables to watch
  4316. * @param callback defines the callback to call on notification
  4317. * @param mask defines the mask used to filter notifications
  4318. * @param scope defines the current scope used to restore the JS context
  4319. * @returns the new MultiObserver
  4320. */
  4321. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4322. }
  4323. /**
  4324. * The Observable class is a simple implementation of the Observable pattern.
  4325. *
  4326. * 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.
  4327. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4328. * 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).
  4329. * 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.
  4330. */
  4331. export class Observable<T> {
  4332. private _observers;
  4333. private _eventState;
  4334. private _onObserverAdded;
  4335. /**
  4336. * Creates a new observable
  4337. * @param onObserverAdded defines a callback to call when a new observer is added
  4338. */
  4339. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4340. /**
  4341. * Create a new Observer with the specified callback
  4342. * @param callback the callback that will be executed for that Observer
  4343. * @param mask the mask used to filter observers
  4344. * @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.
  4345. * @param scope optional scope for the callback to be called from
  4346. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4347. * @returns the new observer created for the callback
  4348. */
  4349. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4350. /**
  4351. * Create a new Observer with the specified callback and unregisters after the next notification
  4352. * @param callback the callback that will be executed for that Observer
  4353. * @returns the new observer created for the callback
  4354. */
  4355. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4356. /**
  4357. * Remove an Observer from the Observable object
  4358. * @param observer the instance of the Observer to remove
  4359. * @returns false if it doesn't belong to this Observable
  4360. */
  4361. remove(observer: Nullable<Observer<T>>): boolean;
  4362. /**
  4363. * Remove a callback from the Observable object
  4364. * @param callback the callback to remove
  4365. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4366. * @returns false if it doesn't belong to this Observable
  4367. */
  4368. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4369. private _deferUnregister;
  4370. private _remove;
  4371. /**
  4372. * Moves the observable to the top of the observer list making it get called first when notified
  4373. * @param observer the observer to move
  4374. */
  4375. makeObserverTopPriority(observer: Observer<T>): void;
  4376. /**
  4377. * Moves the observable to the bottom of the observer list making it get called last when notified
  4378. * @param observer the observer to move
  4379. */
  4380. makeObserverBottomPriority(observer: Observer<T>): void;
  4381. /**
  4382. * Notify all Observers by calling their respective callback with the given data
  4383. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4384. * @param eventData defines the data to send to all observers
  4385. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4386. * @param target defines the original target of the state
  4387. * @param currentTarget defines the current target of the state
  4388. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4389. */
  4390. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4391. /**
  4392. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4393. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4394. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4395. * and it is crucial that all callbacks will be executed.
  4396. * The order of the callbacks is kept, callbacks are not executed parallel.
  4397. *
  4398. * @param eventData The data to be sent to each callback
  4399. * @param mask is used to filter observers defaults to -1
  4400. * @param target defines the callback target (see EventState)
  4401. * @param currentTarget defines he current object in the bubbling phase
  4402. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4403. */
  4404. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4405. /**
  4406. * Notify a specific observer
  4407. * @param observer defines the observer to notify
  4408. * @param eventData defines the data to be sent to each callback
  4409. * @param mask is used to filter observers defaults to -1
  4410. */
  4411. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4412. /**
  4413. * Gets a boolean indicating if the observable has at least one observer
  4414. * @returns true is the Observable has at least one Observer registered
  4415. */
  4416. hasObservers(): boolean;
  4417. /**
  4418. * Clear the list of observers
  4419. */
  4420. clear(): void;
  4421. /**
  4422. * Clone the current observable
  4423. * @returns a new observable
  4424. */
  4425. clone(): Observable<T>;
  4426. /**
  4427. * Does this observable handles observer registered with a given mask
  4428. * @param mask defines the mask to be tested
  4429. * @return whether or not one observer registered with the given mask is handeled
  4430. **/
  4431. hasSpecificMask(mask?: number): boolean;
  4432. }
  4433. }
  4434. declare module "babylonjs/Misc/filesInputStore" {
  4435. /**
  4436. * Class used to help managing file picking and drag'n'drop
  4437. * File Storage
  4438. */
  4439. export class FilesInputStore {
  4440. /**
  4441. * List of files ready to be loaded
  4442. */
  4443. static FilesToLoad: {
  4444. [key: string]: File;
  4445. };
  4446. }
  4447. }
  4448. declare module "babylonjs/Engines/constants" {
  4449. /** Defines the cross module used constants to avoid circular dependncies */
  4450. export class Constants {
  4451. /** Defines that alpha blending is disabled */
  4452. static readonly ALPHA_DISABLE: number;
  4453. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4454. static readonly ALPHA_ADD: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4456. static readonly ALPHA_COMBINE: number;
  4457. /** Defines that alpha blending to DEST - SRC * DEST */
  4458. static readonly ALPHA_SUBTRACT: number;
  4459. /** Defines that alpha blending to SRC * DEST */
  4460. static readonly ALPHA_MULTIPLY: number;
  4461. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4462. static readonly ALPHA_MAXIMIZED: number;
  4463. /** Defines that alpha blending to SRC + DEST */
  4464. static readonly ALPHA_ONEONE: number;
  4465. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4466. static readonly ALPHA_PREMULTIPLIED: number;
  4467. /**
  4468. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4469. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4470. */
  4471. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4472. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4473. static readonly ALPHA_INTERPOLATE: number;
  4474. /**
  4475. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4476. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4477. */
  4478. static readonly ALPHA_SCREENMODE: number;
  4479. /** Defines that the ressource is not delayed*/
  4480. static readonly DELAYLOADSTATE_NONE: number;
  4481. /** Defines that the ressource was successfully delay loaded */
  4482. static readonly DELAYLOADSTATE_LOADED: number;
  4483. /** Defines that the ressource is currently delay loading */
  4484. static readonly DELAYLOADSTATE_LOADING: number;
  4485. /** Defines that the ressource is delayed and has not started loading */
  4486. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4488. static readonly NEVER: number;
  4489. /** 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 */
  4490. static readonly ALWAYS: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4492. static readonly LESS: number;
  4493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4494. static readonly EQUAL: number;
  4495. /** 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 */
  4496. static readonly LEQUAL: number;
  4497. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4498. static readonly GREATER: number;
  4499. /** 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 */
  4500. static readonly GEQUAL: number;
  4501. /** 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 */
  4502. static readonly NOTEQUAL: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be kept */
  4504. static readonly KEEP: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4506. static readonly REPLACE: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4508. static readonly INCR: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4510. static readonly DECR: number;
  4511. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4512. static readonly INVERT: number;
  4513. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4514. static readonly INCR_WRAP: number;
  4515. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4516. static readonly DECR_WRAP: number;
  4517. /** Texture is not repeating outside of 0..1 UVs */
  4518. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4519. /** Texture is repeating outside of 0..1 UVs */
  4520. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4521. /** Texture is repeating and mirrored */
  4522. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4523. /** ALPHA */
  4524. static readonly TEXTUREFORMAT_ALPHA: number;
  4525. /** LUMINANCE */
  4526. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4527. /** LUMINANCE_ALPHA */
  4528. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4529. /** RGB */
  4530. static readonly TEXTUREFORMAT_RGB: number;
  4531. /** RGBA */
  4532. static readonly TEXTUREFORMAT_RGBA: number;
  4533. /** RED */
  4534. static readonly TEXTUREFORMAT_RED: number;
  4535. /** RED (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R: number;
  4537. /** RG */
  4538. static readonly TEXTUREFORMAT_RG: number;
  4539. /** RED_INTEGER */
  4540. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4541. /** RED_INTEGER (2nd reference) */
  4542. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4543. /** RG_INTEGER */
  4544. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4545. /** RGB_INTEGER */
  4546. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4547. /** RGBA_INTEGER */
  4548. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4549. /** UNSIGNED_BYTE */
  4550. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4551. /** UNSIGNED_BYTE (2nd reference) */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4553. /** FLOAT */
  4554. static readonly TEXTURETYPE_FLOAT: number;
  4555. /** HALF_FLOAT */
  4556. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4557. /** BYTE */
  4558. static readonly TEXTURETYPE_BYTE: number;
  4559. /** SHORT */
  4560. static readonly TEXTURETYPE_SHORT: number;
  4561. /** UNSIGNED_SHORT */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4563. /** INT */
  4564. static readonly TEXTURETYPE_INT: number;
  4565. /** UNSIGNED_INT */
  4566. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4567. /** UNSIGNED_SHORT_4_4_4_4 */
  4568. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4569. /** UNSIGNED_SHORT_5_5_5_1 */
  4570. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4571. /** UNSIGNED_SHORT_5_6_5 */
  4572. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4573. /** UNSIGNED_INT_2_10_10_10_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4575. /** UNSIGNED_INT_24_8 */
  4576. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4577. /** UNSIGNED_INT_10F_11F_11F_REV */
  4578. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4579. /** UNSIGNED_INT_5_9_9_9_REV */
  4580. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4581. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4582. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4589. /** nearest is mag = nearest and min = nearest and mip = linear */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4592. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4593. /** Trilinear is mag = linear and min = linear and mip = linear */
  4594. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = nearest and mip = nearest */
  4596. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4597. /** mag = nearest and min = linear and mip = nearest */
  4598. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4599. /** mag = nearest and min = linear and mip = linear */
  4600. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4601. /** mag = nearest and min = linear and mip = none */
  4602. static readonly TEXTURE_NEAREST_LINEAR: number;
  4603. /** mag = nearest and min = nearest and mip = none */
  4604. static readonly TEXTURE_NEAREST_NEAREST: number;
  4605. /** mag = linear and min = nearest and mip = nearest */
  4606. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4607. /** mag = linear and min = nearest and mip = linear */
  4608. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4609. /** mag = linear and min = linear and mip = none */
  4610. static readonly TEXTURE_LINEAR_LINEAR: number;
  4611. /** mag = linear and min = nearest and mip = none */
  4612. static readonly TEXTURE_LINEAR_NEAREST: number;
  4613. /** Explicit coordinates mode */
  4614. static readonly TEXTURE_EXPLICIT_MODE: number;
  4615. /** Spherical coordinates mode */
  4616. static readonly TEXTURE_SPHERICAL_MODE: number;
  4617. /** Planar coordinates mode */
  4618. static readonly TEXTURE_PLANAR_MODE: number;
  4619. /** Cubic coordinates mode */
  4620. static readonly TEXTURE_CUBIC_MODE: number;
  4621. /** Projection coordinates mode */
  4622. static readonly TEXTURE_PROJECTION_MODE: number;
  4623. /** Skybox coordinates mode */
  4624. static readonly TEXTURE_SKYBOX_MODE: number;
  4625. /** Inverse Cubic coordinates mode */
  4626. static readonly TEXTURE_INVCUBIC_MODE: number;
  4627. /** Equirectangular coordinates mode */
  4628. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4629. /** Equirectangular Fixed coordinates mode */
  4630. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4631. /** Equirectangular Fixed Mirrored coordinates mode */
  4632. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4633. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4634. static readonly SCALEMODE_FLOOR: number;
  4635. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4636. static readonly SCALEMODE_NEAREST: number;
  4637. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4638. static readonly SCALEMODE_CEILING: number;
  4639. /**
  4640. * The dirty texture flag value
  4641. */
  4642. static readonly MATERIAL_TextureDirtyFlag: number;
  4643. /**
  4644. * The dirty light flag value
  4645. */
  4646. static readonly MATERIAL_LightDirtyFlag: number;
  4647. /**
  4648. * The dirty fresnel flag value
  4649. */
  4650. static readonly MATERIAL_FresnelDirtyFlag: number;
  4651. /**
  4652. * The dirty attribute flag value
  4653. */
  4654. static readonly MATERIAL_AttributesDirtyFlag: number;
  4655. /**
  4656. * The dirty misc flag value
  4657. */
  4658. static readonly MATERIAL_MiscDirtyFlag: number;
  4659. /**
  4660. * The all dirty flag value
  4661. */
  4662. static readonly MATERIAL_AllDirtyFlag: number;
  4663. /**
  4664. * Returns the triangle fill mode
  4665. */
  4666. static readonly MATERIAL_TriangleFillMode: number;
  4667. /**
  4668. * Returns the wireframe mode
  4669. */
  4670. static readonly MATERIAL_WireFrameFillMode: number;
  4671. /**
  4672. * Returns the point fill mode
  4673. */
  4674. static readonly MATERIAL_PointFillMode: number;
  4675. /**
  4676. * Returns the point list draw mode
  4677. */
  4678. static readonly MATERIAL_PointListDrawMode: number;
  4679. /**
  4680. * Returns the line list draw mode
  4681. */
  4682. static readonly MATERIAL_LineListDrawMode: number;
  4683. /**
  4684. * Returns the line loop draw mode
  4685. */
  4686. static readonly MATERIAL_LineLoopDrawMode: number;
  4687. /**
  4688. * Returns the line strip draw mode
  4689. */
  4690. static readonly MATERIAL_LineStripDrawMode: number;
  4691. /**
  4692. * Returns the triangle strip draw mode
  4693. */
  4694. static readonly MATERIAL_TriangleStripDrawMode: number;
  4695. /**
  4696. * Returns the triangle fan draw mode
  4697. */
  4698. static readonly MATERIAL_TriangleFanDrawMode: number;
  4699. /**
  4700. * Stores the clock-wise side orientation
  4701. */
  4702. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4703. /**
  4704. * Stores the counter clock-wise side orientation
  4705. */
  4706. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4707. /**
  4708. * Nothing
  4709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4710. */
  4711. static readonly ACTION_NothingTrigger: number;
  4712. /**
  4713. * On pick
  4714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4715. */
  4716. static readonly ACTION_OnPickTrigger: number;
  4717. /**
  4718. * On left pick
  4719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4720. */
  4721. static readonly ACTION_OnLeftPickTrigger: number;
  4722. /**
  4723. * On right pick
  4724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4725. */
  4726. static readonly ACTION_OnRightPickTrigger: number;
  4727. /**
  4728. * On center pick
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_OnCenterPickTrigger: number;
  4732. /**
  4733. * On pick down
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickDownTrigger: number;
  4737. /**
  4738. * On double pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnDoublePickTrigger: number;
  4742. /**
  4743. * On pick up
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickUpTrigger: number;
  4747. /**
  4748. * On pick out.
  4749. * This trigger will only be raised if you also declared a OnPickDown
  4750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4751. */
  4752. static readonly ACTION_OnPickOutTrigger: number;
  4753. /**
  4754. * On long press
  4755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4756. */
  4757. static readonly ACTION_OnLongPressTrigger: number;
  4758. /**
  4759. * On pointer over
  4760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4761. */
  4762. static readonly ACTION_OnPointerOverTrigger: number;
  4763. /**
  4764. * On pointer out
  4765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4766. */
  4767. static readonly ACTION_OnPointerOutTrigger: number;
  4768. /**
  4769. * On every frame
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnEveryFrameTrigger: number;
  4773. /**
  4774. * On intersection enter
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4778. /**
  4779. * On intersection exit
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnIntersectionExitTrigger: number;
  4783. /**
  4784. * On key down
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnKeyDownTrigger: number;
  4788. /**
  4789. * On key up
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnKeyUpTrigger: number;
  4793. /**
  4794. * Billboard mode will only apply to Y axis
  4795. */
  4796. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4797. /**
  4798. * Billboard mode will apply to all axes
  4799. */
  4800. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4801. /**
  4802. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4803. */
  4804. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4805. /**
  4806. * Gets or sets base Assets URL
  4807. */
  4808. static readonly PARTICLES_BaseAssetsUrl: string;
  4809. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4810. * Test order :
  4811. * Is the bounding sphere outside the frustum ?
  4812. * If not, are the bounding box vertices outside the frustum ?
  4813. * It not, then the cullable object is in the frustum.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4816. /** Culling strategy : Bounding Sphere Only.
  4817. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4818. * It's also less accurate than the standard because some not visible objects can still be selected.
  4819. * Test : is the bounding sphere outside the frustum ?
  4820. * If not, then the cullable object is in the frustum.
  4821. */
  4822. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4823. /** Culling strategy : Optimistic Inclusion.
  4824. * This in an inclusion test first, then the standard exclusion test.
  4825. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4826. * 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.
  4827. * Anyway, it's as accurate as the standard strategy.
  4828. * Test :
  4829. * Is the cullable object bounding sphere center in the frustum ?
  4830. * If not, apply the default culling strategy.
  4831. */
  4832. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4833. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4834. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4835. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4836. * 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.
  4837. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4838. * Test :
  4839. * Is the cullable object bounding sphere center in the frustum ?
  4840. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4843. /**
  4844. * No logging while loading
  4845. */
  4846. static readonly SCENELOADER_NO_LOGGING: number;
  4847. /**
  4848. * Minimal logging while loading
  4849. */
  4850. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4851. /**
  4852. * Summary logging while loading
  4853. */
  4854. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4855. /**
  4856. * Detailled logging while loading
  4857. */
  4858. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4859. }
  4860. }
  4861. declare module "babylonjs/Misc/domManagement" {
  4862. /**
  4863. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4864. * Babylon.js
  4865. */
  4866. export class DomManagement {
  4867. /**
  4868. * Checks if the window object exists
  4869. * @returns true if the window object exists
  4870. */
  4871. static IsWindowObjectExist(): boolean;
  4872. /**
  4873. * Extracts text content from a DOM element hierarchy
  4874. * @param element defines the root element
  4875. * @returns a string
  4876. */
  4877. static GetDOMTextContent(element: HTMLElement): string;
  4878. }
  4879. }
  4880. declare module "babylonjs/Misc/logger" {
  4881. /**
  4882. * Logger used througouht the application to allow configuration of
  4883. * the log level required for the messages.
  4884. */
  4885. export class Logger {
  4886. /**
  4887. * No log
  4888. */
  4889. static readonly NoneLogLevel: number;
  4890. /**
  4891. * Only message logs
  4892. */
  4893. static readonly MessageLogLevel: number;
  4894. /**
  4895. * Only warning logs
  4896. */
  4897. static readonly WarningLogLevel: number;
  4898. /**
  4899. * Only error logs
  4900. */
  4901. static readonly ErrorLogLevel: number;
  4902. /**
  4903. * All logs
  4904. */
  4905. static readonly AllLogLevel: number;
  4906. private static _LogCache;
  4907. /**
  4908. * Gets a value indicating the number of loading errors
  4909. * @ignorenaming
  4910. */
  4911. static errorsCount: number;
  4912. /**
  4913. * Callback called when a new log is added
  4914. */
  4915. static OnNewCacheEntry: (entry: string) => void;
  4916. private static _AddLogEntry;
  4917. private static _FormatMessage;
  4918. private static _LogDisabled;
  4919. private static _LogEnabled;
  4920. private static _WarnDisabled;
  4921. private static _WarnEnabled;
  4922. private static _ErrorDisabled;
  4923. private static _ErrorEnabled;
  4924. /**
  4925. * Log a message to the console
  4926. */
  4927. static Log: (message: string) => void;
  4928. /**
  4929. * Write a warning message to the console
  4930. */
  4931. static Warn: (message: string) => void;
  4932. /**
  4933. * Write an error message to the console
  4934. */
  4935. static Error: (message: string) => void;
  4936. /**
  4937. * Gets current log cache (list of logs)
  4938. */
  4939. static readonly LogCache: string;
  4940. /**
  4941. * Clears the log cache
  4942. */
  4943. static ClearLogCache(): void;
  4944. /**
  4945. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4946. */
  4947. static LogLevels: number;
  4948. }
  4949. }
  4950. declare module "babylonjs/Misc/typeStore" {
  4951. /** @hidden */
  4952. export class _TypeStore {
  4953. /** @hidden */
  4954. static RegisteredTypes: {
  4955. [key: string]: Object;
  4956. };
  4957. /** @hidden */
  4958. static GetClass(fqdn: string): any;
  4959. }
  4960. }
  4961. declare module "babylonjs/Misc/deepCopier" {
  4962. /**
  4963. * Class containing a set of static utilities functions for deep copy.
  4964. */
  4965. export class DeepCopier {
  4966. /**
  4967. * Tries to copy an object by duplicating every property
  4968. * @param source defines the source object
  4969. * @param destination defines the target object
  4970. * @param doNotCopyList defines a list of properties to avoid
  4971. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4972. */
  4973. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/precisionDate" {
  4977. /**
  4978. * Class containing a set of static utilities functions for precision date
  4979. */
  4980. export class PrecisionDate {
  4981. /**
  4982. * Gets either window.performance.now() if supported or Date.now() else
  4983. */
  4984. static readonly Now: number;
  4985. }
  4986. }
  4987. declare module "babylonjs/Misc/devTools" {
  4988. /** @hidden */
  4989. export class _DevTools {
  4990. static WarnImport(name: string): string;
  4991. }
  4992. }
  4993. declare module "babylonjs/Misc/webRequest" {
  4994. /**
  4995. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4996. */
  4997. export class WebRequest {
  4998. private _xhr;
  4999. /**
  5000. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5001. * i.e. when loading files, where the server/service expects an Authorization header
  5002. */
  5003. static CustomRequestHeaders: {
  5004. [key: string]: string;
  5005. };
  5006. /**
  5007. * Add callback functions in this array to update all the requests before they get sent to the network
  5008. */
  5009. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5010. private _injectCustomRequestHeaders;
  5011. /**
  5012. * Gets or sets a function to be called when loading progress changes
  5013. */
  5014. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5015. /**
  5016. * Returns client's state
  5017. */
  5018. readonly readyState: number;
  5019. /**
  5020. * Returns client's status
  5021. */
  5022. readonly status: number;
  5023. /**
  5024. * Returns client's status as a text
  5025. */
  5026. readonly statusText: string;
  5027. /**
  5028. * Returns client's response
  5029. */
  5030. readonly response: any;
  5031. /**
  5032. * Returns client's response url
  5033. */
  5034. readonly responseURL: string;
  5035. /**
  5036. * Returns client's response as text
  5037. */
  5038. readonly responseText: string;
  5039. /**
  5040. * Gets or sets the expected response type
  5041. */
  5042. responseType: XMLHttpRequestResponseType;
  5043. /** @hidden */
  5044. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5045. /** @hidden */
  5046. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5047. /**
  5048. * Cancels any network activity
  5049. */
  5050. abort(): void;
  5051. /**
  5052. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5053. * @param body defines an optional request body
  5054. */
  5055. send(body?: Document | BodyInit | null): void;
  5056. /**
  5057. * Sets the request method, request URL
  5058. * @param method defines the method to use (GET, POST, etc..)
  5059. * @param url defines the url to connect with
  5060. */
  5061. open(method: string, url: string): void;
  5062. }
  5063. }
  5064. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5065. /**
  5066. * Class used to evalaute queries containing `and` and `or` operators
  5067. */
  5068. export class AndOrNotEvaluator {
  5069. /**
  5070. * Evaluate a query
  5071. * @param query defines the query to evaluate
  5072. * @param evaluateCallback defines the callback used to filter result
  5073. * @returns true if the query matches
  5074. */
  5075. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5076. private static _HandleParenthesisContent;
  5077. private static _SimplifyNegation;
  5078. }
  5079. }
  5080. declare module "babylonjs/Misc/tags" {
  5081. /**
  5082. * Class used to store custom tags
  5083. */
  5084. export class Tags {
  5085. /**
  5086. * Adds support for tags on the given object
  5087. * @param obj defines the object to use
  5088. */
  5089. static EnableFor(obj: any): void;
  5090. /**
  5091. * Removes tags support
  5092. * @param obj defines the object to use
  5093. */
  5094. static DisableFor(obj: any): void;
  5095. /**
  5096. * Gets a boolean indicating if the given object has tags
  5097. * @param obj defines the object to use
  5098. * @returns a boolean
  5099. */
  5100. static HasTags(obj: any): boolean;
  5101. /**
  5102. * Gets the tags available on a given object
  5103. * @param obj defines the object to use
  5104. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5105. * @returns the tags
  5106. */
  5107. static GetTags(obj: any, asString?: boolean): any;
  5108. /**
  5109. * Adds tags to an object
  5110. * @param obj defines the object to use
  5111. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5112. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5113. */
  5114. static AddTagsTo(obj: any, tagsString: string): void;
  5115. /**
  5116. * @hidden
  5117. */
  5118. static _AddTagTo(obj: any, tag: string): void;
  5119. /**
  5120. * Removes specific tags from a specific object
  5121. * @param obj defines the object to use
  5122. * @param tagsString defines the tags to remove
  5123. */
  5124. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5125. /**
  5126. * @hidden
  5127. */
  5128. static _RemoveTagFrom(obj: any, tag: string): void;
  5129. /**
  5130. * Defines if tags hosted on an object match a given query
  5131. * @param obj defines the object to use
  5132. * @param tagsQuery defines the tag query
  5133. * @returns a boolean
  5134. */
  5135. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5136. }
  5137. }
  5138. declare module "babylonjs/Materials/materialDefines" {
  5139. /**
  5140. * Manages the defines for the Material
  5141. */
  5142. export class MaterialDefines {
  5143. private _keys;
  5144. private _isDirty;
  5145. /** @hidden */
  5146. _renderId: number;
  5147. /** @hidden */
  5148. _areLightsDirty: boolean;
  5149. /** @hidden */
  5150. _areAttributesDirty: boolean;
  5151. /** @hidden */
  5152. _areTexturesDirty: boolean;
  5153. /** @hidden */
  5154. _areFresnelDirty: boolean;
  5155. /** @hidden */
  5156. _areMiscDirty: boolean;
  5157. /** @hidden */
  5158. _areImageProcessingDirty: boolean;
  5159. /** @hidden */
  5160. _normals: boolean;
  5161. /** @hidden */
  5162. _uvs: boolean;
  5163. /** @hidden */
  5164. _needNormals: boolean;
  5165. /** @hidden */
  5166. _needUVs: boolean;
  5167. /**
  5168. * Specifies if the material needs to be re-calculated
  5169. */
  5170. readonly isDirty: boolean;
  5171. /**
  5172. * Marks the material to indicate that it has been re-calculated
  5173. */
  5174. markAsProcessed(): void;
  5175. /**
  5176. * Marks the material to indicate that it needs to be re-calculated
  5177. */
  5178. markAsUnprocessed(): void;
  5179. /**
  5180. * Marks the material to indicate all of its defines need to be re-calculated
  5181. */
  5182. markAllAsDirty(): void;
  5183. /**
  5184. * Marks the material to indicate that image processing needs to be re-calculated
  5185. */
  5186. markAsImageProcessingDirty(): void;
  5187. /**
  5188. * Marks the material to indicate the lights need to be re-calculated
  5189. */
  5190. markAsLightDirty(): void;
  5191. /**
  5192. * Marks the attribute state as changed
  5193. */
  5194. markAsAttributesDirty(): void;
  5195. /**
  5196. * Marks the texture state as changed
  5197. */
  5198. markAsTexturesDirty(): void;
  5199. /**
  5200. * Marks the fresnel state as changed
  5201. */
  5202. markAsFresnelDirty(): void;
  5203. /**
  5204. * Marks the misc state as changed
  5205. */
  5206. markAsMiscDirty(): void;
  5207. /**
  5208. * Rebuilds the material defines
  5209. */
  5210. rebuild(): void;
  5211. /**
  5212. * Specifies if two material defines are equal
  5213. * @param other - A material define instance to compare to
  5214. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5215. */
  5216. isEqual(other: MaterialDefines): boolean;
  5217. /**
  5218. * Clones this instance's defines to another instance
  5219. * @param other - material defines to clone values to
  5220. */
  5221. cloneTo(other: MaterialDefines): void;
  5222. /**
  5223. * Resets the material define values
  5224. */
  5225. reset(): void;
  5226. /**
  5227. * Converts the material define values to a string
  5228. * @returns - String of material define information
  5229. */
  5230. toString(): string;
  5231. }
  5232. }
  5233. declare module "babylonjs/Engines/IPipelineContext" {
  5234. /**
  5235. * Class used to store and describe the pipeline context associated with an effect
  5236. */
  5237. export interface IPipelineContext {
  5238. /**
  5239. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5240. */
  5241. isAsync: boolean;
  5242. /**
  5243. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5244. */
  5245. isReady: boolean;
  5246. /** @hidden */
  5247. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5248. }
  5249. }
  5250. declare module "babylonjs/Meshes/dataBuffer" {
  5251. /**
  5252. * Class used to store gfx data (like WebGLBuffer)
  5253. */
  5254. export class DataBuffer {
  5255. /**
  5256. * Gets or sets the number of objects referencing this buffer
  5257. */
  5258. references: number;
  5259. /** Gets or sets the size of the underlying buffer */
  5260. capacity: number;
  5261. /**
  5262. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5263. */
  5264. is32Bits: boolean;
  5265. /**
  5266. * Gets the underlying buffer
  5267. */
  5268. readonly underlyingResource: any;
  5269. }
  5270. }
  5271. declare module "babylonjs/Misc/performanceMonitor" {
  5272. /**
  5273. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5274. */
  5275. export class PerformanceMonitor {
  5276. private _enabled;
  5277. private _rollingFrameTime;
  5278. private _lastFrameTimeMs;
  5279. /**
  5280. * constructor
  5281. * @param frameSampleSize The number of samples required to saturate the sliding window
  5282. */
  5283. constructor(frameSampleSize?: number);
  5284. /**
  5285. * Samples current frame
  5286. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5287. */
  5288. sampleFrame(timeMs?: number): void;
  5289. /**
  5290. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5291. */
  5292. readonly averageFrameTime: number;
  5293. /**
  5294. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5295. */
  5296. readonly averageFrameTimeVariance: number;
  5297. /**
  5298. * Returns the frame time of the most recent frame
  5299. */
  5300. readonly instantaneousFrameTime: number;
  5301. /**
  5302. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5303. */
  5304. readonly averageFPS: number;
  5305. /**
  5306. * Returns the average framerate in frames per second using the most recent frame time
  5307. */
  5308. readonly instantaneousFPS: number;
  5309. /**
  5310. * Returns true if enough samples have been taken to completely fill the sliding window
  5311. */
  5312. readonly isSaturated: boolean;
  5313. /**
  5314. * Enables contributions to the sliding window sample set
  5315. */
  5316. enable(): void;
  5317. /**
  5318. * Disables contributions to the sliding window sample set
  5319. * Samples will not be interpolated over the disabled period
  5320. */
  5321. disable(): void;
  5322. /**
  5323. * Returns true if sampling is enabled
  5324. */
  5325. readonly isEnabled: boolean;
  5326. /**
  5327. * Resets performance monitor
  5328. */
  5329. reset(): void;
  5330. }
  5331. /**
  5332. * RollingAverage
  5333. *
  5334. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5335. */
  5336. export class RollingAverage {
  5337. /**
  5338. * Current average
  5339. */
  5340. average: number;
  5341. /**
  5342. * Current variance
  5343. */
  5344. variance: number;
  5345. protected _samples: Array<number>;
  5346. protected _sampleCount: number;
  5347. protected _pos: number;
  5348. protected _m2: number;
  5349. /**
  5350. * constructor
  5351. * @param length The number of samples required to saturate the sliding window
  5352. */
  5353. constructor(length: number);
  5354. /**
  5355. * Adds a sample to the sample set
  5356. * @param v The sample value
  5357. */
  5358. add(v: number): void;
  5359. /**
  5360. * Returns previously added values or null if outside of history or outside the sliding window domain
  5361. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5362. * @return Value previously recorded with add() or null if outside of range
  5363. */
  5364. history(i: number): number;
  5365. /**
  5366. * Returns true if enough samples have been taken to completely fill the sliding window
  5367. * @return true if sample-set saturated
  5368. */
  5369. isSaturated(): boolean;
  5370. /**
  5371. * Resets the rolling average (equivalent to 0 samples taken so far)
  5372. */
  5373. reset(): void;
  5374. /**
  5375. * Wraps a value around the sample range boundaries
  5376. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5377. * @return Wrapped position in sample range
  5378. */
  5379. protected _wrapPosition(i: number): number;
  5380. }
  5381. }
  5382. declare module "babylonjs/Misc/stringDictionary" {
  5383. import { Nullable } from "babylonjs/types";
  5384. /**
  5385. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5386. * The underlying implementation relies on an associative array to ensure the best performances.
  5387. * The value can be anything including 'null' but except 'undefined'
  5388. */
  5389. export class StringDictionary<T> {
  5390. /**
  5391. * This will clear this dictionary and copy the content from the 'source' one.
  5392. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5393. * @param source the dictionary to take the content from and copy to this dictionary
  5394. */
  5395. copyFrom(source: StringDictionary<T>): void;
  5396. /**
  5397. * Get a value based from its key
  5398. * @param key the given key to get the matching value from
  5399. * @return the value if found, otherwise undefined is returned
  5400. */
  5401. get(key: string): T | undefined;
  5402. /**
  5403. * Get a value from its key or add it if it doesn't exist.
  5404. * This method will ensure you that a given key/data will be present in the dictionary.
  5405. * @param key the given key to get the matching value from
  5406. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5407. * The factory will only be invoked if there's no data for the given key.
  5408. * @return the value corresponding to the key.
  5409. */
  5410. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5411. /**
  5412. * Get a value from its key if present in the dictionary otherwise add it
  5413. * @param key the key to get the value from
  5414. * @param val if there's no such key/value pair in the dictionary add it with this value
  5415. * @return the value corresponding to the key
  5416. */
  5417. getOrAdd(key: string, val: T): T;
  5418. /**
  5419. * Check if there's a given key in the dictionary
  5420. * @param key the key to check for
  5421. * @return true if the key is present, false otherwise
  5422. */
  5423. contains(key: string): boolean;
  5424. /**
  5425. * Add a new key and its corresponding value
  5426. * @param key the key to add
  5427. * @param value the value corresponding to the key
  5428. * @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
  5429. */
  5430. add(key: string, value: T): boolean;
  5431. /**
  5432. * Update a specific value associated to a key
  5433. * @param key defines the key to use
  5434. * @param value defines the value to store
  5435. * @returns true if the value was updated (or false if the key was not found)
  5436. */
  5437. set(key: string, value: T): boolean;
  5438. /**
  5439. * Get the element of the given key and remove it from the dictionary
  5440. * @param key defines the key to search
  5441. * @returns the value associated with the key or null if not found
  5442. */
  5443. getAndRemove(key: string): Nullable<T>;
  5444. /**
  5445. * Remove a key/value from the dictionary.
  5446. * @param key the key to remove
  5447. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5448. */
  5449. remove(key: string): boolean;
  5450. /**
  5451. * Clear the whole content of the dictionary
  5452. */
  5453. clear(): void;
  5454. /**
  5455. * Gets the current count
  5456. */
  5457. readonly count: number;
  5458. /**
  5459. * Execute a callback on each key/val of the dictionary.
  5460. * Note that you can remove any element in this dictionary in the callback implementation
  5461. * @param callback the callback to execute on a given key/value pair
  5462. */
  5463. forEach(callback: (key: string, val: T) => void): void;
  5464. /**
  5465. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5466. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5467. * Note that you can remove any element in this dictionary in the callback implementation
  5468. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5469. * @returns the first item
  5470. */
  5471. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5472. private _count;
  5473. private _data;
  5474. }
  5475. }
  5476. declare module "babylonjs/Misc/promise" {
  5477. /**
  5478. * Helper class that provides a small promise polyfill
  5479. */
  5480. export class PromisePolyfill {
  5481. /**
  5482. * Static function used to check if the polyfill is required
  5483. * If this is the case then the function will inject the polyfill to window.Promise
  5484. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5485. */
  5486. static Apply(force?: boolean): void;
  5487. }
  5488. }
  5489. declare module "babylonjs/Meshes/buffer" {
  5490. import { Nullable, DataArray } from "babylonjs/types";
  5491. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5492. /**
  5493. * Class used to store data that will be store in GPU memory
  5494. */
  5495. export class Buffer {
  5496. private _engine;
  5497. private _buffer;
  5498. /** @hidden */
  5499. _data: Nullable<DataArray>;
  5500. private _updatable;
  5501. private _instanced;
  5502. /**
  5503. * Gets the byte stride.
  5504. */
  5505. readonly byteStride: number;
  5506. /**
  5507. * Constructor
  5508. * @param engine the engine
  5509. * @param data the data to use for this buffer
  5510. * @param updatable whether the data is updatable
  5511. * @param stride the stride (optional)
  5512. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5513. * @param instanced whether the buffer is instanced (optional)
  5514. * @param useBytes set to true if the stride in in bytes (optional)
  5515. */
  5516. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5517. /**
  5518. * Create a new VertexBuffer based on the current buffer
  5519. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5520. * @param offset defines offset in the buffer (0 by default)
  5521. * @param size defines the size in floats of attributes (position is 3 for instance)
  5522. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5523. * @param instanced defines if the vertex buffer contains indexed data
  5524. * @param useBytes defines if the offset and stride are in bytes
  5525. * @returns the new vertex buffer
  5526. */
  5527. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5528. /**
  5529. * Gets a boolean indicating if the Buffer is updatable?
  5530. * @returns true if the buffer is updatable
  5531. */
  5532. isUpdatable(): boolean;
  5533. /**
  5534. * Gets current buffer's data
  5535. * @returns a DataArray or null
  5536. */
  5537. getData(): Nullable<DataArray>;
  5538. /**
  5539. * Gets underlying native buffer
  5540. * @returns underlying native buffer
  5541. */
  5542. getBuffer(): Nullable<DataBuffer>;
  5543. /**
  5544. * Gets the stride in float32 units (i.e. byte stride / 4).
  5545. * May not be an integer if the byte stride is not divisible by 4.
  5546. * DEPRECATED. Use byteStride instead.
  5547. * @returns the stride in float32 units
  5548. */
  5549. getStrideSize(): number;
  5550. /**
  5551. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5552. * @param data defines the data to store
  5553. */
  5554. create(data?: Nullable<DataArray>): void;
  5555. /** @hidden */
  5556. _rebuild(): void;
  5557. /**
  5558. * Update current buffer data
  5559. * @param data defines the data to store
  5560. */
  5561. update(data: DataArray): void;
  5562. /**
  5563. * Updates the data directly.
  5564. * @param data the new data
  5565. * @param offset the new offset
  5566. * @param vertexCount the vertex count (optional)
  5567. * @param useBytes set to true if the offset is in bytes
  5568. */
  5569. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5570. /**
  5571. * Release all resources
  5572. */
  5573. dispose(): void;
  5574. }
  5575. /**
  5576. * Specialized buffer used to store vertex data
  5577. */
  5578. export class VertexBuffer {
  5579. /** @hidden */
  5580. _buffer: Buffer;
  5581. private _kind;
  5582. private _size;
  5583. private _ownsBuffer;
  5584. private _instanced;
  5585. private _instanceDivisor;
  5586. /**
  5587. * The byte type.
  5588. */
  5589. static readonly BYTE: number;
  5590. /**
  5591. * The unsigned byte type.
  5592. */
  5593. static readonly UNSIGNED_BYTE: number;
  5594. /**
  5595. * The short type.
  5596. */
  5597. static readonly SHORT: number;
  5598. /**
  5599. * The unsigned short type.
  5600. */
  5601. static readonly UNSIGNED_SHORT: number;
  5602. /**
  5603. * The integer type.
  5604. */
  5605. static readonly INT: number;
  5606. /**
  5607. * The unsigned integer type.
  5608. */
  5609. static readonly UNSIGNED_INT: number;
  5610. /**
  5611. * The float type.
  5612. */
  5613. static readonly FLOAT: number;
  5614. /**
  5615. * Gets or sets the instance divisor when in instanced mode
  5616. */
  5617. instanceDivisor: number;
  5618. /**
  5619. * Gets the byte stride.
  5620. */
  5621. readonly byteStride: number;
  5622. /**
  5623. * Gets the byte offset.
  5624. */
  5625. readonly byteOffset: number;
  5626. /**
  5627. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5628. */
  5629. readonly normalized: boolean;
  5630. /**
  5631. * Gets the data type of each component in the array.
  5632. */
  5633. readonly type: number;
  5634. /**
  5635. * Constructor
  5636. * @param engine the engine
  5637. * @param data the data to use for this vertex buffer
  5638. * @param kind the vertex buffer kind
  5639. * @param updatable whether the data is updatable
  5640. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5641. * @param stride the stride (optional)
  5642. * @param instanced whether the buffer is instanced (optional)
  5643. * @param offset the offset of the data (optional)
  5644. * @param size the number of components (optional)
  5645. * @param type the type of the component (optional)
  5646. * @param normalized whether the data contains normalized data (optional)
  5647. * @param useBytes set to true if stride and offset are in bytes (optional)
  5648. */
  5649. 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);
  5650. /** @hidden */
  5651. _rebuild(): void;
  5652. /**
  5653. * Returns the kind of the VertexBuffer (string)
  5654. * @returns a string
  5655. */
  5656. getKind(): string;
  5657. /**
  5658. * Gets a boolean indicating if the VertexBuffer is updatable?
  5659. * @returns true if the buffer is updatable
  5660. */
  5661. isUpdatable(): boolean;
  5662. /**
  5663. * Gets current buffer's data
  5664. * @returns a DataArray or null
  5665. */
  5666. getData(): Nullable<DataArray>;
  5667. /**
  5668. * Gets underlying native buffer
  5669. * @returns underlying native buffer
  5670. */
  5671. getBuffer(): Nullable<DataBuffer>;
  5672. /**
  5673. * Gets the stride in float32 units (i.e. byte stride / 4).
  5674. * May not be an integer if the byte stride is not divisible by 4.
  5675. * DEPRECATED. Use byteStride instead.
  5676. * @returns the stride in float32 units
  5677. */
  5678. getStrideSize(): number;
  5679. /**
  5680. * Returns the offset as a multiple of the type byte length.
  5681. * DEPRECATED. Use byteOffset instead.
  5682. * @returns the offset in bytes
  5683. */
  5684. getOffset(): number;
  5685. /**
  5686. * Returns the number of components per vertex attribute (integer)
  5687. * @returns the size in float
  5688. */
  5689. getSize(): number;
  5690. /**
  5691. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5692. * @returns true if this buffer is instanced
  5693. */
  5694. getIsInstanced(): boolean;
  5695. /**
  5696. * Returns the instancing divisor, zero for non-instanced (integer).
  5697. * @returns a number
  5698. */
  5699. getInstanceDivisor(): number;
  5700. /**
  5701. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5702. * @param data defines the data to store
  5703. */
  5704. create(data?: DataArray): void;
  5705. /**
  5706. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5707. * This function will create a new buffer if the current one is not updatable
  5708. * @param data defines the data to store
  5709. */
  5710. update(data: DataArray): void;
  5711. /**
  5712. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5713. * Returns the directly updated WebGLBuffer.
  5714. * @param data the new data
  5715. * @param offset the new offset
  5716. * @param useBytes set to true if the offset is in bytes
  5717. */
  5718. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5719. /**
  5720. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5721. */
  5722. dispose(): void;
  5723. /**
  5724. * Enumerates each value of this vertex buffer as numbers.
  5725. * @param count the number of values to enumerate
  5726. * @param callback the callback function called for each value
  5727. */
  5728. forEach(count: number, callback: (value: number, index: number) => void): void;
  5729. /**
  5730. * Positions
  5731. */
  5732. static readonly PositionKind: string;
  5733. /**
  5734. * Normals
  5735. */
  5736. static readonly NormalKind: string;
  5737. /**
  5738. * Tangents
  5739. */
  5740. static readonly TangentKind: string;
  5741. /**
  5742. * Texture coordinates
  5743. */
  5744. static readonly UVKind: string;
  5745. /**
  5746. * Texture coordinates 2
  5747. */
  5748. static readonly UV2Kind: string;
  5749. /**
  5750. * Texture coordinates 3
  5751. */
  5752. static readonly UV3Kind: string;
  5753. /**
  5754. * Texture coordinates 4
  5755. */
  5756. static readonly UV4Kind: string;
  5757. /**
  5758. * Texture coordinates 5
  5759. */
  5760. static readonly UV5Kind: string;
  5761. /**
  5762. * Texture coordinates 6
  5763. */
  5764. static readonly UV6Kind: string;
  5765. /**
  5766. * Colors
  5767. */
  5768. static readonly ColorKind: string;
  5769. /**
  5770. * Matrix indices (for bones)
  5771. */
  5772. static readonly MatricesIndicesKind: string;
  5773. /**
  5774. * Matrix weights (for bones)
  5775. */
  5776. static readonly MatricesWeightsKind: string;
  5777. /**
  5778. * Additional matrix indices (for bones)
  5779. */
  5780. static readonly MatricesIndicesExtraKind: string;
  5781. /**
  5782. * Additional matrix weights (for bones)
  5783. */
  5784. static readonly MatricesWeightsExtraKind: string;
  5785. /**
  5786. * Deduces the stride given a kind.
  5787. * @param kind The kind string to deduce
  5788. * @returns The deduced stride
  5789. */
  5790. static DeduceStride(kind: string): number;
  5791. /**
  5792. * Gets the byte length of the given type.
  5793. * @param type the type
  5794. * @returns the number of bytes
  5795. */
  5796. static GetTypeByteLength(type: number): number;
  5797. /**
  5798. * Enumerates each value of the given parameters as numbers.
  5799. * @param data the data to enumerate
  5800. * @param byteOffset the byte offset of the data
  5801. * @param byteStride the byte stride of the data
  5802. * @param componentCount the number of components per element
  5803. * @param componentType the type of the component
  5804. * @param count the total number of components
  5805. * @param normalized whether the data is normalized
  5806. * @param callback the callback function called for each value
  5807. */
  5808. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5809. private static _GetFloatValue;
  5810. }
  5811. }
  5812. declare module "babylonjs/Maths/sphericalPolynomial" {
  5813. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5814. /**
  5815. * Class representing spherical harmonics coefficients to the 3rd degree
  5816. */
  5817. export class SphericalHarmonics {
  5818. /**
  5819. * Defines whether or not the harmonics have been prescaled for rendering.
  5820. */
  5821. preScaled: boolean;
  5822. /**
  5823. * The l0,0 coefficients of the spherical harmonics
  5824. */
  5825. l00: Vector3;
  5826. /**
  5827. * The l1,-1 coefficients of the spherical harmonics
  5828. */
  5829. l1_1: Vector3;
  5830. /**
  5831. * The l1,0 coefficients of the spherical harmonics
  5832. */
  5833. l10: Vector3;
  5834. /**
  5835. * The l1,1 coefficients of the spherical harmonics
  5836. */
  5837. l11: Vector3;
  5838. /**
  5839. * The l2,-2 coefficients of the spherical harmonics
  5840. */
  5841. l2_2: Vector3;
  5842. /**
  5843. * The l2,-1 coefficients of the spherical harmonics
  5844. */
  5845. l2_1: Vector3;
  5846. /**
  5847. * The l2,0 coefficients of the spherical harmonics
  5848. */
  5849. l20: Vector3;
  5850. /**
  5851. * The l2,1 coefficients of the spherical harmonics
  5852. */
  5853. l21: Vector3;
  5854. /**
  5855. * The l2,2 coefficients of the spherical harmonics
  5856. */
  5857. l22: Vector3;
  5858. /**
  5859. * Adds a light to the spherical harmonics
  5860. * @param direction the direction of the light
  5861. * @param color the color of the light
  5862. * @param deltaSolidAngle the delta solid angle of the light
  5863. */
  5864. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5865. /**
  5866. * Scales the spherical harmonics by the given amount
  5867. * @param scale the amount to scale
  5868. */
  5869. scaleInPlace(scale: number): void;
  5870. /**
  5871. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5872. *
  5873. * ```
  5874. * E_lm = A_l * L_lm
  5875. * ```
  5876. *
  5877. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5878. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5879. * the scaling factors are given in equation 9.
  5880. */
  5881. convertIncidentRadianceToIrradiance(): void;
  5882. /**
  5883. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5884. *
  5885. * ```
  5886. * L = (1/pi) * E * rho
  5887. * ```
  5888. *
  5889. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5890. */
  5891. convertIrradianceToLambertianRadiance(): void;
  5892. /**
  5893. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5894. * required operations at run time.
  5895. *
  5896. * This is simply done by scaling back the SH with Ylm constants parameter.
  5897. * The trigonometric part being applied by the shader at run time.
  5898. */
  5899. preScaleForRendering(): void;
  5900. /**
  5901. * Constructs a spherical harmonics from an array.
  5902. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5903. * @returns the spherical harmonics
  5904. */
  5905. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5906. /**
  5907. * Gets the spherical harmonics from polynomial
  5908. * @param polynomial the spherical polynomial
  5909. * @returns the spherical harmonics
  5910. */
  5911. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5912. }
  5913. /**
  5914. * Class representing spherical polynomial coefficients to the 3rd degree
  5915. */
  5916. export class SphericalPolynomial {
  5917. private _harmonics;
  5918. /**
  5919. * The spherical harmonics used to create the polynomials.
  5920. */
  5921. readonly preScaledHarmonics: SphericalHarmonics;
  5922. /**
  5923. * The x coefficients of the spherical polynomial
  5924. */
  5925. x: Vector3;
  5926. /**
  5927. * The y coefficients of the spherical polynomial
  5928. */
  5929. y: Vector3;
  5930. /**
  5931. * The z coefficients of the spherical polynomial
  5932. */
  5933. z: Vector3;
  5934. /**
  5935. * The xx coefficients of the spherical polynomial
  5936. */
  5937. xx: Vector3;
  5938. /**
  5939. * The yy coefficients of the spherical polynomial
  5940. */
  5941. yy: Vector3;
  5942. /**
  5943. * The zz coefficients of the spherical polynomial
  5944. */
  5945. zz: Vector3;
  5946. /**
  5947. * The xy coefficients of the spherical polynomial
  5948. */
  5949. xy: Vector3;
  5950. /**
  5951. * The yz coefficients of the spherical polynomial
  5952. */
  5953. yz: Vector3;
  5954. /**
  5955. * The zx coefficients of the spherical polynomial
  5956. */
  5957. zx: Vector3;
  5958. /**
  5959. * Adds an ambient color to the spherical polynomial
  5960. * @param color the color to add
  5961. */
  5962. addAmbient(color: Color3): void;
  5963. /**
  5964. * Scales the spherical polynomial by the given amount
  5965. * @param scale the amount to scale
  5966. */
  5967. scaleInPlace(scale: number): void;
  5968. /**
  5969. * Gets the spherical polynomial from harmonics
  5970. * @param harmonics the spherical harmonics
  5971. * @returns the spherical polynomial
  5972. */
  5973. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5974. /**
  5975. * Constructs a spherical polynomial from an array.
  5976. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5977. * @returns the spherical polynomial
  5978. */
  5979. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5980. }
  5981. }
  5982. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5983. import { Nullable } from "babylonjs/types";
  5984. /**
  5985. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5986. */
  5987. export interface CubeMapInfo {
  5988. /**
  5989. * The pixel array for the front face.
  5990. * This is stored in format, left to right, up to down format.
  5991. */
  5992. front: Nullable<ArrayBufferView>;
  5993. /**
  5994. * The pixel array for the back face.
  5995. * This is stored in format, left to right, up to down format.
  5996. */
  5997. back: Nullable<ArrayBufferView>;
  5998. /**
  5999. * The pixel array for the left face.
  6000. * This is stored in format, left to right, up to down format.
  6001. */
  6002. left: Nullable<ArrayBufferView>;
  6003. /**
  6004. * The pixel array for the right face.
  6005. * This is stored in format, left to right, up to down format.
  6006. */
  6007. right: Nullable<ArrayBufferView>;
  6008. /**
  6009. * The pixel array for the up face.
  6010. * This is stored in format, left to right, up to down format.
  6011. */
  6012. up: Nullable<ArrayBufferView>;
  6013. /**
  6014. * The pixel array for the down face.
  6015. * This is stored in format, left to right, up to down format.
  6016. */
  6017. down: Nullable<ArrayBufferView>;
  6018. /**
  6019. * The size of the cubemap stored.
  6020. *
  6021. * Each faces will be size * size pixels.
  6022. */
  6023. size: number;
  6024. /**
  6025. * The format of the texture.
  6026. *
  6027. * RGBA, RGB.
  6028. */
  6029. format: number;
  6030. /**
  6031. * The type of the texture data.
  6032. *
  6033. * UNSIGNED_INT, FLOAT.
  6034. */
  6035. type: number;
  6036. /**
  6037. * Specifies whether the texture is in gamma space.
  6038. */
  6039. gammaSpace: boolean;
  6040. }
  6041. /**
  6042. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6043. */
  6044. export class PanoramaToCubeMapTools {
  6045. private static FACE_FRONT;
  6046. private static FACE_BACK;
  6047. private static FACE_RIGHT;
  6048. private static FACE_LEFT;
  6049. private static FACE_DOWN;
  6050. private static FACE_UP;
  6051. /**
  6052. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6053. *
  6054. * @param float32Array The source data.
  6055. * @param inputWidth The width of the input panorama.
  6056. * @param inputHeight The height of the input panorama.
  6057. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6058. * @return The cubemap data
  6059. */
  6060. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6061. private static CreateCubemapTexture;
  6062. private static CalcProjectionSpherical;
  6063. }
  6064. }
  6065. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6066. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6067. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6068. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6069. /**
  6070. * Helper class dealing with the extraction of spherical polynomial dataArray
  6071. * from a cube map.
  6072. */
  6073. export class CubeMapToSphericalPolynomialTools {
  6074. private static FileFaces;
  6075. /**
  6076. * Converts a texture to the according Spherical Polynomial data.
  6077. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6078. *
  6079. * @param texture The texture to extract the information from.
  6080. * @return The Spherical Polynomial data.
  6081. */
  6082. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6083. /**
  6084. * Converts a cubemap to the according Spherical Polynomial data.
  6085. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6086. *
  6087. * @param cubeInfo The Cube map to extract the information from.
  6088. * @return The Spherical Polynomial data.
  6089. */
  6090. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6091. }
  6092. }
  6093. declare module "babylonjs/Engines/engineStore" {
  6094. import { Nullable } from "babylonjs/types";
  6095. import { Engine } from "babylonjs/Engines/engine";
  6096. import { Scene } from "babylonjs/scene";
  6097. /**
  6098. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6099. * during the life time of the application.
  6100. */
  6101. export class EngineStore {
  6102. /** Gets the list of created engines */
  6103. static Instances: import("babylonjs/Engines/engine").Engine[];
  6104. /**
  6105. * Gets the latest created engine
  6106. */
  6107. static readonly LastCreatedEngine: Nullable<Engine>;
  6108. /**
  6109. * Gets the latest created scene
  6110. */
  6111. static readonly LastCreatedScene: Nullable<Scene>;
  6112. }
  6113. }
  6114. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6115. /**
  6116. * Define options used to create a render target texture
  6117. */
  6118. export class RenderTargetCreationOptions {
  6119. /**
  6120. * Specifies is mipmaps must be generated
  6121. */
  6122. generateMipMaps?: boolean;
  6123. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6124. generateDepthBuffer?: boolean;
  6125. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6126. generateStencilBuffer?: boolean;
  6127. /** Defines texture type (int by default) */
  6128. type?: number;
  6129. /** Defines sampling mode (trilinear by default) */
  6130. samplingMode?: number;
  6131. /** Defines format (RGBA by default) */
  6132. format?: number;
  6133. }
  6134. }
  6135. declare module "babylonjs/States/alphaCullingState" {
  6136. /**
  6137. * @hidden
  6138. **/
  6139. export class _AlphaState {
  6140. private _isAlphaBlendDirty;
  6141. private _isBlendFunctionParametersDirty;
  6142. private _isBlendEquationParametersDirty;
  6143. private _isBlendConstantsDirty;
  6144. private _alphaBlend;
  6145. private _blendFunctionParameters;
  6146. private _blendEquationParameters;
  6147. private _blendConstants;
  6148. /**
  6149. * Initializes the state.
  6150. */
  6151. constructor();
  6152. readonly isDirty: boolean;
  6153. alphaBlend: boolean;
  6154. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6155. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6156. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6157. reset(): void;
  6158. apply(gl: WebGLRenderingContext): void;
  6159. }
  6160. }
  6161. declare module "babylonjs/States/depthCullingState" {
  6162. import { Nullable } from "babylonjs/types";
  6163. /**
  6164. * @hidden
  6165. **/
  6166. export class _DepthCullingState {
  6167. private _isDepthTestDirty;
  6168. private _isDepthMaskDirty;
  6169. private _isDepthFuncDirty;
  6170. private _isCullFaceDirty;
  6171. private _isCullDirty;
  6172. private _isZOffsetDirty;
  6173. private _isFrontFaceDirty;
  6174. private _depthTest;
  6175. private _depthMask;
  6176. private _depthFunc;
  6177. private _cull;
  6178. private _cullFace;
  6179. private _zOffset;
  6180. private _frontFace;
  6181. /**
  6182. * Initializes the state.
  6183. */
  6184. constructor();
  6185. readonly isDirty: boolean;
  6186. zOffset: number;
  6187. cullFace: Nullable<number>;
  6188. cull: Nullable<boolean>;
  6189. depthFunc: Nullable<number>;
  6190. depthMask: boolean;
  6191. depthTest: boolean;
  6192. frontFace: Nullable<number>;
  6193. reset(): void;
  6194. apply(gl: WebGLRenderingContext): void;
  6195. }
  6196. }
  6197. declare module "babylonjs/States/stencilState" {
  6198. /**
  6199. * @hidden
  6200. **/
  6201. export class _StencilState {
  6202. /** 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 */
  6203. static readonly ALWAYS: number;
  6204. /** Passed to stencilOperation to specify that stencil value must be kept */
  6205. static readonly KEEP: number;
  6206. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6207. static readonly REPLACE: number;
  6208. private _isStencilTestDirty;
  6209. private _isStencilMaskDirty;
  6210. private _isStencilFuncDirty;
  6211. private _isStencilOpDirty;
  6212. private _stencilTest;
  6213. private _stencilMask;
  6214. private _stencilFunc;
  6215. private _stencilFuncRef;
  6216. private _stencilFuncMask;
  6217. private _stencilOpStencilFail;
  6218. private _stencilOpDepthFail;
  6219. private _stencilOpStencilDepthPass;
  6220. readonly isDirty: boolean;
  6221. stencilFunc: number;
  6222. stencilFuncRef: number;
  6223. stencilFuncMask: number;
  6224. stencilOpStencilFail: number;
  6225. stencilOpDepthFail: number;
  6226. stencilOpStencilDepthPass: number;
  6227. stencilMask: number;
  6228. stencilTest: boolean;
  6229. constructor();
  6230. reset(): void;
  6231. apply(gl: WebGLRenderingContext): void;
  6232. }
  6233. }
  6234. declare module "babylonjs/States/index" {
  6235. export * from "babylonjs/States/alphaCullingState";
  6236. export * from "babylonjs/States/depthCullingState";
  6237. export * from "babylonjs/States/stencilState";
  6238. }
  6239. declare module "babylonjs/Instrumentation/timeToken" {
  6240. import { Nullable } from "babylonjs/types";
  6241. /**
  6242. * @hidden
  6243. **/
  6244. export class _TimeToken {
  6245. _startTimeQuery: Nullable<WebGLQuery>;
  6246. _endTimeQuery: Nullable<WebGLQuery>;
  6247. _timeElapsedQuery: Nullable<WebGLQuery>;
  6248. _timeElapsedQueryEnded: boolean;
  6249. }
  6250. }
  6251. declare module "babylonjs/Materials/Textures/internalTexture" {
  6252. import { Observable } from "babylonjs/Misc/observable";
  6253. import { Nullable, int } from "babylonjs/types";
  6254. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6255. import { Engine } from "babylonjs/Engines/engine";
  6256. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6257. /**
  6258. * Class used to store data associated with WebGL texture data for the engine
  6259. * This class should not be used directly
  6260. */
  6261. export class InternalTexture {
  6262. /** hidden */
  6263. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6264. /**
  6265. * The source of the texture data is unknown
  6266. */
  6267. static DATASOURCE_UNKNOWN: number;
  6268. /**
  6269. * Texture data comes from an URL
  6270. */
  6271. static DATASOURCE_URL: number;
  6272. /**
  6273. * Texture data is only used for temporary storage
  6274. */
  6275. static DATASOURCE_TEMP: number;
  6276. /**
  6277. * Texture data comes from raw data (ArrayBuffer)
  6278. */
  6279. static DATASOURCE_RAW: number;
  6280. /**
  6281. * Texture content is dynamic (video or dynamic texture)
  6282. */
  6283. static DATASOURCE_DYNAMIC: number;
  6284. /**
  6285. * Texture content is generated by rendering to it
  6286. */
  6287. static DATASOURCE_RENDERTARGET: number;
  6288. /**
  6289. * Texture content is part of a multi render target process
  6290. */
  6291. static DATASOURCE_MULTIRENDERTARGET: number;
  6292. /**
  6293. * Texture data comes from a cube data file
  6294. */
  6295. static DATASOURCE_CUBE: number;
  6296. /**
  6297. * Texture data comes from a raw cube data
  6298. */
  6299. static DATASOURCE_CUBERAW: number;
  6300. /**
  6301. * Texture data come from a prefiltered cube data file
  6302. */
  6303. static DATASOURCE_CUBEPREFILTERED: number;
  6304. /**
  6305. * Texture content is raw 3D data
  6306. */
  6307. static DATASOURCE_RAW3D: number;
  6308. /**
  6309. * Texture content is a depth texture
  6310. */
  6311. static DATASOURCE_DEPTHTEXTURE: number;
  6312. /**
  6313. * Texture data comes from a raw cube data encoded with RGBD
  6314. */
  6315. static DATASOURCE_CUBERAW_RGBD: number;
  6316. /**
  6317. * Defines if the texture is ready
  6318. */
  6319. isReady: boolean;
  6320. /**
  6321. * Defines if the texture is a cube texture
  6322. */
  6323. isCube: boolean;
  6324. /**
  6325. * Defines if the texture contains 3D data
  6326. */
  6327. is3D: boolean;
  6328. /**
  6329. * Defines if the texture contains multiview data
  6330. */
  6331. isMultiview: boolean;
  6332. /**
  6333. * Gets the URL used to load this texture
  6334. */
  6335. url: string;
  6336. /**
  6337. * Gets the sampling mode of the texture
  6338. */
  6339. samplingMode: number;
  6340. /**
  6341. * Gets a boolean indicating if the texture needs mipmaps generation
  6342. */
  6343. generateMipMaps: boolean;
  6344. /**
  6345. * Gets the number of samples used by the texture (WebGL2+ only)
  6346. */
  6347. samples: number;
  6348. /**
  6349. * Gets the type of the texture (int, float...)
  6350. */
  6351. type: number;
  6352. /**
  6353. * Gets the format of the texture (RGB, RGBA...)
  6354. */
  6355. format: number;
  6356. /**
  6357. * Observable called when the texture is loaded
  6358. */
  6359. onLoadedObservable: Observable<InternalTexture>;
  6360. /**
  6361. * Gets the width of the texture
  6362. */
  6363. width: number;
  6364. /**
  6365. * Gets the height of the texture
  6366. */
  6367. height: number;
  6368. /**
  6369. * Gets the depth of the texture
  6370. */
  6371. depth: number;
  6372. /**
  6373. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6374. */
  6375. baseWidth: number;
  6376. /**
  6377. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6378. */
  6379. baseHeight: number;
  6380. /**
  6381. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6382. */
  6383. baseDepth: number;
  6384. /**
  6385. * Gets a boolean indicating if the texture is inverted on Y axis
  6386. */
  6387. invertY: boolean;
  6388. /** @hidden */
  6389. _invertVScale: boolean;
  6390. /** @hidden */
  6391. _associatedChannel: number;
  6392. /** @hidden */
  6393. _dataSource: number;
  6394. /** @hidden */
  6395. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6396. /** @hidden */
  6397. _bufferView: Nullable<ArrayBufferView>;
  6398. /** @hidden */
  6399. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6400. /** @hidden */
  6401. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6402. /** @hidden */
  6403. _size: number;
  6404. /** @hidden */
  6405. _extension: string;
  6406. /** @hidden */
  6407. _files: Nullable<string[]>;
  6408. /** @hidden */
  6409. _workingCanvas: Nullable<HTMLCanvasElement>;
  6410. /** @hidden */
  6411. _workingContext: Nullable<CanvasRenderingContext2D>;
  6412. /** @hidden */
  6413. _framebuffer: Nullable<WebGLFramebuffer>;
  6414. /** @hidden */
  6415. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6416. /** @hidden */
  6417. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6418. /** @hidden */
  6419. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6420. /** @hidden */
  6421. _attachments: Nullable<number[]>;
  6422. /** @hidden */
  6423. _cachedCoordinatesMode: Nullable<number>;
  6424. /** @hidden */
  6425. _cachedWrapU: Nullable<number>;
  6426. /** @hidden */
  6427. _cachedWrapV: Nullable<number>;
  6428. /** @hidden */
  6429. _cachedWrapR: Nullable<number>;
  6430. /** @hidden */
  6431. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6432. /** @hidden */
  6433. _isDisabled: boolean;
  6434. /** @hidden */
  6435. _compression: Nullable<string>;
  6436. /** @hidden */
  6437. _generateStencilBuffer: boolean;
  6438. /** @hidden */
  6439. _generateDepthBuffer: boolean;
  6440. /** @hidden */
  6441. _comparisonFunction: number;
  6442. /** @hidden */
  6443. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6444. /** @hidden */
  6445. _lodGenerationScale: number;
  6446. /** @hidden */
  6447. _lodGenerationOffset: number;
  6448. /** @hidden */
  6449. _colorTextureArray: Nullable<WebGLTexture>;
  6450. /** @hidden */
  6451. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6452. /** @hidden */
  6453. _lodTextureHigh: Nullable<BaseTexture>;
  6454. /** @hidden */
  6455. _lodTextureMid: Nullable<BaseTexture>;
  6456. /** @hidden */
  6457. _lodTextureLow: Nullable<BaseTexture>;
  6458. /** @hidden */
  6459. _isRGBD: boolean;
  6460. /** @hidden */
  6461. _webGLTexture: Nullable<WebGLTexture>;
  6462. /** @hidden */
  6463. _references: number;
  6464. private _engine;
  6465. /**
  6466. * Gets the Engine the texture belongs to.
  6467. * @returns The babylon engine
  6468. */
  6469. getEngine(): Engine;
  6470. /**
  6471. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6472. */
  6473. readonly dataSource: number;
  6474. /**
  6475. * Creates a new InternalTexture
  6476. * @param engine defines the engine to use
  6477. * @param dataSource defines the type of data that will be used
  6478. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6479. */
  6480. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6481. /**
  6482. * Increments the number of references (ie. the number of Texture that point to it)
  6483. */
  6484. incrementReferences(): void;
  6485. /**
  6486. * Change the size of the texture (not the size of the content)
  6487. * @param width defines the new width
  6488. * @param height defines the new height
  6489. * @param depth defines the new depth (1 by default)
  6490. */
  6491. updateSize(width: int, height: int, depth?: int): void;
  6492. /** @hidden */
  6493. _rebuild(): void;
  6494. /** @hidden */
  6495. _swapAndDie(target: InternalTexture): void;
  6496. /**
  6497. * Dispose the current allocated resources
  6498. */
  6499. dispose(): void;
  6500. }
  6501. }
  6502. declare module "babylonjs/Animations/easing" {
  6503. /**
  6504. * This represents the main contract an easing function should follow.
  6505. * Easing functions are used throughout the animation system.
  6506. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6507. */
  6508. export interface IEasingFunction {
  6509. /**
  6510. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6511. * of the easing function.
  6512. * The link below provides some of the most common examples of easing functions.
  6513. * @see https://easings.net/
  6514. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6515. * @returns the corresponding value on the curve defined by the easing function
  6516. */
  6517. ease(gradient: number): number;
  6518. }
  6519. /**
  6520. * Base class used for every default easing function.
  6521. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6522. */
  6523. export class EasingFunction implements IEasingFunction {
  6524. /**
  6525. * Interpolation follows the mathematical formula associated with the easing function.
  6526. */
  6527. static readonly EASINGMODE_EASEIN: number;
  6528. /**
  6529. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6530. */
  6531. static readonly EASINGMODE_EASEOUT: number;
  6532. /**
  6533. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6534. */
  6535. static readonly EASINGMODE_EASEINOUT: number;
  6536. private _easingMode;
  6537. /**
  6538. * Sets the easing mode of the current function.
  6539. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6540. */
  6541. setEasingMode(easingMode: number): void;
  6542. /**
  6543. * Gets the current easing mode.
  6544. * @returns the easing mode
  6545. */
  6546. getEasingMode(): number;
  6547. /**
  6548. * @hidden
  6549. */
  6550. easeInCore(gradient: number): number;
  6551. /**
  6552. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6553. * of the easing function.
  6554. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6555. * @returns the corresponding value on the curve defined by the easing function
  6556. */
  6557. ease(gradient: number): number;
  6558. }
  6559. /**
  6560. * Easing function with a circle shape (see link below).
  6561. * @see https://easings.net/#easeInCirc
  6562. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6563. */
  6564. export class CircleEase extends EasingFunction implements IEasingFunction {
  6565. /** @hidden */
  6566. easeInCore(gradient: number): number;
  6567. }
  6568. /**
  6569. * Easing function with a ease back shape (see link below).
  6570. * @see https://easings.net/#easeInBack
  6571. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6572. */
  6573. export class BackEase extends EasingFunction implements IEasingFunction {
  6574. /** Defines the amplitude of the function */
  6575. amplitude: number;
  6576. /**
  6577. * Instantiates a back ease easing
  6578. * @see https://easings.net/#easeInBack
  6579. * @param amplitude Defines the amplitude of the function
  6580. */
  6581. constructor(
  6582. /** Defines the amplitude of the function */
  6583. amplitude?: number);
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a bouncing shape (see link below).
  6589. * @see https://easings.net/#easeInBounce
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class BounceEase extends EasingFunction implements IEasingFunction {
  6593. /** Defines the number of bounces */
  6594. bounces: number;
  6595. /** Defines the amplitude of the bounce */
  6596. bounciness: number;
  6597. /**
  6598. * Instantiates a bounce easing
  6599. * @see https://easings.net/#easeInBounce
  6600. * @param bounces Defines the number of bounces
  6601. * @param bounciness Defines the amplitude of the bounce
  6602. */
  6603. constructor(
  6604. /** Defines the number of bounces */
  6605. bounces?: number,
  6606. /** Defines the amplitude of the bounce */
  6607. bounciness?: number);
  6608. /** @hidden */
  6609. easeInCore(gradient: number): number;
  6610. }
  6611. /**
  6612. * Easing function with a power of 3 shape (see link below).
  6613. * @see https://easings.net/#easeInCubic
  6614. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6615. */
  6616. export class CubicEase extends EasingFunction implements IEasingFunction {
  6617. /** @hidden */
  6618. easeInCore(gradient: number): number;
  6619. }
  6620. /**
  6621. * Easing function with an elastic shape (see link below).
  6622. * @see https://easings.net/#easeInElastic
  6623. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6624. */
  6625. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6626. /** Defines the number of oscillations*/
  6627. oscillations: number;
  6628. /** Defines the amplitude of the oscillations*/
  6629. springiness: number;
  6630. /**
  6631. * Instantiates an elastic easing function
  6632. * @see https://easings.net/#easeInElastic
  6633. * @param oscillations Defines the number of oscillations
  6634. * @param springiness Defines the amplitude of the oscillations
  6635. */
  6636. constructor(
  6637. /** Defines the number of oscillations*/
  6638. oscillations?: number,
  6639. /** Defines the amplitude of the oscillations*/
  6640. springiness?: number);
  6641. /** @hidden */
  6642. easeInCore(gradient: number): number;
  6643. }
  6644. /**
  6645. * Easing function with an exponential shape (see link below).
  6646. * @see https://easings.net/#easeInExpo
  6647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6648. */
  6649. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6650. /** Defines the exponent of the function */
  6651. exponent: number;
  6652. /**
  6653. * Instantiates an exponential easing function
  6654. * @see https://easings.net/#easeInExpo
  6655. * @param exponent Defines the exponent of the function
  6656. */
  6657. constructor(
  6658. /** Defines the exponent of the function */
  6659. exponent?: number);
  6660. /** @hidden */
  6661. easeInCore(gradient: number): number;
  6662. }
  6663. /**
  6664. * Easing function with a power shape (see link below).
  6665. * @see https://easings.net/#easeInQuad
  6666. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6667. */
  6668. export class PowerEase extends EasingFunction implements IEasingFunction {
  6669. /** Defines the power of the function */
  6670. power: number;
  6671. /**
  6672. * Instantiates an power base easing function
  6673. * @see https://easings.net/#easeInQuad
  6674. * @param power Defines the power of the function
  6675. */
  6676. constructor(
  6677. /** Defines the power of the function */
  6678. power?: number);
  6679. /** @hidden */
  6680. easeInCore(gradient: number): number;
  6681. }
  6682. /**
  6683. * Easing function with a power of 2 shape (see link below).
  6684. * @see https://easings.net/#easeInQuad
  6685. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6686. */
  6687. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6688. /** @hidden */
  6689. easeInCore(gradient: number): number;
  6690. }
  6691. /**
  6692. * Easing function with a power of 4 shape (see link below).
  6693. * @see https://easings.net/#easeInQuart
  6694. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6695. */
  6696. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6697. /** @hidden */
  6698. easeInCore(gradient: number): number;
  6699. }
  6700. /**
  6701. * Easing function with a power of 5 shape (see link below).
  6702. * @see https://easings.net/#easeInQuint
  6703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6704. */
  6705. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6706. /** @hidden */
  6707. easeInCore(gradient: number): number;
  6708. }
  6709. /**
  6710. * Easing function with a sin shape (see link below).
  6711. * @see https://easings.net/#easeInSine
  6712. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6713. */
  6714. export class SineEase extends EasingFunction implements IEasingFunction {
  6715. /** @hidden */
  6716. easeInCore(gradient: number): number;
  6717. }
  6718. /**
  6719. * Easing function with a bezier shape (see link below).
  6720. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6721. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6722. */
  6723. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6724. /** Defines the x component of the start tangent in the bezier curve */
  6725. x1: number;
  6726. /** Defines the y component of the start tangent in the bezier curve */
  6727. y1: number;
  6728. /** Defines the x component of the end tangent in the bezier curve */
  6729. x2: number;
  6730. /** Defines the y component of the end tangent in the bezier curve */
  6731. y2: number;
  6732. /**
  6733. * Instantiates a bezier function
  6734. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6735. * @param x1 Defines the x component of the start tangent in the bezier curve
  6736. * @param y1 Defines the y component of the start tangent in the bezier curve
  6737. * @param x2 Defines the x component of the end tangent in the bezier curve
  6738. * @param y2 Defines the y component of the end tangent in the bezier curve
  6739. */
  6740. constructor(
  6741. /** Defines the x component of the start tangent in the bezier curve */
  6742. x1?: number,
  6743. /** Defines the y component of the start tangent in the bezier curve */
  6744. y1?: number,
  6745. /** Defines the x component of the end tangent in the bezier curve */
  6746. x2?: number,
  6747. /** Defines the y component of the end tangent in the bezier curve */
  6748. y2?: number);
  6749. /** @hidden */
  6750. easeInCore(gradient: number): number;
  6751. }
  6752. }
  6753. declare module "babylonjs/Animations/animationKey" {
  6754. /**
  6755. * Defines an interface which represents an animation key frame
  6756. */
  6757. export interface IAnimationKey {
  6758. /**
  6759. * Frame of the key frame
  6760. */
  6761. frame: number;
  6762. /**
  6763. * Value at the specifies key frame
  6764. */
  6765. value: any;
  6766. /**
  6767. * The input tangent for the cubic hermite spline
  6768. */
  6769. inTangent?: any;
  6770. /**
  6771. * The output tangent for the cubic hermite spline
  6772. */
  6773. outTangent?: any;
  6774. /**
  6775. * The animation interpolation type
  6776. */
  6777. interpolation?: AnimationKeyInterpolation;
  6778. }
  6779. /**
  6780. * Enum for the animation key frame interpolation type
  6781. */
  6782. export enum AnimationKeyInterpolation {
  6783. /**
  6784. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6785. */
  6786. STEP = 1
  6787. }
  6788. }
  6789. declare module "babylonjs/Animations/animationRange" {
  6790. /**
  6791. * Represents the range of an animation
  6792. */
  6793. export class AnimationRange {
  6794. /**The name of the animation range**/
  6795. name: string;
  6796. /**The starting frame of the animation */
  6797. from: number;
  6798. /**The ending frame of the animation*/
  6799. to: number;
  6800. /**
  6801. * Initializes the range of an animation
  6802. * @param name The name of the animation range
  6803. * @param from The starting frame of the animation
  6804. * @param to The ending frame of the animation
  6805. */
  6806. constructor(
  6807. /**The name of the animation range**/
  6808. name: string,
  6809. /**The starting frame of the animation */
  6810. from: number,
  6811. /**The ending frame of the animation*/
  6812. to: number);
  6813. /**
  6814. * Makes a copy of the animation range
  6815. * @returns A copy of the animation range
  6816. */
  6817. clone(): AnimationRange;
  6818. }
  6819. }
  6820. declare module "babylonjs/Animations/animationEvent" {
  6821. /**
  6822. * Composed of a frame, and an action function
  6823. */
  6824. export class AnimationEvent {
  6825. /** The frame for which the event is triggered **/
  6826. frame: number;
  6827. /** The event to perform when triggered **/
  6828. action: (currentFrame: number) => void;
  6829. /** Specifies if the event should be triggered only once**/
  6830. onlyOnce?: boolean | undefined;
  6831. /**
  6832. * Specifies if the animation event is done
  6833. */
  6834. isDone: boolean;
  6835. /**
  6836. * Initializes the animation event
  6837. * @param frame The frame for which the event is triggered
  6838. * @param action The event to perform when triggered
  6839. * @param onlyOnce Specifies if the event should be triggered only once
  6840. */
  6841. constructor(
  6842. /** The frame for which the event is triggered **/
  6843. frame: number,
  6844. /** The event to perform when triggered **/
  6845. action: (currentFrame: number) => void,
  6846. /** Specifies if the event should be triggered only once**/
  6847. onlyOnce?: boolean | undefined);
  6848. /** @hidden */
  6849. _clone(): AnimationEvent;
  6850. }
  6851. }
  6852. declare module "babylonjs/Behaviors/behavior" {
  6853. import { Nullable } from "babylonjs/types";
  6854. /**
  6855. * Interface used to define a behavior
  6856. */
  6857. export interface Behavior<T> {
  6858. /** gets or sets behavior's name */
  6859. name: string;
  6860. /**
  6861. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6862. */
  6863. init(): void;
  6864. /**
  6865. * Called when the behavior is attached to a target
  6866. * @param target defines the target where the behavior is attached to
  6867. */
  6868. attach(target: T): void;
  6869. /**
  6870. * Called when the behavior is detached from its target
  6871. */
  6872. detach(): void;
  6873. }
  6874. /**
  6875. * Interface implemented by classes supporting behaviors
  6876. */
  6877. export interface IBehaviorAware<T> {
  6878. /**
  6879. * Attach a behavior
  6880. * @param behavior defines the behavior to attach
  6881. * @returns the current host
  6882. */
  6883. addBehavior(behavior: Behavior<T>): T;
  6884. /**
  6885. * Remove a behavior from the current object
  6886. * @param behavior defines the behavior to detach
  6887. * @returns the current host
  6888. */
  6889. removeBehavior(behavior: Behavior<T>): T;
  6890. /**
  6891. * Gets a behavior using its name to search
  6892. * @param name defines the name to search
  6893. * @returns the behavior or null if not found
  6894. */
  6895. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6896. }
  6897. }
  6898. declare module "babylonjs/Collisions/intersectionInfo" {
  6899. import { Nullable } from "babylonjs/types";
  6900. /**
  6901. * @hidden
  6902. */
  6903. export class IntersectionInfo {
  6904. bu: Nullable<number>;
  6905. bv: Nullable<number>;
  6906. distance: number;
  6907. faceId: number;
  6908. subMeshId: number;
  6909. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6910. }
  6911. }
  6912. declare module "babylonjs/Culling/boundingSphere" {
  6913. import { DeepImmutable } from "babylonjs/types";
  6914. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6915. /**
  6916. * Class used to store bounding sphere information
  6917. */
  6918. export class BoundingSphere {
  6919. /**
  6920. * Gets the center of the bounding sphere in local space
  6921. */
  6922. readonly center: Vector3;
  6923. /**
  6924. * Radius of the bounding sphere in local space
  6925. */
  6926. radius: number;
  6927. /**
  6928. * Gets the center of the bounding sphere in world space
  6929. */
  6930. readonly centerWorld: Vector3;
  6931. /**
  6932. * Radius of the bounding sphere in world space
  6933. */
  6934. radiusWorld: number;
  6935. /**
  6936. * Gets the minimum vector in local space
  6937. */
  6938. readonly minimum: Vector3;
  6939. /**
  6940. * Gets the maximum vector in local space
  6941. */
  6942. readonly maximum: Vector3;
  6943. private _worldMatrix;
  6944. private static readonly TmpVector3;
  6945. /**
  6946. * Creates a new bounding sphere
  6947. * @param min defines the minimum vector (in local space)
  6948. * @param max defines the maximum vector (in local space)
  6949. * @param worldMatrix defines the new world matrix
  6950. */
  6951. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6952. /**
  6953. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6954. * @param min defines the new minimum vector (in local space)
  6955. * @param max defines the new maximum vector (in local space)
  6956. * @param worldMatrix defines the new world matrix
  6957. */
  6958. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6959. /**
  6960. * Scale the current bounding sphere by applying a scale factor
  6961. * @param factor defines the scale factor to apply
  6962. * @returns the current bounding box
  6963. */
  6964. scale(factor: number): BoundingSphere;
  6965. /**
  6966. * Gets the world matrix of the bounding box
  6967. * @returns a matrix
  6968. */
  6969. getWorldMatrix(): DeepImmutable<Matrix>;
  6970. /** @hidden */
  6971. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6972. /**
  6973. * Tests if the bounding sphere is intersecting the frustum planes
  6974. * @param frustumPlanes defines the frustum planes to test
  6975. * @returns true if there is an intersection
  6976. */
  6977. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6978. /**
  6979. * Tests if the bounding sphere center is in between the frustum planes.
  6980. * Used for optimistic fast inclusion.
  6981. * @param frustumPlanes defines the frustum planes to test
  6982. * @returns true if the sphere center is in between the frustum planes
  6983. */
  6984. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6985. /**
  6986. * Tests if a point is inside the bounding sphere
  6987. * @param point defines the point to test
  6988. * @returns true if the point is inside the bounding sphere
  6989. */
  6990. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6991. /**
  6992. * Checks if two sphere intersct
  6993. * @param sphere0 sphere 0
  6994. * @param sphere1 sphere 1
  6995. * @returns true if the speres intersect
  6996. */
  6997. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6998. }
  6999. }
  7000. declare module "babylonjs/Culling/boundingBox" {
  7001. import { DeepImmutable } from "babylonjs/types";
  7002. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7003. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7004. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7005. /**
  7006. * Class used to store bounding box information
  7007. */
  7008. export class BoundingBox implements ICullable {
  7009. /**
  7010. * Gets the 8 vectors representing the bounding box in local space
  7011. */
  7012. readonly vectors: Vector3[];
  7013. /**
  7014. * Gets the center of the bounding box in local space
  7015. */
  7016. readonly center: Vector3;
  7017. /**
  7018. * Gets the center of the bounding box in world space
  7019. */
  7020. readonly centerWorld: Vector3;
  7021. /**
  7022. * Gets the extend size in local space
  7023. */
  7024. readonly extendSize: Vector3;
  7025. /**
  7026. * Gets the extend size in world space
  7027. */
  7028. readonly extendSizeWorld: Vector3;
  7029. /**
  7030. * Gets the OBB (object bounding box) directions
  7031. */
  7032. readonly directions: Vector3[];
  7033. /**
  7034. * Gets the 8 vectors representing the bounding box in world space
  7035. */
  7036. readonly vectorsWorld: Vector3[];
  7037. /**
  7038. * Gets the minimum vector in world space
  7039. */
  7040. readonly minimumWorld: Vector3;
  7041. /**
  7042. * Gets the maximum vector in world space
  7043. */
  7044. readonly maximumWorld: Vector3;
  7045. /**
  7046. * Gets the minimum vector in local space
  7047. */
  7048. readonly minimum: Vector3;
  7049. /**
  7050. * Gets the maximum vector in local space
  7051. */
  7052. readonly maximum: Vector3;
  7053. private _worldMatrix;
  7054. private static readonly TmpVector3;
  7055. /**
  7056. * @hidden
  7057. */
  7058. _tag: number;
  7059. /**
  7060. * Creates a new bounding box
  7061. * @param min defines the minimum vector (in local space)
  7062. * @param max defines the maximum vector (in local space)
  7063. * @param worldMatrix defines the new world matrix
  7064. */
  7065. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7066. /**
  7067. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7068. * @param min defines the new minimum vector (in local space)
  7069. * @param max defines the new maximum vector (in local space)
  7070. * @param worldMatrix defines the new world matrix
  7071. */
  7072. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7073. /**
  7074. * Scale the current bounding box by applying a scale factor
  7075. * @param factor defines the scale factor to apply
  7076. * @returns the current bounding box
  7077. */
  7078. scale(factor: number): BoundingBox;
  7079. /**
  7080. * Gets the world matrix of the bounding box
  7081. * @returns a matrix
  7082. */
  7083. getWorldMatrix(): DeepImmutable<Matrix>;
  7084. /** @hidden */
  7085. _update(world: DeepImmutable<Matrix>): void;
  7086. /**
  7087. * Tests if the bounding box is intersecting the frustum planes
  7088. * @param frustumPlanes defines the frustum planes to test
  7089. * @returns true if there is an intersection
  7090. */
  7091. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7092. /**
  7093. * Tests if the bounding box is entirely inside the frustum planes
  7094. * @param frustumPlanes defines the frustum planes to test
  7095. * @returns true if there is an inclusion
  7096. */
  7097. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7098. /**
  7099. * Tests if a point is inside the bounding box
  7100. * @param point defines the point to test
  7101. * @returns true if the point is inside the bounding box
  7102. */
  7103. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7104. /**
  7105. * Tests if the bounding box intersects with a bounding sphere
  7106. * @param sphere defines the sphere to test
  7107. * @returns true if there is an intersection
  7108. */
  7109. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7110. /**
  7111. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7112. * @param min defines the min vector to use
  7113. * @param max defines the max vector to use
  7114. * @returns true if there is an intersection
  7115. */
  7116. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7117. /**
  7118. * Tests if two bounding boxes are intersections
  7119. * @param box0 defines the first box to test
  7120. * @param box1 defines the second box to test
  7121. * @returns true if there is an intersection
  7122. */
  7123. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7124. /**
  7125. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7126. * @param minPoint defines the minimum vector of the bounding box
  7127. * @param maxPoint defines the maximum vector of the bounding box
  7128. * @param sphereCenter defines the sphere center
  7129. * @param sphereRadius defines the sphere radius
  7130. * @returns true if there is an intersection
  7131. */
  7132. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7133. /**
  7134. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7135. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7136. * @param frustumPlanes defines the frustum planes to test
  7137. * @return true if there is an inclusion
  7138. */
  7139. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7140. /**
  7141. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7142. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7143. * @param frustumPlanes defines the frustum planes to test
  7144. * @return true if there is an intersection
  7145. */
  7146. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7147. }
  7148. }
  7149. declare module "babylonjs/Collisions/collider" {
  7150. import { Nullable, IndicesArray } from "babylonjs/types";
  7151. import { Vector3, Plane } from "babylonjs/Maths/math";
  7152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7153. /** @hidden */
  7154. export class Collider {
  7155. /** Define if a collision was found */
  7156. collisionFound: boolean;
  7157. /**
  7158. * Define last intersection point in local space
  7159. */
  7160. intersectionPoint: Vector3;
  7161. /**
  7162. * Define last collided mesh
  7163. */
  7164. collidedMesh: Nullable<AbstractMesh>;
  7165. private _collisionPoint;
  7166. private _planeIntersectionPoint;
  7167. private _tempVector;
  7168. private _tempVector2;
  7169. private _tempVector3;
  7170. private _tempVector4;
  7171. private _edge;
  7172. private _baseToVertex;
  7173. private _destinationPoint;
  7174. private _slidePlaneNormal;
  7175. private _displacementVector;
  7176. /** @hidden */
  7177. _radius: Vector3;
  7178. /** @hidden */
  7179. _retry: number;
  7180. private _velocity;
  7181. private _basePoint;
  7182. private _epsilon;
  7183. /** @hidden */
  7184. _velocityWorldLength: number;
  7185. /** @hidden */
  7186. _basePointWorld: Vector3;
  7187. private _velocityWorld;
  7188. private _normalizedVelocity;
  7189. /** @hidden */
  7190. _initialVelocity: Vector3;
  7191. /** @hidden */
  7192. _initialPosition: Vector3;
  7193. private _nearestDistance;
  7194. private _collisionMask;
  7195. collisionMask: number;
  7196. /**
  7197. * Gets the plane normal used to compute the sliding response (in local space)
  7198. */
  7199. readonly slidePlaneNormal: Vector3;
  7200. /** @hidden */
  7201. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7202. /** @hidden */
  7203. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7204. /** @hidden */
  7205. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7206. /** @hidden */
  7207. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7208. /** @hidden */
  7209. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7210. /** @hidden */
  7211. _getResponse(pos: Vector3, vel: Vector3): void;
  7212. }
  7213. }
  7214. declare module "babylonjs/Culling/boundingInfo" {
  7215. import { DeepImmutable } from "babylonjs/types";
  7216. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7217. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7218. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7219. import { Collider } from "babylonjs/Collisions/collider";
  7220. /**
  7221. * Interface for cullable objects
  7222. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7223. */
  7224. export interface ICullable {
  7225. /**
  7226. * Checks if the object or part of the object is in the frustum
  7227. * @param frustumPlanes Camera near/planes
  7228. * @returns true if the object is in frustum otherwise false
  7229. */
  7230. isInFrustum(frustumPlanes: Plane[]): boolean;
  7231. /**
  7232. * Checks if a cullable object (mesh...) is in the camera frustum
  7233. * Unlike isInFrustum this cheks the full bounding box
  7234. * @param frustumPlanes Camera near/planes
  7235. * @returns true if the object is in frustum otherwise false
  7236. */
  7237. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7238. }
  7239. /**
  7240. * Info for a bounding data of a mesh
  7241. */
  7242. export class BoundingInfo implements ICullable {
  7243. /**
  7244. * Bounding box for the mesh
  7245. */
  7246. readonly boundingBox: BoundingBox;
  7247. /**
  7248. * Bounding sphere for the mesh
  7249. */
  7250. readonly boundingSphere: BoundingSphere;
  7251. private _isLocked;
  7252. private static readonly TmpVector3;
  7253. /**
  7254. * Constructs bounding info
  7255. * @param minimum min vector of the bounding box/sphere
  7256. * @param maximum max vector of the bounding box/sphere
  7257. * @param worldMatrix defines the new world matrix
  7258. */
  7259. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7260. /**
  7261. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7262. * @param min defines the new minimum vector (in local space)
  7263. * @param max defines the new maximum vector (in local space)
  7264. * @param worldMatrix defines the new world matrix
  7265. */
  7266. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7267. /**
  7268. * min vector of the bounding box/sphere
  7269. */
  7270. readonly minimum: Vector3;
  7271. /**
  7272. * max vector of the bounding box/sphere
  7273. */
  7274. readonly maximum: Vector3;
  7275. /**
  7276. * If the info is locked and won't be updated to avoid perf overhead
  7277. */
  7278. isLocked: boolean;
  7279. /**
  7280. * Updates the bounding sphere and box
  7281. * @param world world matrix to be used to update
  7282. */
  7283. update(world: DeepImmutable<Matrix>): void;
  7284. /**
  7285. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7286. * @param center New center of the bounding info
  7287. * @param extend New extend of the bounding info
  7288. * @returns the current bounding info
  7289. */
  7290. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7291. /**
  7292. * Scale the current bounding info by applying a scale factor
  7293. * @param factor defines the scale factor to apply
  7294. * @returns the current bounding info
  7295. */
  7296. scale(factor: number): BoundingInfo;
  7297. /**
  7298. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7299. * @param frustumPlanes defines the frustum to test
  7300. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7301. * @returns true if the bounding info is in the frustum planes
  7302. */
  7303. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7304. /**
  7305. * Gets the world distance between the min and max points of the bounding box
  7306. */
  7307. readonly diagonalLength: number;
  7308. /**
  7309. * Checks if a cullable object (mesh...) is in the camera frustum
  7310. * Unlike isInFrustum this cheks the full bounding box
  7311. * @param frustumPlanes Camera near/planes
  7312. * @returns true if the object is in frustum otherwise false
  7313. */
  7314. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7315. /** @hidden */
  7316. _checkCollision(collider: Collider): boolean;
  7317. /**
  7318. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7319. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7320. * @param point the point to check intersection with
  7321. * @returns if the point intersects
  7322. */
  7323. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7324. /**
  7325. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7326. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7327. * @param boundingInfo the bounding info to check intersection with
  7328. * @param precise if the intersection should be done using OBB
  7329. * @returns if the bounding info intersects
  7330. */
  7331. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7332. }
  7333. }
  7334. declare module "babylonjs/Misc/smartArray" {
  7335. /**
  7336. * Defines an array and its length.
  7337. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7338. */
  7339. export interface ISmartArrayLike<T> {
  7340. /**
  7341. * The data of the array.
  7342. */
  7343. data: Array<T>;
  7344. /**
  7345. * The active length of the array.
  7346. */
  7347. length: number;
  7348. }
  7349. /**
  7350. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7351. */
  7352. export class SmartArray<T> implements ISmartArrayLike<T> {
  7353. /**
  7354. * The full set of data from the array.
  7355. */
  7356. data: Array<T>;
  7357. /**
  7358. * The active length of the array.
  7359. */
  7360. length: number;
  7361. protected _id: number;
  7362. /**
  7363. * Instantiates a Smart Array.
  7364. * @param capacity defines the default capacity of the array.
  7365. */
  7366. constructor(capacity: number);
  7367. /**
  7368. * Pushes a value at the end of the active data.
  7369. * @param value defines the object to push in the array.
  7370. */
  7371. push(value: T): void;
  7372. /**
  7373. * Iterates over the active data and apply the lambda to them.
  7374. * @param func defines the action to apply on each value.
  7375. */
  7376. forEach(func: (content: T) => void): void;
  7377. /**
  7378. * Sorts the full sets of data.
  7379. * @param compareFn defines the comparison function to apply.
  7380. */
  7381. sort(compareFn: (a: T, b: T) => number): void;
  7382. /**
  7383. * Resets the active data to an empty array.
  7384. */
  7385. reset(): void;
  7386. /**
  7387. * Releases all the data from the array as well as the array.
  7388. */
  7389. dispose(): void;
  7390. /**
  7391. * Concats the active data with a given array.
  7392. * @param array defines the data to concatenate with.
  7393. */
  7394. concat(array: any): void;
  7395. /**
  7396. * Returns the position of a value in the active data.
  7397. * @param value defines the value to find the index for
  7398. * @returns the index if found in the active data otherwise -1
  7399. */
  7400. indexOf(value: T): number;
  7401. /**
  7402. * Returns whether an element is part of the active data.
  7403. * @param value defines the value to look for
  7404. * @returns true if found in the active data otherwise false
  7405. */
  7406. contains(value: T): boolean;
  7407. private static _GlobalId;
  7408. }
  7409. /**
  7410. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7411. * The data in this array can only be present once
  7412. */
  7413. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7414. private _duplicateId;
  7415. /**
  7416. * Pushes a value at the end of the active data.
  7417. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7418. * @param value defines the object to push in the array.
  7419. */
  7420. push(value: T): void;
  7421. /**
  7422. * Pushes a value at the end of the active data.
  7423. * If the data is already present, it won t be added again
  7424. * @param value defines the object to push in the array.
  7425. * @returns true if added false if it was already present
  7426. */
  7427. pushNoDuplicate(value: T): boolean;
  7428. /**
  7429. * Resets the active data to an empty array.
  7430. */
  7431. reset(): void;
  7432. /**
  7433. * Concats the active data with a given array.
  7434. * This ensures no dupplicate will be present in the result.
  7435. * @param array defines the data to concatenate with.
  7436. */
  7437. concatWithNoDuplicate(array: any): void;
  7438. }
  7439. }
  7440. declare module "babylonjs/Materials/multiMaterial" {
  7441. import { Nullable } from "babylonjs/types";
  7442. import { Scene } from "babylonjs/scene";
  7443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7444. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7446. import { Material } from "babylonjs/Materials/material";
  7447. /**
  7448. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7449. * separate meshes. This can be use to improve performances.
  7450. * @see http://doc.babylonjs.com/how_to/multi_materials
  7451. */
  7452. export class MultiMaterial extends Material {
  7453. private _subMaterials;
  7454. /**
  7455. * Gets or Sets the list of Materials used within the multi material.
  7456. * They need to be ordered according to the submeshes order in the associated mesh
  7457. */
  7458. subMaterials: Nullable<Material>[];
  7459. /**
  7460. * Function used to align with Node.getChildren()
  7461. * @returns the list of Materials used within the multi material
  7462. */
  7463. getChildren(): Nullable<Material>[];
  7464. /**
  7465. * Instantiates a new Multi Material
  7466. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7467. * separate meshes. This can be use to improve performances.
  7468. * @see http://doc.babylonjs.com/how_to/multi_materials
  7469. * @param name Define the name in the scene
  7470. * @param scene Define the scene the material belongs to
  7471. */
  7472. constructor(name: string, scene: Scene);
  7473. private _hookArray;
  7474. /**
  7475. * Get one of the submaterial by its index in the submaterials array
  7476. * @param index The index to look the sub material at
  7477. * @returns The Material if the index has been defined
  7478. */
  7479. getSubMaterial(index: number): Nullable<Material>;
  7480. /**
  7481. * Get the list of active textures for the whole sub materials list.
  7482. * @returns All the textures that will be used during the rendering
  7483. */
  7484. getActiveTextures(): BaseTexture[];
  7485. /**
  7486. * Gets the current class name of the material e.g. "MultiMaterial"
  7487. * Mainly use in serialization.
  7488. * @returns the class name
  7489. */
  7490. getClassName(): string;
  7491. /**
  7492. * Checks if the material is ready to render the requested sub mesh
  7493. * @param mesh Define the mesh the submesh belongs to
  7494. * @param subMesh Define the sub mesh to look readyness for
  7495. * @param useInstances Define whether or not the material is used with instances
  7496. * @returns true if ready, otherwise false
  7497. */
  7498. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7499. /**
  7500. * Clones the current material and its related sub materials
  7501. * @param name Define the name of the newly cloned material
  7502. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7503. * @returns the cloned material
  7504. */
  7505. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7506. /**
  7507. * Serializes the materials into a JSON representation.
  7508. * @returns the JSON representation
  7509. */
  7510. serialize(): any;
  7511. /**
  7512. * Dispose the material and release its associated resources
  7513. * @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)
  7514. * @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)
  7515. * @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)
  7516. */
  7517. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7518. /**
  7519. * Creates a MultiMaterial from parsed MultiMaterial data.
  7520. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7521. * @param scene defines the hosting scene
  7522. * @returns a new MultiMaterial
  7523. */
  7524. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7525. }
  7526. }
  7527. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7528. /**
  7529. * Class used to represent data loading progression
  7530. */
  7531. export class SceneLoaderFlags {
  7532. private static _ForceFullSceneLoadingForIncremental;
  7533. private static _ShowLoadingScreen;
  7534. private static _CleanBoneMatrixWeights;
  7535. private static _loggingLevel;
  7536. /**
  7537. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7538. */
  7539. static ForceFullSceneLoadingForIncremental: boolean;
  7540. /**
  7541. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7542. */
  7543. static ShowLoadingScreen: boolean;
  7544. /**
  7545. * Defines the current logging level (while loading the scene)
  7546. * @ignorenaming
  7547. */
  7548. static loggingLevel: number;
  7549. /**
  7550. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7551. */
  7552. static CleanBoneMatrixWeights: boolean;
  7553. }
  7554. }
  7555. declare module "babylonjs/Meshes/transformNode" {
  7556. import { DeepImmutable } from "babylonjs/types";
  7557. import { Observable } from "babylonjs/Misc/observable";
  7558. import { Nullable } from "babylonjs/types";
  7559. import { Camera } from "babylonjs/Cameras/camera";
  7560. import { Scene } from "babylonjs/scene";
  7561. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7562. import { Node } from "babylonjs/node";
  7563. import { Bone } from "babylonjs/Bones/bone";
  7564. /**
  7565. * 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.
  7566. * @see https://doc.babylonjs.com/how_to/transformnode
  7567. */
  7568. export class TransformNode extends Node {
  7569. /**
  7570. * Object will not rotate to face the camera
  7571. */
  7572. static BILLBOARDMODE_NONE: number;
  7573. /**
  7574. * Object will rotate to face the camera but only on the x axis
  7575. */
  7576. static BILLBOARDMODE_X: number;
  7577. /**
  7578. * Object will rotate to face the camera but only on the y axis
  7579. */
  7580. static BILLBOARDMODE_Y: number;
  7581. /**
  7582. * Object will rotate to face the camera but only on the z axis
  7583. */
  7584. static BILLBOARDMODE_Z: number;
  7585. /**
  7586. * Object will rotate to face the camera
  7587. */
  7588. static BILLBOARDMODE_ALL: number;
  7589. private _forward;
  7590. private _forwardInverted;
  7591. private _up;
  7592. private _right;
  7593. private _rightInverted;
  7594. private _position;
  7595. private _rotation;
  7596. private _rotationQuaternion;
  7597. protected _scaling: Vector3;
  7598. protected _isDirty: boolean;
  7599. private _transformToBoneReferal;
  7600. private _billboardMode;
  7601. /**
  7602. * Gets or sets the billboard mode. Default is 0.
  7603. *
  7604. * | Value | Type | Description |
  7605. * | --- | --- | --- |
  7606. * | 0 | BILLBOARDMODE_NONE | |
  7607. * | 1 | BILLBOARDMODE_X | |
  7608. * | 2 | BILLBOARDMODE_Y | |
  7609. * | 4 | BILLBOARDMODE_Z | |
  7610. * | 7 | BILLBOARDMODE_ALL | |
  7611. *
  7612. */
  7613. billboardMode: number;
  7614. private _preserveParentRotationForBillboard;
  7615. /**
  7616. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7617. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7618. */
  7619. preserveParentRotationForBillboard: boolean;
  7620. /**
  7621. * 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
  7622. */
  7623. scalingDeterminant: number;
  7624. private _infiniteDistance;
  7625. /**
  7626. * Gets or sets the distance of the object to max, often used by skybox
  7627. */
  7628. infiniteDistance: boolean;
  7629. /**
  7630. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7631. * By default the system will update normals to compensate
  7632. */
  7633. ignoreNonUniformScaling: boolean;
  7634. /**
  7635. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7636. */
  7637. reIntegrateRotationIntoRotationQuaternion: boolean;
  7638. /** @hidden */
  7639. _poseMatrix: Nullable<Matrix>;
  7640. /** @hidden */
  7641. _localMatrix: Matrix;
  7642. private _usePivotMatrix;
  7643. private _absolutePosition;
  7644. private _pivotMatrix;
  7645. private _pivotMatrixInverse;
  7646. protected _postMultiplyPivotMatrix: boolean;
  7647. protected _isWorldMatrixFrozen: boolean;
  7648. /** @hidden */
  7649. _indexInSceneTransformNodesArray: number;
  7650. /**
  7651. * An event triggered after the world matrix is updated
  7652. */
  7653. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7654. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7655. /**
  7656. * Gets a string identifying the name of the class
  7657. * @returns "TransformNode" string
  7658. */
  7659. getClassName(): string;
  7660. /**
  7661. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7662. */
  7663. position: Vector3;
  7664. /**
  7665. * 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)).
  7666. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7667. */
  7668. rotation: Vector3;
  7669. /**
  7670. * 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)).
  7671. */
  7672. scaling: Vector3;
  7673. /**
  7674. * 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).
  7675. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7676. */
  7677. rotationQuaternion: Nullable<Quaternion>;
  7678. /**
  7679. * The forward direction of that transform in world space.
  7680. */
  7681. readonly forward: Vector3;
  7682. /**
  7683. * The up direction of that transform in world space.
  7684. */
  7685. readonly up: Vector3;
  7686. /**
  7687. * The right direction of that transform in world space.
  7688. */
  7689. readonly right: Vector3;
  7690. /**
  7691. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7692. * @param matrix the matrix to copy the pose from
  7693. * @returns this TransformNode.
  7694. */
  7695. updatePoseMatrix(matrix: Matrix): TransformNode;
  7696. /**
  7697. * Returns the mesh Pose matrix.
  7698. * @returns the pose matrix
  7699. */
  7700. getPoseMatrix(): Matrix;
  7701. /** @hidden */
  7702. _isSynchronized(): boolean;
  7703. /** @hidden */
  7704. _initCache(): void;
  7705. /**
  7706. * Flag the transform node as dirty (Forcing it to update everything)
  7707. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7708. * @returns this transform node
  7709. */
  7710. markAsDirty(property: string): TransformNode;
  7711. /**
  7712. * Returns the current mesh absolute position.
  7713. * Returns a Vector3.
  7714. */
  7715. readonly absolutePosition: Vector3;
  7716. /**
  7717. * Sets a new matrix to apply before all other transformation
  7718. * @param matrix defines the transform matrix
  7719. * @returns the current TransformNode
  7720. */
  7721. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7722. /**
  7723. * Sets a new pivot matrix to the current node
  7724. * @param matrix defines the new pivot matrix to use
  7725. * @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
  7726. * @returns the current TransformNode
  7727. */
  7728. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7729. /**
  7730. * Returns the mesh pivot matrix.
  7731. * Default : Identity.
  7732. * @returns the matrix
  7733. */
  7734. getPivotMatrix(): Matrix;
  7735. /**
  7736. * Prevents the World matrix to be computed any longer.
  7737. * @returns the TransformNode.
  7738. */
  7739. freezeWorldMatrix(): TransformNode;
  7740. /**
  7741. * Allows back the World matrix computation.
  7742. * @returns the TransformNode.
  7743. */
  7744. unfreezeWorldMatrix(): this;
  7745. /**
  7746. * True if the World matrix has been frozen.
  7747. */
  7748. readonly isWorldMatrixFrozen: boolean;
  7749. /**
  7750. * Retuns the mesh absolute position in the World.
  7751. * @returns a Vector3.
  7752. */
  7753. getAbsolutePosition(): Vector3;
  7754. /**
  7755. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7756. * @param absolutePosition the absolute position to set
  7757. * @returns the TransformNode.
  7758. */
  7759. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7760. /**
  7761. * Sets the mesh position in its local space.
  7762. * @param vector3 the position to set in localspace
  7763. * @returns the TransformNode.
  7764. */
  7765. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7766. /**
  7767. * Returns the mesh position in the local space from the current World matrix values.
  7768. * @returns a new Vector3.
  7769. */
  7770. getPositionExpressedInLocalSpace(): Vector3;
  7771. /**
  7772. * Translates the mesh along the passed Vector3 in its local space.
  7773. * @param vector3 the distance to translate in localspace
  7774. * @returns the TransformNode.
  7775. */
  7776. locallyTranslate(vector3: Vector3): TransformNode;
  7777. private static _lookAtVectorCache;
  7778. /**
  7779. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7780. * @param targetPoint the position (must be in same space as current mesh) to look at
  7781. * @param yawCor optional yaw (y-axis) correction in radians
  7782. * @param pitchCor optional pitch (x-axis) correction in radians
  7783. * @param rollCor optional roll (z-axis) correction in radians
  7784. * @param space the choosen space of the target
  7785. * @returns the TransformNode.
  7786. */
  7787. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7788. /**
  7789. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7790. * This Vector3 is expressed in the World space.
  7791. * @param localAxis axis to rotate
  7792. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7793. */
  7794. getDirection(localAxis: Vector3): Vector3;
  7795. /**
  7796. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7797. * localAxis is expressed in the mesh local space.
  7798. * result is computed in the Wordl space from the mesh World matrix.
  7799. * @param localAxis axis to rotate
  7800. * @param result the resulting transformnode
  7801. * @returns this TransformNode.
  7802. */
  7803. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7804. /**
  7805. * Sets this transform node rotation to the given local axis.
  7806. * @param localAxis the axis in local space
  7807. * @param yawCor optional yaw (y-axis) correction in radians
  7808. * @param pitchCor optional pitch (x-axis) correction in radians
  7809. * @param rollCor optional roll (z-axis) correction in radians
  7810. * @returns this TransformNode
  7811. */
  7812. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7813. /**
  7814. * Sets a new pivot point to the current node
  7815. * @param point defines the new pivot point to use
  7816. * @param space defines if the point is in world or local space (local by default)
  7817. * @returns the current TransformNode
  7818. */
  7819. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7820. /**
  7821. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7822. * @returns the pivot point
  7823. */
  7824. getPivotPoint(): Vector3;
  7825. /**
  7826. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7827. * @param result the vector3 to store the result
  7828. * @returns this TransformNode.
  7829. */
  7830. getPivotPointToRef(result: Vector3): TransformNode;
  7831. /**
  7832. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7833. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7834. */
  7835. getAbsolutePivotPoint(): Vector3;
  7836. /**
  7837. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7838. * @param result vector3 to store the result
  7839. * @returns this TransformNode.
  7840. */
  7841. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7842. /**
  7843. * Defines the passed node as the parent of the current node.
  7844. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7845. * @see https://doc.babylonjs.com/how_to/parenting
  7846. * @param node the node ot set as the parent
  7847. * @returns this TransformNode.
  7848. */
  7849. setParent(node: Nullable<Node>): TransformNode;
  7850. private _nonUniformScaling;
  7851. /**
  7852. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7853. */
  7854. readonly nonUniformScaling: boolean;
  7855. /** @hidden */
  7856. _updateNonUniformScalingState(value: boolean): boolean;
  7857. /**
  7858. * Attach the current TransformNode to another TransformNode associated with a bone
  7859. * @param bone Bone affecting the TransformNode
  7860. * @param affectedTransformNode TransformNode associated with the bone
  7861. * @returns this object
  7862. */
  7863. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7864. /**
  7865. * Detach the transform node if its associated with a bone
  7866. * @returns this object
  7867. */
  7868. detachFromBone(): TransformNode;
  7869. private static _rotationAxisCache;
  7870. /**
  7871. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7872. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7873. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7874. * The passed axis is also normalized.
  7875. * @param axis the axis to rotate around
  7876. * @param amount the amount to rotate in radians
  7877. * @param space Space to rotate in (Default: local)
  7878. * @returns the TransformNode.
  7879. */
  7880. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7881. /**
  7882. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7883. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7884. * The passed axis is also normalized. .
  7885. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7886. * @param point the point to rotate around
  7887. * @param axis the axis to rotate around
  7888. * @param amount the amount to rotate in radians
  7889. * @returns the TransformNode
  7890. */
  7891. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7892. /**
  7893. * Translates the mesh along the axis vector for the passed distance in the given space.
  7894. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7895. * @param axis the axis to translate in
  7896. * @param distance the distance to translate
  7897. * @param space Space to rotate in (Default: local)
  7898. * @returns the TransformNode.
  7899. */
  7900. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7901. /**
  7902. * Adds a rotation step to the mesh current rotation.
  7903. * x, y, z are Euler angles expressed in radians.
  7904. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7905. * This means this rotation is made in the mesh local space only.
  7906. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7907. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7908. * ```javascript
  7909. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7910. * ```
  7911. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7912. * 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.
  7913. * @param x Rotation to add
  7914. * @param y Rotation to add
  7915. * @param z Rotation to add
  7916. * @returns the TransformNode.
  7917. */
  7918. addRotation(x: number, y: number, z: number): TransformNode;
  7919. /**
  7920. * @hidden
  7921. */
  7922. protected _getEffectiveParent(): Nullable<Node>;
  7923. /**
  7924. * Computes the world matrix of the node
  7925. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7926. * @returns the world matrix
  7927. */
  7928. computeWorldMatrix(force?: boolean): Matrix;
  7929. protected _afterComputeWorldMatrix(): void;
  7930. /**
  7931. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7932. * @param func callback function to add
  7933. *
  7934. * @returns the TransformNode.
  7935. */
  7936. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7937. /**
  7938. * Removes a registered callback function.
  7939. * @param func callback function to remove
  7940. * @returns the TransformNode.
  7941. */
  7942. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7943. /**
  7944. * Gets the position of the current mesh in camera space
  7945. * @param camera defines the camera to use
  7946. * @returns a position
  7947. */
  7948. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7949. /**
  7950. * Returns the distance from the mesh to the active camera
  7951. * @param camera defines the camera to use
  7952. * @returns the distance
  7953. */
  7954. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7955. /**
  7956. * Clone the current transform node
  7957. * @param name Name of the new clone
  7958. * @param newParent New parent for the clone
  7959. * @param doNotCloneChildren Do not clone children hierarchy
  7960. * @returns the new transform node
  7961. */
  7962. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7963. /**
  7964. * Serializes the objects information.
  7965. * @param currentSerializationObject defines the object to serialize in
  7966. * @returns the serialized object
  7967. */
  7968. serialize(currentSerializationObject?: any): any;
  7969. /**
  7970. * Returns a new TransformNode object parsed from the source provided.
  7971. * @param parsedTransformNode is the source.
  7972. * @param scene the scne the object belongs to
  7973. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7974. * @returns a new TransformNode object parsed from the source provided.
  7975. */
  7976. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7977. /**
  7978. * Get all child-transformNodes of this node
  7979. * @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
  7980. * @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
  7981. * @returns an array of TransformNode
  7982. */
  7983. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7984. /**
  7985. * Releases resources associated with this transform node.
  7986. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7987. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7988. */
  7989. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7990. }
  7991. }
  7992. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7993. /**
  7994. * Class used to override all child animations of a given target
  7995. */
  7996. export class AnimationPropertiesOverride {
  7997. /**
  7998. * Gets or sets a value indicating if animation blending must be used
  7999. */
  8000. enableBlending: boolean;
  8001. /**
  8002. * Gets or sets the blending speed to use when enableBlending is true
  8003. */
  8004. blendingSpeed: number;
  8005. /**
  8006. * Gets or sets the default loop mode to use
  8007. */
  8008. loopMode: number;
  8009. }
  8010. }
  8011. declare module "babylonjs/Bones/bone" {
  8012. import { Skeleton } from "babylonjs/Bones/skeleton";
  8013. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8014. import { Nullable } from "babylonjs/types";
  8015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8016. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8017. import { Node } from "babylonjs/node";
  8018. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8019. /**
  8020. * Class used to store bone information
  8021. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8022. */
  8023. export class Bone extends Node {
  8024. /**
  8025. * defines the bone name
  8026. */
  8027. name: string;
  8028. private static _tmpVecs;
  8029. private static _tmpQuat;
  8030. private static _tmpMats;
  8031. /**
  8032. * Gets the list of child bones
  8033. */
  8034. children: Bone[];
  8035. /** Gets the animations associated with this bone */
  8036. animations: import("babylonjs/Animations/animation").Animation[];
  8037. /**
  8038. * Gets or sets bone length
  8039. */
  8040. length: number;
  8041. /**
  8042. * @hidden Internal only
  8043. * Set this value to map this bone to a different index in the transform matrices
  8044. * Set this value to -1 to exclude the bone from the transform matrices
  8045. */
  8046. _index: Nullable<number>;
  8047. private _skeleton;
  8048. private _localMatrix;
  8049. private _restPose;
  8050. private _baseMatrix;
  8051. private _absoluteTransform;
  8052. private _invertedAbsoluteTransform;
  8053. private _parent;
  8054. private _scalingDeterminant;
  8055. private _worldTransform;
  8056. private _localScaling;
  8057. private _localRotation;
  8058. private _localPosition;
  8059. private _needToDecompose;
  8060. private _needToCompose;
  8061. /** @hidden */
  8062. _linkedTransformNode: Nullable<TransformNode>;
  8063. /** @hidden */
  8064. /** @hidden */
  8065. _matrix: Matrix;
  8066. /**
  8067. * Create a new bone
  8068. * @param name defines the bone name
  8069. * @param skeleton defines the parent skeleton
  8070. * @param parentBone defines the parent (can be null if the bone is the root)
  8071. * @param localMatrix defines the local matrix
  8072. * @param restPose defines the rest pose matrix
  8073. * @param baseMatrix defines the base matrix
  8074. * @param index defines index of the bone in the hiearchy
  8075. */
  8076. constructor(
  8077. /**
  8078. * defines the bone name
  8079. */
  8080. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8081. /**
  8082. * Gets the current object class name.
  8083. * @return the class name
  8084. */
  8085. getClassName(): string;
  8086. /**
  8087. * Gets the parent skeleton
  8088. * @returns a skeleton
  8089. */
  8090. getSkeleton(): Skeleton;
  8091. /**
  8092. * Gets parent bone
  8093. * @returns a bone or null if the bone is the root of the bone hierarchy
  8094. */
  8095. getParent(): Nullable<Bone>;
  8096. /**
  8097. * Returns an array containing the root bones
  8098. * @returns an array containing the root bones
  8099. */
  8100. getChildren(): Array<Bone>;
  8101. /**
  8102. * Sets the parent bone
  8103. * @param parent defines the parent (can be null if the bone is the root)
  8104. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8105. */
  8106. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8107. /**
  8108. * Gets the local matrix
  8109. * @returns a matrix
  8110. */
  8111. getLocalMatrix(): Matrix;
  8112. /**
  8113. * Gets the base matrix (initial matrix which remains unchanged)
  8114. * @returns a matrix
  8115. */
  8116. getBaseMatrix(): Matrix;
  8117. /**
  8118. * Gets the rest pose matrix
  8119. * @returns a matrix
  8120. */
  8121. getRestPose(): Matrix;
  8122. /**
  8123. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8124. */
  8125. getWorldMatrix(): Matrix;
  8126. /**
  8127. * Sets the local matrix to rest pose matrix
  8128. */
  8129. returnToRest(): void;
  8130. /**
  8131. * Gets the inverse of the absolute transform matrix.
  8132. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8133. * @returns a matrix
  8134. */
  8135. getInvertedAbsoluteTransform(): Matrix;
  8136. /**
  8137. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8138. * @returns a matrix
  8139. */
  8140. getAbsoluteTransform(): Matrix;
  8141. /**
  8142. * Links with the given transform node.
  8143. * The local matrix of this bone is copied from the transform node every frame.
  8144. * @param transformNode defines the transform node to link to
  8145. */
  8146. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8147. /** Gets or sets current position (in local space) */
  8148. position: Vector3;
  8149. /** Gets or sets current rotation (in local space) */
  8150. rotation: Vector3;
  8151. /** Gets or sets current rotation quaternion (in local space) */
  8152. rotationQuaternion: Quaternion;
  8153. /** Gets or sets current scaling (in local space) */
  8154. scaling: Vector3;
  8155. /**
  8156. * Gets the animation properties override
  8157. */
  8158. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8159. private _decompose;
  8160. private _compose;
  8161. /**
  8162. * Update the base and local matrices
  8163. * @param matrix defines the new base or local matrix
  8164. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8165. * @param updateLocalMatrix defines if the local matrix should be updated
  8166. */
  8167. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8168. /** @hidden */
  8169. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8170. /**
  8171. * Flag the bone as dirty (Forcing it to update everything)
  8172. */
  8173. markAsDirty(): void;
  8174. private _markAsDirtyAndCompose;
  8175. private _markAsDirtyAndDecompose;
  8176. /**
  8177. * Translate the bone in local or world space
  8178. * @param vec The amount to translate the bone
  8179. * @param space The space that the translation is in
  8180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8181. */
  8182. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8183. /**
  8184. * Set the postion of the bone in local or world space
  8185. * @param position The position to set the bone
  8186. * @param space The space that the position is in
  8187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8188. */
  8189. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8190. /**
  8191. * Set the absolute position of the bone (world space)
  8192. * @param position The position to set the bone
  8193. * @param mesh The mesh that this bone is attached to
  8194. */
  8195. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8196. /**
  8197. * Scale the bone on the x, y and z axes (in local space)
  8198. * @param x The amount to scale the bone on the x axis
  8199. * @param y The amount to scale the bone on the y axis
  8200. * @param z The amount to scale the bone on the z axis
  8201. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8202. */
  8203. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8204. /**
  8205. * Set the bone scaling in local space
  8206. * @param scale defines the scaling vector
  8207. */
  8208. setScale(scale: Vector3): void;
  8209. /**
  8210. * Gets the current scaling in local space
  8211. * @returns the current scaling vector
  8212. */
  8213. getScale(): Vector3;
  8214. /**
  8215. * Gets the current scaling in local space and stores it in a target vector
  8216. * @param result defines the target vector
  8217. */
  8218. getScaleToRef(result: Vector3): void;
  8219. /**
  8220. * Set the yaw, pitch, and roll of the bone in local or world space
  8221. * @param yaw The rotation of the bone on the y axis
  8222. * @param pitch The rotation of the bone on the x axis
  8223. * @param roll The rotation of the bone on the z axis
  8224. * @param space The space that the axes of rotation are in
  8225. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8226. */
  8227. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8228. /**
  8229. * Add a rotation to the bone on an axis in local or world space
  8230. * @param axis The axis to rotate the bone on
  8231. * @param amount The amount to rotate the bone
  8232. * @param space The space that the axis is in
  8233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8234. */
  8235. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8236. /**
  8237. * Set the rotation of the bone to a particular axis angle in local or world space
  8238. * @param axis The axis to rotate the bone on
  8239. * @param angle The angle that the bone should be rotated to
  8240. * @param space The space that the axis is in
  8241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8242. */
  8243. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8244. /**
  8245. * Set the euler rotation of the bone in local of world space
  8246. * @param rotation The euler rotation that the bone should be set to
  8247. * @param space The space that the rotation is in
  8248. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8249. */
  8250. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8251. /**
  8252. * Set the quaternion rotation of the bone in local of world space
  8253. * @param quat The quaternion rotation that the bone should be set to
  8254. * @param space The space that the rotation is in
  8255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8256. */
  8257. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8258. /**
  8259. * Set the rotation matrix of the bone in local of world space
  8260. * @param rotMat The rotation matrix that the bone should be set to
  8261. * @param space The space that the rotation is in
  8262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8263. */
  8264. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8265. private _rotateWithMatrix;
  8266. private _getNegativeRotationToRef;
  8267. /**
  8268. * Get the position of the bone in local or world space
  8269. * @param space The space that the returned position is in
  8270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8271. * @returns The position of the bone
  8272. */
  8273. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8274. /**
  8275. * Copy the position of the bone to a vector3 in local or world space
  8276. * @param space The space that the returned position is in
  8277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8278. * @param result The vector3 to copy the position to
  8279. */
  8280. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8281. /**
  8282. * Get the absolute position of the bone (world space)
  8283. * @param mesh The mesh that this bone is attached to
  8284. * @returns The absolute position of the bone
  8285. */
  8286. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8287. /**
  8288. * Copy the absolute position of the bone (world space) to the result param
  8289. * @param mesh The mesh that this bone is attached to
  8290. * @param result The vector3 to copy the absolute position to
  8291. */
  8292. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8293. /**
  8294. * Compute the absolute transforms of this bone and its children
  8295. */
  8296. computeAbsoluteTransforms(): void;
  8297. /**
  8298. * Get the world direction from an axis that is in the local space of the bone
  8299. * @param localAxis The local direction that is used to compute the world direction
  8300. * @param mesh The mesh that this bone is attached to
  8301. * @returns The world direction
  8302. */
  8303. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8304. /**
  8305. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8306. * @param localAxis The local direction that is used to compute the world direction
  8307. * @param mesh The mesh that this bone is attached to
  8308. * @param result The vector3 that the world direction will be copied to
  8309. */
  8310. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8311. /**
  8312. * Get the euler rotation of the bone in local or world space
  8313. * @param space The space that the rotation should be in
  8314. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8315. * @returns The euler rotation
  8316. */
  8317. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8318. /**
  8319. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8320. * @param space The space that the rotation should be in
  8321. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8322. * @param result The vector3 that the rotation should be copied to
  8323. */
  8324. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8325. /**
  8326. * Get the quaternion rotation of the bone in either local or world space
  8327. * @param space The space that the rotation should be in
  8328. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8329. * @returns The quaternion rotation
  8330. */
  8331. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8332. /**
  8333. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8334. * @param space The space that the rotation should be in
  8335. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8336. * @param result The quaternion that the rotation should be copied to
  8337. */
  8338. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8339. /**
  8340. * Get the rotation matrix of the bone in local or world space
  8341. * @param space The space that the rotation should be in
  8342. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8343. * @returns The rotation matrix
  8344. */
  8345. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8346. /**
  8347. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8348. * @param space The space that the rotation should be in
  8349. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8350. * @param result The quaternion that the rotation should be copied to
  8351. */
  8352. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8353. /**
  8354. * Get the world position of a point that is in the local space of the bone
  8355. * @param position The local position
  8356. * @param mesh The mesh that this bone is attached to
  8357. * @returns The world position
  8358. */
  8359. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8360. /**
  8361. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8362. * @param position The local position
  8363. * @param mesh The mesh that this bone is attached to
  8364. * @param result The vector3 that the world position should be copied to
  8365. */
  8366. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8367. /**
  8368. * Get the local position of a point that is in world space
  8369. * @param position The world position
  8370. * @param mesh The mesh that this bone is attached to
  8371. * @returns The local position
  8372. */
  8373. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8374. /**
  8375. * Get the local position of a point that is in world space and copy it to the result param
  8376. * @param position The world position
  8377. * @param mesh The mesh that this bone is attached to
  8378. * @param result The vector3 that the local position should be copied to
  8379. */
  8380. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8381. }
  8382. }
  8383. declare module "babylonjs/Misc/iInspectable" {
  8384. /**
  8385. * Enum that determines the text-wrapping mode to use.
  8386. */
  8387. export enum InspectableType {
  8388. /**
  8389. * Checkbox for booleans
  8390. */
  8391. Checkbox = 0,
  8392. /**
  8393. * Sliders for numbers
  8394. */
  8395. Slider = 1,
  8396. /**
  8397. * Vector3
  8398. */
  8399. Vector3 = 2,
  8400. /**
  8401. * Quaternions
  8402. */
  8403. Quaternion = 3,
  8404. /**
  8405. * Color3
  8406. */
  8407. Color3 = 4
  8408. }
  8409. /**
  8410. * Interface used to define custom inspectable properties.
  8411. * This interface is used by the inspector to display custom property grids
  8412. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8413. */
  8414. export interface IInspectable {
  8415. /**
  8416. * Gets the label to display
  8417. */
  8418. label: string;
  8419. /**
  8420. * Gets the name of the property to edit
  8421. */
  8422. propertyName: string;
  8423. /**
  8424. * Gets the type of the editor to use
  8425. */
  8426. type: InspectableType;
  8427. /**
  8428. * Gets the minimum value of the property when using in "slider" mode
  8429. */
  8430. min?: number;
  8431. /**
  8432. * Gets the maximum value of the property when using in "slider" mode
  8433. */
  8434. max?: number;
  8435. /**
  8436. * Gets the setp to use when using in "slider" mode
  8437. */
  8438. step?: number;
  8439. }
  8440. }
  8441. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8442. import { Nullable } from "babylonjs/types";
  8443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8444. /**
  8445. * This represents the required contract to create a new type of texture loader.
  8446. */
  8447. export interface IInternalTextureLoader {
  8448. /**
  8449. * Defines wether the loader supports cascade loading the different faces.
  8450. */
  8451. supportCascades: boolean;
  8452. /**
  8453. * This returns if the loader support the current file information.
  8454. * @param extension defines the file extension of the file being loaded
  8455. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8456. * @param fallback defines the fallback internal texture if any
  8457. * @param isBase64 defines whether the texture is encoded as a base64
  8458. * @param isBuffer defines whether the texture data are stored as a buffer
  8459. * @returns true if the loader can load the specified file
  8460. */
  8461. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8462. /**
  8463. * Transform the url before loading if required.
  8464. * @param rootUrl the url of the texture
  8465. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8466. * @returns the transformed texture
  8467. */
  8468. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8469. /**
  8470. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8471. * @param rootUrl the url of the texture
  8472. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8473. * @returns the fallback texture
  8474. */
  8475. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8476. /**
  8477. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8478. * @param data contains the texture data
  8479. * @param texture defines the BabylonJS internal texture
  8480. * @param createPolynomials will be true if polynomials have been requested
  8481. * @param onLoad defines the callback to trigger once the texture is ready
  8482. * @param onError defines the callback to trigger in case of error
  8483. */
  8484. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8485. /**
  8486. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8487. * @param data contains the texture data
  8488. * @param texture defines the BabylonJS internal texture
  8489. * @param callback defines the method to call once ready to upload
  8490. */
  8491. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8492. }
  8493. }
  8494. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8495. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8496. import { Nullable } from "babylonjs/types";
  8497. import { Scene } from "babylonjs/scene";
  8498. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8499. module "babylonjs/Engines/engine" {
  8500. interface Engine {
  8501. /**
  8502. * Creates a depth stencil cube texture.
  8503. * This is only available in WebGL 2.
  8504. * @param size The size of face edge in the cube texture.
  8505. * @param options The options defining the cube texture.
  8506. * @returns The cube texture
  8507. */
  8508. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8509. /**
  8510. * Creates a cube texture
  8511. * @param rootUrl defines the url where the files to load is located
  8512. * @param scene defines the current scene
  8513. * @param files defines the list of files to load (1 per face)
  8514. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8515. * @param onLoad defines an optional callback raised when the texture is loaded
  8516. * @param onError defines an optional callback raised if there is an issue to load the texture
  8517. * @param format defines the format of the data
  8518. * @param forcedExtension defines the extension to use to pick the right loader
  8519. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8520. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8521. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8522. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8523. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8524. * @returns the cube texture as an InternalTexture
  8525. */
  8526. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8527. /**
  8528. * Creates a cube texture
  8529. * @param rootUrl defines the url where the files to load is located
  8530. * @param scene defines the current scene
  8531. * @param files defines the list of files to load (1 per face)
  8532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8533. * @param onLoad defines an optional callback raised when the texture is loaded
  8534. * @param onError defines an optional callback raised if there is an issue to load the texture
  8535. * @param format defines the format of the data
  8536. * @param forcedExtension defines the extension to use to pick the right loader
  8537. * @returns the cube texture as an InternalTexture
  8538. */
  8539. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  8540. /**
  8541. * Creates a cube texture
  8542. * @param rootUrl defines the url where the files to load is located
  8543. * @param scene defines the current scene
  8544. * @param files defines the list of files to load (1 per face)
  8545. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8546. * @param onLoad defines an optional callback raised when the texture is loaded
  8547. * @param onError defines an optional callback raised if there is an issue to load the texture
  8548. * @param format defines the format of the data
  8549. * @param forcedExtension defines the extension to use to pick the right loader
  8550. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8551. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8552. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8553. * @returns the cube texture as an InternalTexture
  8554. */
  8555. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8556. /** @hidden */
  8557. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8558. /** @hidden */
  8559. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8560. /** @hidden */
  8561. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8562. /** @hidden */
  8563. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8564. }
  8565. }
  8566. }
  8567. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8568. import { Nullable } from "babylonjs/types";
  8569. import { Scene } from "babylonjs/scene";
  8570. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8572. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8573. /**
  8574. * Class for creating a cube texture
  8575. */
  8576. export class CubeTexture extends BaseTexture {
  8577. private _delayedOnLoad;
  8578. /**
  8579. * The url of the texture
  8580. */
  8581. url: string;
  8582. /**
  8583. * Gets or sets the center of the bounding box associated with the cube texture.
  8584. * It must define where the camera used to render the texture was set
  8585. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8586. */
  8587. boundingBoxPosition: Vector3;
  8588. private _boundingBoxSize;
  8589. /**
  8590. * Gets or sets the size of the bounding box associated with the cube texture
  8591. * When defined, the cubemap will switch to local mode
  8592. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8593. * @example https://www.babylonjs-playground.com/#RNASML
  8594. */
  8595. /**
  8596. * Returns the bounding box size
  8597. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8598. */
  8599. boundingBoxSize: Vector3;
  8600. protected _rotationY: number;
  8601. /**
  8602. * Sets texture matrix rotation angle around Y axis in radians.
  8603. */
  8604. /**
  8605. * Gets texture matrix rotation angle around Y axis radians.
  8606. */
  8607. rotationY: number;
  8608. /**
  8609. * Are mip maps generated for this texture or not.
  8610. */
  8611. readonly noMipmap: boolean;
  8612. private _noMipmap;
  8613. private _files;
  8614. private _extensions;
  8615. private _textureMatrix;
  8616. private _format;
  8617. private _createPolynomials;
  8618. /** @hidden */
  8619. _prefiltered: boolean;
  8620. /**
  8621. * Creates a cube texture from an array of image urls
  8622. * @param files defines an array of image urls
  8623. * @param scene defines the hosting scene
  8624. * @param noMipmap specifies if mip maps are not used
  8625. * @returns a cube texture
  8626. */
  8627. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8628. /**
  8629. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8630. * @param url defines the url of the prefiltered texture
  8631. * @param scene defines the scene the texture is attached to
  8632. * @param forcedExtension defines the extension of the file if different from the url
  8633. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8634. * @return the prefiltered texture
  8635. */
  8636. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8637. /**
  8638. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8639. * as prefiltered data.
  8640. * @param rootUrl defines the url of the texture or the root name of the six images
  8641. * @param scene defines the scene the texture is attached to
  8642. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8643. * @param noMipmap defines if mipmaps should be created or not
  8644. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8645. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8646. * @param onError defines a callback triggered in case of error during load
  8647. * @param format defines the internal format to use for the texture once loaded
  8648. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8649. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8650. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8651. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8652. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8653. * @return the cube texture
  8654. */
  8655. 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);
  8656. /**
  8657. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8658. */
  8659. readonly isPrefiltered: boolean;
  8660. /**
  8661. * Get the current class name of the texture useful for serialization or dynamic coding.
  8662. * @returns "CubeTexture"
  8663. */
  8664. getClassName(): string;
  8665. /**
  8666. * Update the url (and optional buffer) of this texture if url was null during construction.
  8667. * @param url the url of the texture
  8668. * @param forcedExtension defines the extension to use
  8669. * @param onLoad callback called when the texture is loaded (defaults to null)
  8670. */
  8671. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8672. /**
  8673. * Delays loading of the cube texture
  8674. * @param forcedExtension defines the extension to use
  8675. */
  8676. delayLoad(forcedExtension?: string): void;
  8677. /**
  8678. * Returns the reflection texture matrix
  8679. * @returns the reflection texture matrix
  8680. */
  8681. getReflectionTextureMatrix(): Matrix;
  8682. /**
  8683. * Sets the reflection texture matrix
  8684. * @param value Reflection texture matrix
  8685. */
  8686. setReflectionTextureMatrix(value: Matrix): void;
  8687. /**
  8688. * Parses text to create a cube texture
  8689. * @param parsedTexture define the serialized text to read from
  8690. * @param scene defines the hosting scene
  8691. * @param rootUrl defines the root url of the cube texture
  8692. * @returns a cube texture
  8693. */
  8694. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8695. /**
  8696. * Makes a clone, or deep copy, of the cube texture
  8697. * @returns a new cube texture
  8698. */
  8699. clone(): CubeTexture;
  8700. }
  8701. }
  8702. declare module "babylonjs/Shaders/postprocess.vertex" {
  8703. /** @hidden */
  8704. export var postprocessVertexShader: {
  8705. name: string;
  8706. shader: string;
  8707. };
  8708. }
  8709. declare module "babylonjs/Cameras/targetCamera" {
  8710. import { Nullable } from "babylonjs/types";
  8711. import { Camera } from "babylonjs/Cameras/camera";
  8712. import { Scene } from "babylonjs/scene";
  8713. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8714. /**
  8715. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8716. * This is the base of the follow, arc rotate cameras and Free camera
  8717. * @see http://doc.babylonjs.com/features/cameras
  8718. */
  8719. export class TargetCamera extends Camera {
  8720. private static _RigCamTransformMatrix;
  8721. private static _TargetTransformMatrix;
  8722. private static _TargetFocalPoint;
  8723. /**
  8724. * Define the current direction the camera is moving to
  8725. */
  8726. cameraDirection: Vector3;
  8727. /**
  8728. * Define the current rotation the camera is rotating to
  8729. */
  8730. cameraRotation: Vector2;
  8731. /**
  8732. * When set, the up vector of the camera will be updated by the rotation of the camera
  8733. */
  8734. updateUpVectorFromRotation: boolean;
  8735. private _tmpQuaternion;
  8736. /**
  8737. * Define the current rotation of the camera
  8738. */
  8739. rotation: Vector3;
  8740. /**
  8741. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8742. */
  8743. rotationQuaternion: Quaternion;
  8744. /**
  8745. * Define the current speed of the camera
  8746. */
  8747. speed: number;
  8748. /**
  8749. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8750. * around all axis.
  8751. */
  8752. noRotationConstraint: boolean;
  8753. /**
  8754. * Define the current target of the camera as an object or a position.
  8755. */
  8756. lockedTarget: any;
  8757. /** @hidden */
  8758. _currentTarget: Vector3;
  8759. /** @hidden */
  8760. _initialFocalDistance: number;
  8761. /** @hidden */
  8762. _viewMatrix: Matrix;
  8763. /** @hidden */
  8764. _camMatrix: Matrix;
  8765. /** @hidden */
  8766. _cameraTransformMatrix: Matrix;
  8767. /** @hidden */
  8768. _cameraRotationMatrix: Matrix;
  8769. /** @hidden */
  8770. _referencePoint: Vector3;
  8771. /** @hidden */
  8772. _transformedReferencePoint: Vector3;
  8773. protected _globalCurrentTarget: Vector3;
  8774. protected _globalCurrentUpVector: Vector3;
  8775. /** @hidden */
  8776. _reset: () => void;
  8777. private _defaultUp;
  8778. /**
  8779. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8780. * This is the base of the follow, arc rotate cameras and Free camera
  8781. * @see http://doc.babylonjs.com/features/cameras
  8782. * @param name Defines the name of the camera in the scene
  8783. * @param position Defines the start position of the camera in the scene
  8784. * @param scene Defines the scene the camera belongs to
  8785. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8786. */
  8787. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8788. /**
  8789. * Gets the position in front of the camera at a given distance.
  8790. * @param distance The distance from the camera we want the position to be
  8791. * @returns the position
  8792. */
  8793. getFrontPosition(distance: number): Vector3;
  8794. /** @hidden */
  8795. _getLockedTargetPosition(): Nullable<Vector3>;
  8796. private _storedPosition;
  8797. private _storedRotation;
  8798. private _storedRotationQuaternion;
  8799. /**
  8800. * Store current camera state of the camera (fov, position, rotation, etc..)
  8801. * @returns the camera
  8802. */
  8803. storeState(): Camera;
  8804. /**
  8805. * Restored camera state. You must call storeState() first
  8806. * @returns whether it was successful or not
  8807. * @hidden
  8808. */
  8809. _restoreStateValues(): boolean;
  8810. /** @hidden */
  8811. _initCache(): void;
  8812. /** @hidden */
  8813. _updateCache(ignoreParentClass?: boolean): void;
  8814. /** @hidden */
  8815. _isSynchronizedViewMatrix(): boolean;
  8816. /** @hidden */
  8817. _computeLocalCameraSpeed(): number;
  8818. /**
  8819. * Defines the target the camera should look at.
  8820. * This will automatically adapt alpha beta and radius to fit within the new target.
  8821. * @param target Defines the new target as a Vector or a mesh
  8822. */
  8823. setTarget(target: Vector3): void;
  8824. /**
  8825. * Return the current target position of the camera. This value is expressed in local space.
  8826. * @returns the target position
  8827. */
  8828. getTarget(): Vector3;
  8829. /** @hidden */
  8830. _decideIfNeedsToMove(): boolean;
  8831. /** @hidden */
  8832. _updatePosition(): void;
  8833. /** @hidden */
  8834. _checkInputs(): void;
  8835. protected _updateCameraRotationMatrix(): void;
  8836. /**
  8837. * 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)
  8838. * @returns the current camera
  8839. */
  8840. private _rotateUpVectorWithCameraRotationMatrix;
  8841. private _cachedRotationZ;
  8842. private _cachedQuaternionRotationZ;
  8843. /** @hidden */
  8844. _getViewMatrix(): Matrix;
  8845. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8846. /**
  8847. * @hidden
  8848. */
  8849. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8850. /**
  8851. * @hidden
  8852. */
  8853. _updateRigCameras(): void;
  8854. private _getRigCamPositionAndTarget;
  8855. /**
  8856. * Gets the current object class name.
  8857. * @return the class name
  8858. */
  8859. getClassName(): string;
  8860. }
  8861. }
  8862. declare module "babylonjs/Cameras/cameraInputsManager" {
  8863. import { Nullable } from "babylonjs/types";
  8864. import { Camera } from "babylonjs/Cameras/camera";
  8865. /**
  8866. * @ignore
  8867. * This is a list of all the different input types that are available in the application.
  8868. * Fo instance: ArcRotateCameraGamepadInput...
  8869. */
  8870. export var CameraInputTypes: {};
  8871. /**
  8872. * This is the contract to implement in order to create a new input class.
  8873. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8874. */
  8875. export interface ICameraInput<TCamera extends Camera> {
  8876. /**
  8877. * Defines the camera the input is attached to.
  8878. */
  8879. camera: Nullable<TCamera>;
  8880. /**
  8881. * Gets the class name of the current intput.
  8882. * @returns the class name
  8883. */
  8884. getClassName(): string;
  8885. /**
  8886. * Get the friendly name associated with the input class.
  8887. * @returns the input friendly name
  8888. */
  8889. getSimpleName(): string;
  8890. /**
  8891. * Attach the input controls to a specific dom element to get the input from.
  8892. * @param element Defines the element the controls should be listened from
  8893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8894. */
  8895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8896. /**
  8897. * Detach the current controls from the specified dom element.
  8898. * @param element Defines the element to stop listening the inputs from
  8899. */
  8900. detachControl(element: Nullable<HTMLElement>): void;
  8901. /**
  8902. * Update the current camera state depending on the inputs that have been used this frame.
  8903. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8904. */
  8905. checkInputs?: () => void;
  8906. }
  8907. /**
  8908. * Represents a map of input types to input instance or input index to input instance.
  8909. */
  8910. export interface CameraInputsMap<TCamera extends Camera> {
  8911. /**
  8912. * Accessor to the input by input type.
  8913. */
  8914. [name: string]: ICameraInput<TCamera>;
  8915. /**
  8916. * Accessor to the input by input index.
  8917. */
  8918. [idx: number]: ICameraInput<TCamera>;
  8919. }
  8920. /**
  8921. * This represents the input manager used within a camera.
  8922. * It helps dealing with all the different kind of input attached to a camera.
  8923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8924. */
  8925. export class CameraInputsManager<TCamera extends Camera> {
  8926. /**
  8927. * Defines the list of inputs attahed to the camera.
  8928. */
  8929. attached: CameraInputsMap<TCamera>;
  8930. /**
  8931. * Defines the dom element the camera is collecting inputs from.
  8932. * This is null if the controls have not been attached.
  8933. */
  8934. attachedElement: Nullable<HTMLElement>;
  8935. /**
  8936. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8937. */
  8938. noPreventDefault: boolean;
  8939. /**
  8940. * Defined the camera the input manager belongs to.
  8941. */
  8942. camera: TCamera;
  8943. /**
  8944. * Update the current camera state depending on the inputs that have been used this frame.
  8945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8946. */
  8947. checkInputs: () => void;
  8948. /**
  8949. * Instantiate a new Camera Input Manager.
  8950. * @param camera Defines the camera the input manager blongs to
  8951. */
  8952. constructor(camera: TCamera);
  8953. /**
  8954. * Add an input method to a camera
  8955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8956. * @param input camera input method
  8957. */
  8958. add(input: ICameraInput<TCamera>): void;
  8959. /**
  8960. * Remove a specific input method from a camera
  8961. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8962. * @param inputToRemove camera input method
  8963. */
  8964. remove(inputToRemove: ICameraInput<TCamera>): void;
  8965. /**
  8966. * Remove a specific input type from a camera
  8967. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8968. * @param inputType the type of the input to remove
  8969. */
  8970. removeByType(inputType: string): void;
  8971. private _addCheckInputs;
  8972. /**
  8973. * Attach the input controls to the currently attached dom element to listen the events from.
  8974. * @param input Defines the input to attach
  8975. */
  8976. attachInput(input: ICameraInput<TCamera>): void;
  8977. /**
  8978. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8979. * @param element Defines the dom element to collect the events from
  8980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8981. */
  8982. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8983. /**
  8984. * Detach the current manager inputs controls from a specific dom element.
  8985. * @param element Defines the dom element to collect the events from
  8986. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8987. */
  8988. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8989. /**
  8990. * Rebuild the dynamic inputCheck function from the current list of
  8991. * defined inputs in the manager.
  8992. */
  8993. rebuildInputCheck(): void;
  8994. /**
  8995. * Remove all attached input methods from a camera
  8996. */
  8997. clear(): void;
  8998. /**
  8999. * Serialize the current input manager attached to a camera.
  9000. * This ensures than once parsed,
  9001. * the input associated to the camera will be identical to the current ones
  9002. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9003. */
  9004. serialize(serializedCamera: any): void;
  9005. /**
  9006. * Parses an input manager serialized JSON to restore the previous list of inputs
  9007. * and states associated to a camera.
  9008. * @param parsedCamera Defines the JSON to parse
  9009. */
  9010. parse(parsedCamera: any): void;
  9011. }
  9012. }
  9013. declare module "babylonjs/Events/keyboardEvents" {
  9014. /**
  9015. * Gather the list of keyboard event types as constants.
  9016. */
  9017. export class KeyboardEventTypes {
  9018. /**
  9019. * The keydown event is fired when a key becomes active (pressed).
  9020. */
  9021. static readonly KEYDOWN: number;
  9022. /**
  9023. * The keyup event is fired when a key has been released.
  9024. */
  9025. static readonly KEYUP: number;
  9026. }
  9027. /**
  9028. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9029. */
  9030. export class KeyboardInfo {
  9031. /**
  9032. * Defines the type of event (KeyboardEventTypes)
  9033. */
  9034. type: number;
  9035. /**
  9036. * Defines the related dom event
  9037. */
  9038. event: KeyboardEvent;
  9039. /**
  9040. * Instantiates a new keyboard info.
  9041. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9042. * @param type Defines the type of event (KeyboardEventTypes)
  9043. * @param event Defines the related dom event
  9044. */
  9045. constructor(
  9046. /**
  9047. * Defines the type of event (KeyboardEventTypes)
  9048. */
  9049. type: number,
  9050. /**
  9051. * Defines the related dom event
  9052. */
  9053. event: KeyboardEvent);
  9054. }
  9055. /**
  9056. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9057. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9058. */
  9059. export class KeyboardInfoPre extends KeyboardInfo {
  9060. /**
  9061. * Defines the type of event (KeyboardEventTypes)
  9062. */
  9063. type: number;
  9064. /**
  9065. * Defines the related dom event
  9066. */
  9067. event: KeyboardEvent;
  9068. /**
  9069. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9070. */
  9071. skipOnPointerObservable: boolean;
  9072. /**
  9073. * Instantiates a new keyboard pre info.
  9074. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9075. * @param type Defines the type of event (KeyboardEventTypes)
  9076. * @param event Defines the related dom event
  9077. */
  9078. constructor(
  9079. /**
  9080. * Defines the type of event (KeyboardEventTypes)
  9081. */
  9082. type: number,
  9083. /**
  9084. * Defines the related dom event
  9085. */
  9086. event: KeyboardEvent);
  9087. }
  9088. }
  9089. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9090. import { Nullable } from "babylonjs/types";
  9091. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9092. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9093. /**
  9094. * Manage the keyboard inputs to control the movement of a free camera.
  9095. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9096. */
  9097. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9098. /**
  9099. * Defines the camera the input is attached to.
  9100. */
  9101. camera: FreeCamera;
  9102. /**
  9103. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9104. */
  9105. keysUp: number[];
  9106. /**
  9107. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9108. */
  9109. keysDown: number[];
  9110. /**
  9111. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9112. */
  9113. keysLeft: number[];
  9114. /**
  9115. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9116. */
  9117. keysRight: number[];
  9118. private _keys;
  9119. private _onCanvasBlurObserver;
  9120. private _onKeyboardObserver;
  9121. private _engine;
  9122. private _scene;
  9123. /**
  9124. * Attach the input controls to a specific dom element to get the input from.
  9125. * @param element Defines the element the controls should be listened from
  9126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9127. */
  9128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9129. /**
  9130. * Detach the current controls from the specified dom element.
  9131. * @param element Defines the element to stop listening the inputs from
  9132. */
  9133. detachControl(element: Nullable<HTMLElement>): void;
  9134. /**
  9135. * Update the current camera state depending on the inputs that have been used this frame.
  9136. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9137. */
  9138. checkInputs(): void;
  9139. /**
  9140. * Gets the class name of the current intput.
  9141. * @returns the class name
  9142. */
  9143. getClassName(): string;
  9144. /** @hidden */
  9145. _onLostFocus(): void;
  9146. /**
  9147. * Get the friendly name associated with the input class.
  9148. * @returns the input friendly name
  9149. */
  9150. getSimpleName(): string;
  9151. }
  9152. }
  9153. declare module "babylonjs/Lights/shadowLight" {
  9154. import { Camera } from "babylonjs/Cameras/camera";
  9155. import { Scene } from "babylonjs/scene";
  9156. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9158. import { Light } from "babylonjs/Lights/light";
  9159. /**
  9160. * Interface describing all the common properties and methods a shadow light needs to implement.
  9161. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9162. * as well as binding the different shadow properties to the effects.
  9163. */
  9164. export interface IShadowLight extends Light {
  9165. /**
  9166. * The light id in the scene (used in scene.findLighById for instance)
  9167. */
  9168. id: string;
  9169. /**
  9170. * The position the shdow will be casted from.
  9171. */
  9172. position: Vector3;
  9173. /**
  9174. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9175. */
  9176. direction: Vector3;
  9177. /**
  9178. * The transformed position. Position of the light in world space taking parenting in account.
  9179. */
  9180. transformedPosition: Vector3;
  9181. /**
  9182. * The transformed direction. Direction of the light in world space taking parenting in account.
  9183. */
  9184. transformedDirection: Vector3;
  9185. /**
  9186. * The friendly name of the light in the scene.
  9187. */
  9188. name: string;
  9189. /**
  9190. * Defines the shadow projection clipping minimum z value.
  9191. */
  9192. shadowMinZ: number;
  9193. /**
  9194. * Defines the shadow projection clipping maximum z value.
  9195. */
  9196. shadowMaxZ: number;
  9197. /**
  9198. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9199. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9200. */
  9201. computeTransformedInformation(): boolean;
  9202. /**
  9203. * Gets the scene the light belongs to.
  9204. * @returns The scene
  9205. */
  9206. getScene(): Scene;
  9207. /**
  9208. * Callback defining a custom Projection Matrix Builder.
  9209. * This can be used to override the default projection matrix computation.
  9210. */
  9211. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9212. /**
  9213. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9214. * @param matrix The materix to updated with the projection information
  9215. * @param viewMatrix The transform matrix of the light
  9216. * @param renderList The list of mesh to render in the map
  9217. * @returns The current light
  9218. */
  9219. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9220. /**
  9221. * Gets the current depth scale used in ESM.
  9222. * @returns The scale
  9223. */
  9224. getDepthScale(): number;
  9225. /**
  9226. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9227. * @returns true if a cube texture needs to be use
  9228. */
  9229. needCube(): boolean;
  9230. /**
  9231. * Detects if the projection matrix requires to be recomputed this frame.
  9232. * @returns true if it requires to be recomputed otherwise, false.
  9233. */
  9234. needProjectionMatrixCompute(): boolean;
  9235. /**
  9236. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9237. */
  9238. forceProjectionMatrixCompute(): void;
  9239. /**
  9240. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9241. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9242. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9243. */
  9244. getShadowDirection(faceIndex?: number): Vector3;
  9245. /**
  9246. * Gets the minZ used for shadow according to both the scene and the light.
  9247. * @param activeCamera The camera we are returning the min for
  9248. * @returns the depth min z
  9249. */
  9250. getDepthMinZ(activeCamera: Camera): number;
  9251. /**
  9252. * Gets the maxZ used for shadow according to both the scene and the light.
  9253. * @param activeCamera The camera we are returning the max for
  9254. * @returns the depth max z
  9255. */
  9256. getDepthMaxZ(activeCamera: Camera): number;
  9257. }
  9258. /**
  9259. * Base implementation IShadowLight
  9260. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9261. */
  9262. export abstract class ShadowLight extends Light implements IShadowLight {
  9263. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9264. protected _position: Vector3;
  9265. protected _setPosition(value: Vector3): void;
  9266. /**
  9267. * Sets the position the shadow will be casted from. Also use as the light position for both
  9268. * point and spot lights.
  9269. */
  9270. /**
  9271. * Sets the position the shadow will be casted from. Also use as the light position for both
  9272. * point and spot lights.
  9273. */
  9274. position: Vector3;
  9275. protected _direction: Vector3;
  9276. protected _setDirection(value: Vector3): void;
  9277. /**
  9278. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9279. * Also use as the light direction on spot and directional lights.
  9280. */
  9281. /**
  9282. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9283. * Also use as the light direction on spot and directional lights.
  9284. */
  9285. direction: Vector3;
  9286. private _shadowMinZ;
  9287. /**
  9288. * Gets the shadow projection clipping minimum z value.
  9289. */
  9290. /**
  9291. * Sets the shadow projection clipping minimum z value.
  9292. */
  9293. shadowMinZ: number;
  9294. private _shadowMaxZ;
  9295. /**
  9296. * Sets the shadow projection clipping maximum z value.
  9297. */
  9298. /**
  9299. * Gets the shadow projection clipping maximum z value.
  9300. */
  9301. shadowMaxZ: number;
  9302. /**
  9303. * Callback defining a custom Projection Matrix Builder.
  9304. * This can be used to override the default projection matrix computation.
  9305. */
  9306. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9307. /**
  9308. * The transformed position. Position of the light in world space taking parenting in account.
  9309. */
  9310. transformedPosition: Vector3;
  9311. /**
  9312. * The transformed direction. Direction of the light in world space taking parenting in account.
  9313. */
  9314. transformedDirection: Vector3;
  9315. private _needProjectionMatrixCompute;
  9316. /**
  9317. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9318. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9319. */
  9320. computeTransformedInformation(): boolean;
  9321. /**
  9322. * Return the depth scale used for the shadow map.
  9323. * @returns the depth scale.
  9324. */
  9325. getDepthScale(): number;
  9326. /**
  9327. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9328. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9329. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9330. */
  9331. getShadowDirection(faceIndex?: number): Vector3;
  9332. /**
  9333. * Returns the ShadowLight absolute position in the World.
  9334. * @returns the position vector in world space
  9335. */
  9336. getAbsolutePosition(): Vector3;
  9337. /**
  9338. * Sets the ShadowLight direction toward the passed target.
  9339. * @param target The point to target in local space
  9340. * @returns the updated ShadowLight direction
  9341. */
  9342. setDirectionToTarget(target: Vector3): Vector3;
  9343. /**
  9344. * Returns the light rotation in euler definition.
  9345. * @returns the x y z rotation in local space.
  9346. */
  9347. getRotation(): Vector3;
  9348. /**
  9349. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9350. * @returns true if a cube texture needs to be use
  9351. */
  9352. needCube(): boolean;
  9353. /**
  9354. * Detects if the projection matrix requires to be recomputed this frame.
  9355. * @returns true if it requires to be recomputed otherwise, false.
  9356. */
  9357. needProjectionMatrixCompute(): boolean;
  9358. /**
  9359. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9360. */
  9361. forceProjectionMatrixCompute(): void;
  9362. /** @hidden */
  9363. _initCache(): void;
  9364. /** @hidden */
  9365. _isSynchronized(): boolean;
  9366. /**
  9367. * Computes the world matrix of the node
  9368. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9369. * @returns the world matrix
  9370. */
  9371. computeWorldMatrix(force?: boolean): Matrix;
  9372. /**
  9373. * Gets the minZ used for shadow according to both the scene and the light.
  9374. * @param activeCamera The camera we are returning the min for
  9375. * @returns the depth min z
  9376. */
  9377. getDepthMinZ(activeCamera: Camera): number;
  9378. /**
  9379. * Gets the maxZ used for shadow according to both the scene and the light.
  9380. * @param activeCamera The camera we are returning the max for
  9381. * @returns the depth max z
  9382. */
  9383. getDepthMaxZ(activeCamera: Camera): number;
  9384. /**
  9385. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9386. * @param matrix The materix to updated with the projection information
  9387. * @param viewMatrix The transform matrix of the light
  9388. * @param renderList The list of mesh to render in the map
  9389. * @returns The current light
  9390. */
  9391. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9392. }
  9393. }
  9394. declare module "babylonjs/Materials/materialHelper" {
  9395. import { Nullable } from "babylonjs/types";
  9396. import { Scene } from "babylonjs/scene";
  9397. import { Engine } from "babylonjs/Engines/engine";
  9398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9399. import { Light } from "babylonjs/Lights/light";
  9400. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9401. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9403. /**
  9404. * "Static Class" containing the most commonly used helper while dealing with material for
  9405. * rendering purpose.
  9406. *
  9407. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9408. *
  9409. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9410. */
  9411. export class MaterialHelper {
  9412. /**
  9413. * Bind the current view position to an effect.
  9414. * @param effect The effect to be bound
  9415. * @param scene The scene the eyes position is used from
  9416. */
  9417. static BindEyePosition(effect: Effect, scene: Scene): void;
  9418. /**
  9419. * Helps preparing the defines values about the UVs in used in the effect.
  9420. * UVs are shared as much as we can accross channels in the shaders.
  9421. * @param texture The texture we are preparing the UVs for
  9422. * @param defines The defines to update
  9423. * @param key The channel key "diffuse", "specular"... used in the shader
  9424. */
  9425. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9426. /**
  9427. * Binds a texture matrix value to its corrsponding uniform
  9428. * @param texture The texture to bind the matrix for
  9429. * @param uniformBuffer The uniform buffer receivin the data
  9430. * @param key The channel key "diffuse", "specular"... used in the shader
  9431. */
  9432. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9433. /**
  9434. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9435. * @param mesh defines the current mesh
  9436. * @param scene defines the current scene
  9437. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9438. * @param pointsCloud defines if point cloud rendering has to be turned on
  9439. * @param fogEnabled defines if fog has to be turned on
  9440. * @param alphaTest defines if alpha testing has to be turned on
  9441. * @param defines defines the current list of defines
  9442. */
  9443. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9444. /**
  9445. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9446. * @param scene defines the current scene
  9447. * @param engine defines the current engine
  9448. * @param defines specifies the list of active defines
  9449. * @param useInstances defines if instances have to be turned on
  9450. * @param useClipPlane defines if clip plane have to be turned on
  9451. */
  9452. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9453. /**
  9454. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9455. * @param mesh The mesh containing the geometry data we will draw
  9456. * @param defines The defines to update
  9457. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9458. * @param useBones Precise whether bones should be used or not (override mesh info)
  9459. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9460. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9461. * @returns false if defines are considered not dirty and have not been checked
  9462. */
  9463. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9464. /**
  9465. * Prepares the defines related to multiview
  9466. * @param scene The scene we are intending to draw
  9467. * @param defines The defines to update
  9468. */
  9469. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9470. /**
  9471. * Prepares the defines related to the light information passed in parameter
  9472. * @param scene The scene we are intending to draw
  9473. * @param mesh The mesh the effect is compiling for
  9474. * @param defines The defines to update
  9475. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9476. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9477. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9478. * @returns true if normals will be required for the rest of the effect
  9479. */
  9480. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9481. /**
  9482. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9483. * that won t be acctive due to defines being turned off.
  9484. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9485. * @param samplersList The samplers list
  9486. * @param defines The defines helping in the list generation
  9487. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9488. */
  9489. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9490. /**
  9491. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9492. * @param defines The defines to update while falling back
  9493. * @param fallbacks The authorized effect fallbacks
  9494. * @param maxSimultaneousLights The maximum number of lights allowed
  9495. * @param rank the current rank of the Effect
  9496. * @returns The newly affected rank
  9497. */
  9498. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9499. /**
  9500. * Prepares the list of attributes required for morph targets according to the effect defines.
  9501. * @param attribs The current list of supported attribs
  9502. * @param mesh The mesh to prepare the morph targets attributes for
  9503. * @param defines The current Defines of the effect
  9504. */
  9505. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9506. /**
  9507. * Prepares the list of attributes required for bones according to the effect defines.
  9508. * @param attribs The current list of supported attribs
  9509. * @param mesh The mesh to prepare the bones attributes for
  9510. * @param defines The current Defines of the effect
  9511. * @param fallbacks The current efffect fallback strategy
  9512. */
  9513. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9514. /**
  9515. * Prepares the list of attributes required for instances according to the effect defines.
  9516. * @param attribs The current list of supported attribs
  9517. * @param defines The current Defines of the effect
  9518. */
  9519. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9520. /**
  9521. * Binds the light shadow information to the effect for the given mesh.
  9522. * @param light The light containing the generator
  9523. * @param scene The scene the lights belongs to
  9524. * @param mesh The mesh we are binding the information to render
  9525. * @param lightIndex The light index in the effect used to render the mesh
  9526. * @param effect The effect we are binding the data to
  9527. */
  9528. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9529. /**
  9530. * Binds the light information to the effect.
  9531. * @param light The light containing the generator
  9532. * @param effect The effect we are binding the data to
  9533. * @param lightIndex The light index in the effect used to render
  9534. */
  9535. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9536. /**
  9537. * Binds the lights information from the scene to the effect for the given mesh.
  9538. * @param scene The scene the lights belongs to
  9539. * @param mesh The mesh we are binding the information to render
  9540. * @param effect The effect we are binding the data to
  9541. * @param defines The generated defines for the effect
  9542. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9543. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9544. */
  9545. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9546. private static _tempFogColor;
  9547. /**
  9548. * Binds the fog information from the scene to the effect for the given mesh.
  9549. * @param scene The scene the lights belongs to
  9550. * @param mesh The mesh we are binding the information to render
  9551. * @param effect The effect we are binding the data to
  9552. * @param linearSpace Defines if the fog effect is applied in linear space
  9553. */
  9554. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9555. /**
  9556. * Binds the bones information from the mesh to the effect.
  9557. * @param mesh The mesh we are binding the information to render
  9558. * @param effect The effect we are binding the data to
  9559. */
  9560. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9561. /**
  9562. * Binds the morph targets information from the mesh to the effect.
  9563. * @param abstractMesh The mesh we are binding the information to render
  9564. * @param effect The effect we are binding the data to
  9565. */
  9566. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9567. /**
  9568. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9569. * @param defines The generated defines used in the effect
  9570. * @param effect The effect we are binding the data to
  9571. * @param scene The scene we are willing to render with logarithmic scale for
  9572. */
  9573. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9574. /**
  9575. * Binds the clip plane information from the scene to the effect.
  9576. * @param scene The scene the clip plane information are extracted from
  9577. * @param effect The effect we are binding the data to
  9578. */
  9579. static BindClipPlane(effect: Effect, scene: Scene): void;
  9580. }
  9581. }
  9582. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9583. /** @hidden */
  9584. export var kernelBlurVaryingDeclaration: {
  9585. name: string;
  9586. shader: string;
  9587. };
  9588. }
  9589. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9590. /** @hidden */
  9591. export var kernelBlurFragment: {
  9592. name: string;
  9593. shader: string;
  9594. };
  9595. }
  9596. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9597. /** @hidden */
  9598. export var kernelBlurFragment2: {
  9599. name: string;
  9600. shader: string;
  9601. };
  9602. }
  9603. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9604. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9605. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9606. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9607. /** @hidden */
  9608. export var kernelBlurPixelShader: {
  9609. name: string;
  9610. shader: string;
  9611. };
  9612. }
  9613. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9614. /** @hidden */
  9615. export var kernelBlurVertex: {
  9616. name: string;
  9617. shader: string;
  9618. };
  9619. }
  9620. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9621. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9622. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9623. /** @hidden */
  9624. export var kernelBlurVertexShader: {
  9625. name: string;
  9626. shader: string;
  9627. };
  9628. }
  9629. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9630. import { Vector2 } from "babylonjs/Maths/math";
  9631. import { Nullable } from "babylonjs/types";
  9632. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9633. import { Camera } from "babylonjs/Cameras/camera";
  9634. import { Effect } from "babylonjs/Materials/effect";
  9635. import { Engine } from "babylonjs/Engines/engine";
  9636. import "babylonjs/Shaders/kernelBlur.fragment";
  9637. import "babylonjs/Shaders/kernelBlur.vertex";
  9638. /**
  9639. * The Blur Post Process which blurs an image based on a kernel and direction.
  9640. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9641. */
  9642. export class BlurPostProcess extends PostProcess {
  9643. /** The direction in which to blur the image. */
  9644. direction: Vector2;
  9645. private blockCompilation;
  9646. protected _kernel: number;
  9647. protected _idealKernel: number;
  9648. protected _packedFloat: boolean;
  9649. private _staticDefines;
  9650. /**
  9651. * Sets the length in pixels of the blur sample region
  9652. */
  9653. /**
  9654. * Gets the length in pixels of the blur sample region
  9655. */
  9656. kernel: number;
  9657. /**
  9658. * Sets wether or not the blur needs to unpack/repack floats
  9659. */
  9660. /**
  9661. * Gets wether or not the blur is unpacking/repacking floats
  9662. */
  9663. packedFloat: boolean;
  9664. /**
  9665. * Creates a new instance BlurPostProcess
  9666. * @param name The name of the effect.
  9667. * @param direction The direction in which to blur the image.
  9668. * @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.
  9669. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9670. * @param camera The camera to apply the render pass to.
  9671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9672. * @param engine The engine which the post process will be applied. (default: current engine)
  9673. * @param reusable If the post process can be reused on the same frame. (default: false)
  9674. * @param textureType Type of textures used when performing the post process. (default: 0)
  9675. * @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)
  9676. */
  9677. constructor(name: string,
  9678. /** The direction in which to blur the image. */
  9679. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9680. /**
  9681. * Updates the effect with the current post process compile time values and recompiles the shader.
  9682. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9683. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9684. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9685. * @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
  9686. * @param onCompiled Called when the shader has been compiled.
  9687. * @param onError Called if there is an error when compiling a shader.
  9688. */
  9689. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9690. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9691. /**
  9692. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9693. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9694. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9695. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9696. * The gaps between physical kernels are compensated for in the weighting of the samples
  9697. * @param idealKernel Ideal blur kernel.
  9698. * @return Nearest best kernel.
  9699. */
  9700. protected _nearestBestKernel(idealKernel: number): number;
  9701. /**
  9702. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9703. * @param x The point on the Gaussian distribution to sample.
  9704. * @return the value of the Gaussian function at x.
  9705. */
  9706. protected _gaussianWeight(x: number): number;
  9707. /**
  9708. * Generates a string that can be used as a floating point number in GLSL.
  9709. * @param x Value to print.
  9710. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9711. * @return GLSL float string.
  9712. */
  9713. protected _glslFloat(x: number, decimalFigures?: number): string;
  9714. }
  9715. }
  9716. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9717. /** @hidden */
  9718. export var shadowMapPixelShader: {
  9719. name: string;
  9720. shader: string;
  9721. };
  9722. }
  9723. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9724. /** @hidden */
  9725. export var bonesDeclaration: {
  9726. name: string;
  9727. shader: string;
  9728. };
  9729. }
  9730. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9731. /** @hidden */
  9732. export var morphTargetsVertexGlobalDeclaration: {
  9733. name: string;
  9734. shader: string;
  9735. };
  9736. }
  9737. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9738. /** @hidden */
  9739. export var morphTargetsVertexDeclaration: {
  9740. name: string;
  9741. shader: string;
  9742. };
  9743. }
  9744. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9745. /** @hidden */
  9746. export var instancesDeclaration: {
  9747. name: string;
  9748. shader: string;
  9749. };
  9750. }
  9751. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9752. /** @hidden */
  9753. export var helperFunctions: {
  9754. name: string;
  9755. shader: string;
  9756. };
  9757. }
  9758. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9759. /** @hidden */
  9760. export var morphTargetsVertex: {
  9761. name: string;
  9762. shader: string;
  9763. };
  9764. }
  9765. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9766. /** @hidden */
  9767. export var instancesVertex: {
  9768. name: string;
  9769. shader: string;
  9770. };
  9771. }
  9772. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9773. /** @hidden */
  9774. export var bonesVertex: {
  9775. name: string;
  9776. shader: string;
  9777. };
  9778. }
  9779. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9780. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9781. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9782. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9783. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9784. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9785. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9786. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9787. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9788. /** @hidden */
  9789. export var shadowMapVertexShader: {
  9790. name: string;
  9791. shader: string;
  9792. };
  9793. }
  9794. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9795. /** @hidden */
  9796. export var depthBoxBlurPixelShader: {
  9797. name: string;
  9798. shader: string;
  9799. };
  9800. }
  9801. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9802. import { Nullable } from "babylonjs/types";
  9803. import { Scene } from "babylonjs/scene";
  9804. import { Matrix } from "babylonjs/Maths/math";
  9805. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9807. import { Mesh } from "babylonjs/Meshes/mesh";
  9808. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9809. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9810. import { Effect } from "babylonjs/Materials/effect";
  9811. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9812. import "babylonjs/Shaders/shadowMap.fragment";
  9813. import "babylonjs/Shaders/shadowMap.vertex";
  9814. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9815. import { Observable } from "babylonjs/Misc/observable";
  9816. /**
  9817. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9818. */
  9819. export interface ICustomShaderOptions {
  9820. /**
  9821. * Gets or sets the custom shader name to use
  9822. */
  9823. shaderName: string;
  9824. /**
  9825. * The list of attribute names used in the shader
  9826. */
  9827. attributes?: string[];
  9828. /**
  9829. * The list of unifrom names used in the shader
  9830. */
  9831. uniforms?: string[];
  9832. /**
  9833. * The list of sampler names used in the shader
  9834. */
  9835. samplers?: string[];
  9836. /**
  9837. * The list of defines used in the shader
  9838. */
  9839. defines?: string[];
  9840. }
  9841. /**
  9842. * Interface to implement to create a shadow generator compatible with BJS.
  9843. */
  9844. export interface IShadowGenerator {
  9845. /**
  9846. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9847. * @returns The render target texture if present otherwise, null
  9848. */
  9849. getShadowMap(): Nullable<RenderTargetTexture>;
  9850. /**
  9851. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9852. * @returns The render target texture if the shadow map is present otherwise, null
  9853. */
  9854. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9855. /**
  9856. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9857. * @param subMesh The submesh we want to render in the shadow map
  9858. * @param useInstances Defines wether will draw in the map using instances
  9859. * @returns true if ready otherwise, false
  9860. */
  9861. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9862. /**
  9863. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9864. * @param defines Defines of the material we want to update
  9865. * @param lightIndex Index of the light in the enabled light list of the material
  9866. */
  9867. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9868. /**
  9869. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9870. * defined in the generator but impacting the effect).
  9871. * It implies the unifroms available on the materials are the standard BJS ones.
  9872. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9873. * @param effect The effect we are binfing the information for
  9874. */
  9875. bindShadowLight(lightIndex: string, effect: Effect): void;
  9876. /**
  9877. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9878. * (eq to shadow prjection matrix * light transform matrix)
  9879. * @returns The transform matrix used to create the shadow map
  9880. */
  9881. getTransformMatrix(): Matrix;
  9882. /**
  9883. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9884. * Cube and 2D textures for instance.
  9885. */
  9886. recreateShadowMap(): void;
  9887. /**
  9888. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9889. * @param onCompiled Callback triggered at the and of the effects compilation
  9890. * @param options Sets of optional options forcing the compilation with different modes
  9891. */
  9892. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9893. useInstances: boolean;
  9894. }>): void;
  9895. /**
  9896. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9897. * @param options Sets of optional options forcing the compilation with different modes
  9898. * @returns A promise that resolves when the compilation completes
  9899. */
  9900. forceCompilationAsync(options?: Partial<{
  9901. useInstances: boolean;
  9902. }>): Promise<void>;
  9903. /**
  9904. * Serializes the shadow generator setup to a json object.
  9905. * @returns The serialized JSON object
  9906. */
  9907. serialize(): any;
  9908. /**
  9909. * Disposes the Shadow map and related Textures and effects.
  9910. */
  9911. dispose(): void;
  9912. }
  9913. /**
  9914. * Default implementation IShadowGenerator.
  9915. * This is the main object responsible of generating shadows in the framework.
  9916. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9917. */
  9918. export class ShadowGenerator implements IShadowGenerator {
  9919. /**
  9920. * Shadow generator mode None: no filtering applied.
  9921. */
  9922. static readonly FILTER_NONE: number;
  9923. /**
  9924. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9925. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9926. */
  9927. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9928. /**
  9929. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9930. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9931. */
  9932. static readonly FILTER_POISSONSAMPLING: number;
  9933. /**
  9934. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9935. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9936. */
  9937. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9938. /**
  9939. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9940. * edge artifacts on steep falloff.
  9941. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9942. */
  9943. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9944. /**
  9945. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9946. * edge artifacts on steep falloff.
  9947. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9948. */
  9949. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9950. /**
  9951. * Shadow generator mode PCF: Percentage Closer Filtering
  9952. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9953. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9954. */
  9955. static readonly FILTER_PCF: number;
  9956. /**
  9957. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9958. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9959. * Contact Hardening
  9960. */
  9961. static readonly FILTER_PCSS: number;
  9962. /**
  9963. * Reserved for PCF and PCSS
  9964. * Highest Quality.
  9965. *
  9966. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9967. *
  9968. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9969. */
  9970. static readonly QUALITY_HIGH: number;
  9971. /**
  9972. * Reserved for PCF and PCSS
  9973. * Good tradeoff for quality/perf cross devices
  9974. *
  9975. * Execute PCF on a 3*3 kernel.
  9976. *
  9977. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9978. */
  9979. static readonly QUALITY_MEDIUM: number;
  9980. /**
  9981. * Reserved for PCF and PCSS
  9982. * The lowest quality but the fastest.
  9983. *
  9984. * Execute PCF on a 1*1 kernel.
  9985. *
  9986. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9987. */
  9988. static readonly QUALITY_LOW: number;
  9989. /** Gets or sets the custom shader name to use */
  9990. customShaderOptions: ICustomShaderOptions;
  9991. /**
  9992. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9993. */
  9994. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9995. /**
  9996. * Observable triggered before a mesh is rendered in the shadow map.
  9997. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9998. */
  9999. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  10000. private _bias;
  10001. /**
  10002. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10003. */
  10004. /**
  10005. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10006. */
  10007. bias: number;
  10008. private _normalBias;
  10009. /**
  10010. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10011. */
  10012. /**
  10013. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10014. */
  10015. normalBias: number;
  10016. private _blurBoxOffset;
  10017. /**
  10018. * Gets the blur box offset: offset applied during the blur pass.
  10019. * Only useful if useKernelBlur = false
  10020. */
  10021. /**
  10022. * Sets the blur box offset: offset applied during the blur pass.
  10023. * Only useful if useKernelBlur = false
  10024. */
  10025. blurBoxOffset: number;
  10026. private _blurScale;
  10027. /**
  10028. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10029. * 2 means half of the size.
  10030. */
  10031. /**
  10032. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10033. * 2 means half of the size.
  10034. */
  10035. blurScale: number;
  10036. private _blurKernel;
  10037. /**
  10038. * Gets the blur kernel: kernel size of the blur pass.
  10039. * Only useful if useKernelBlur = true
  10040. */
  10041. /**
  10042. * Sets the blur kernel: kernel size of the blur pass.
  10043. * Only useful if useKernelBlur = true
  10044. */
  10045. blurKernel: number;
  10046. private _useKernelBlur;
  10047. /**
  10048. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10049. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10050. */
  10051. /**
  10052. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10053. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10054. */
  10055. useKernelBlur: boolean;
  10056. private _depthScale;
  10057. /**
  10058. * Gets the depth scale used in ESM mode.
  10059. */
  10060. /**
  10061. * Sets the depth scale used in ESM mode.
  10062. * This can override the scale stored on the light.
  10063. */
  10064. depthScale: number;
  10065. private _filter;
  10066. /**
  10067. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10068. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10069. */
  10070. /**
  10071. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10072. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10073. */
  10074. filter: number;
  10075. /**
  10076. * Gets if the current filter is set to Poisson Sampling.
  10077. */
  10078. /**
  10079. * Sets the current filter to Poisson Sampling.
  10080. */
  10081. usePoissonSampling: boolean;
  10082. /**
  10083. * Gets if the current filter is set to ESM.
  10084. */
  10085. /**
  10086. * Sets the current filter is to ESM.
  10087. */
  10088. useExponentialShadowMap: boolean;
  10089. /**
  10090. * Gets if the current filter is set to filtered ESM.
  10091. */
  10092. /**
  10093. * Gets if the current filter is set to filtered ESM.
  10094. */
  10095. useBlurExponentialShadowMap: boolean;
  10096. /**
  10097. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10098. * exponential to prevent steep falloff artifacts).
  10099. */
  10100. /**
  10101. * Sets the current filter to "close ESM" (using the inverse of the
  10102. * exponential to prevent steep falloff artifacts).
  10103. */
  10104. useCloseExponentialShadowMap: boolean;
  10105. /**
  10106. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10107. * exponential to prevent steep falloff artifacts).
  10108. */
  10109. /**
  10110. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10111. * exponential to prevent steep falloff artifacts).
  10112. */
  10113. useBlurCloseExponentialShadowMap: boolean;
  10114. /**
  10115. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10116. */
  10117. /**
  10118. * Sets the current filter to "PCF" (percentage closer filtering).
  10119. */
  10120. usePercentageCloserFiltering: boolean;
  10121. private _filteringQuality;
  10122. /**
  10123. * Gets the PCF or PCSS Quality.
  10124. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10125. */
  10126. /**
  10127. * Sets the PCF or PCSS Quality.
  10128. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10129. */
  10130. filteringQuality: number;
  10131. /**
  10132. * Gets if the current filter is set to "PCSS" (contact hardening).
  10133. */
  10134. /**
  10135. * Sets the current filter to "PCSS" (contact hardening).
  10136. */
  10137. useContactHardeningShadow: boolean;
  10138. private _contactHardeningLightSizeUVRatio;
  10139. /**
  10140. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10141. * Using a ratio helps keeping shape stability independently of the map size.
  10142. *
  10143. * It does not account for the light projection as it was having too much
  10144. * instability during the light setup or during light position changes.
  10145. *
  10146. * Only valid if useContactHardeningShadow is true.
  10147. */
  10148. /**
  10149. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10150. * Using a ratio helps keeping shape stability independently of the map size.
  10151. *
  10152. * It does not account for the light projection as it was having too much
  10153. * instability during the light setup or during light position changes.
  10154. *
  10155. * Only valid if useContactHardeningShadow is true.
  10156. */
  10157. contactHardeningLightSizeUVRatio: number;
  10158. private _darkness;
  10159. /**
  10160. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10161. * 0 means strongest and 1 would means no shadow.
  10162. * @returns the darkness.
  10163. */
  10164. getDarkness(): number;
  10165. /**
  10166. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10167. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10168. * @returns the shadow generator allowing fluent coding.
  10169. */
  10170. setDarkness(darkness: number): ShadowGenerator;
  10171. private _transparencyShadow;
  10172. /**
  10173. * Sets the ability to have transparent shadow (boolean).
  10174. * @param transparent True if transparent else False
  10175. * @returns the shadow generator allowing fluent coding
  10176. */
  10177. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10178. private _shadowMap;
  10179. private _shadowMap2;
  10180. /**
  10181. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10182. * @returns The render target texture if present otherwise, null
  10183. */
  10184. getShadowMap(): Nullable<RenderTargetTexture>;
  10185. /**
  10186. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10187. * @returns The render target texture if the shadow map is present otherwise, null
  10188. */
  10189. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10190. /**
  10191. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10192. * @param mesh Mesh to add
  10193. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10194. * @returns the Shadow Generator itself
  10195. */
  10196. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10197. /**
  10198. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10199. * @param mesh Mesh to remove
  10200. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10201. * @returns the Shadow Generator itself
  10202. */
  10203. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10204. /**
  10205. * Controls the extent to which the shadows fade out at the edge of the frustum
  10206. * Used only by directionals and spots
  10207. */
  10208. frustumEdgeFalloff: number;
  10209. private _light;
  10210. /**
  10211. * Returns the associated light object.
  10212. * @returns the light generating the shadow
  10213. */
  10214. getLight(): IShadowLight;
  10215. /**
  10216. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10217. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10218. * It might on the other hand introduce peter panning.
  10219. */
  10220. forceBackFacesOnly: boolean;
  10221. private _scene;
  10222. private _lightDirection;
  10223. private _effect;
  10224. private _viewMatrix;
  10225. private _projectionMatrix;
  10226. private _transformMatrix;
  10227. private _cachedPosition;
  10228. private _cachedDirection;
  10229. private _cachedDefines;
  10230. private _currentRenderID;
  10231. private _boxBlurPostprocess;
  10232. private _kernelBlurXPostprocess;
  10233. private _kernelBlurYPostprocess;
  10234. private _blurPostProcesses;
  10235. private _mapSize;
  10236. private _currentFaceIndex;
  10237. private _currentFaceIndexCache;
  10238. private _textureType;
  10239. private _defaultTextureMatrix;
  10240. /** @hidden */
  10241. static _SceneComponentInitialization: (scene: Scene) => void;
  10242. /**
  10243. * Creates a ShadowGenerator object.
  10244. * A ShadowGenerator is the required tool to use the shadows.
  10245. * Each light casting shadows needs to use its own ShadowGenerator.
  10246. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10247. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10248. * @param light The light object generating the shadows.
  10249. * @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.
  10250. */
  10251. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10252. private _initializeGenerator;
  10253. private _initializeShadowMap;
  10254. private _initializeBlurRTTAndPostProcesses;
  10255. private _renderForShadowMap;
  10256. private _renderSubMeshForShadowMap;
  10257. private _applyFilterValues;
  10258. /**
  10259. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10260. * @param onCompiled Callback triggered at the and of the effects compilation
  10261. * @param options Sets of optional options forcing the compilation with different modes
  10262. */
  10263. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10264. useInstances: boolean;
  10265. }>): void;
  10266. /**
  10267. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10268. * @param options Sets of optional options forcing the compilation with different modes
  10269. * @returns A promise that resolves when the compilation completes
  10270. */
  10271. forceCompilationAsync(options?: Partial<{
  10272. useInstances: boolean;
  10273. }>): Promise<void>;
  10274. /**
  10275. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10276. * @param subMesh The submesh we want to render in the shadow map
  10277. * @param useInstances Defines wether will draw in the map using instances
  10278. * @returns true if ready otherwise, false
  10279. */
  10280. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10281. /**
  10282. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10283. * @param defines Defines of the material we want to update
  10284. * @param lightIndex Index of the light in the enabled light list of the material
  10285. */
  10286. prepareDefines(defines: any, lightIndex: number): void;
  10287. /**
  10288. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10289. * defined in the generator but impacting the effect).
  10290. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10291. * @param effect The effect we are binfing the information for
  10292. */
  10293. bindShadowLight(lightIndex: string, effect: Effect): void;
  10294. /**
  10295. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10296. * (eq to shadow prjection matrix * light transform matrix)
  10297. * @returns The transform matrix used to create the shadow map
  10298. */
  10299. getTransformMatrix(): Matrix;
  10300. /**
  10301. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10302. * Cube and 2D textures for instance.
  10303. */
  10304. recreateShadowMap(): void;
  10305. private _disposeBlurPostProcesses;
  10306. private _disposeRTTandPostProcesses;
  10307. /**
  10308. * Disposes the ShadowGenerator.
  10309. * Returns nothing.
  10310. */
  10311. dispose(): void;
  10312. /**
  10313. * Serializes the shadow generator setup to a json object.
  10314. * @returns The serialized JSON object
  10315. */
  10316. serialize(): any;
  10317. /**
  10318. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10319. * @param parsedShadowGenerator The JSON object to parse
  10320. * @param scene The scene to create the shadow map for
  10321. * @returns The parsed shadow generator
  10322. */
  10323. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10324. }
  10325. }
  10326. declare module "babylonjs/Lights/light" {
  10327. import { Nullable } from "babylonjs/types";
  10328. import { Scene } from "babylonjs/scene";
  10329. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10330. import { Node } from "babylonjs/node";
  10331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10332. import { Effect } from "babylonjs/Materials/effect";
  10333. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10334. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10335. /**
  10336. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10337. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10338. * 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.
  10339. */
  10340. export abstract class Light extends Node {
  10341. /**
  10342. * Falloff Default: light is falling off following the material specification:
  10343. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10344. */
  10345. static readonly FALLOFF_DEFAULT: number;
  10346. /**
  10347. * Falloff Physical: light is falling off following the inverse squared distance law.
  10348. */
  10349. static readonly FALLOFF_PHYSICAL: number;
  10350. /**
  10351. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10352. * to enhance interoperability with other engines.
  10353. */
  10354. static readonly FALLOFF_GLTF: number;
  10355. /**
  10356. * Falloff Standard: light is falling off like in the standard material
  10357. * to enhance interoperability with other materials.
  10358. */
  10359. static readonly FALLOFF_STANDARD: number;
  10360. /**
  10361. * If every light affecting the material is in this lightmapMode,
  10362. * material.lightmapTexture adds or multiplies
  10363. * (depends on material.useLightmapAsShadowmap)
  10364. * after every other light calculations.
  10365. */
  10366. static readonly LIGHTMAP_DEFAULT: number;
  10367. /**
  10368. * material.lightmapTexture as only diffuse lighting from this light
  10369. * adds only specular lighting from this light
  10370. * adds dynamic shadows
  10371. */
  10372. static readonly LIGHTMAP_SPECULAR: number;
  10373. /**
  10374. * material.lightmapTexture as only lighting
  10375. * no light calculation from this light
  10376. * only adds dynamic shadows from this light
  10377. */
  10378. static readonly LIGHTMAP_SHADOWSONLY: number;
  10379. /**
  10380. * Each light type uses the default quantity according to its type:
  10381. * point/spot lights use luminous intensity
  10382. * directional lights use illuminance
  10383. */
  10384. static readonly INTENSITYMODE_AUTOMATIC: number;
  10385. /**
  10386. * lumen (lm)
  10387. */
  10388. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10389. /**
  10390. * candela (lm/sr)
  10391. */
  10392. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10393. /**
  10394. * lux (lm/m^2)
  10395. */
  10396. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10397. /**
  10398. * nit (cd/m^2)
  10399. */
  10400. static readonly INTENSITYMODE_LUMINANCE: number;
  10401. /**
  10402. * Light type const id of the point light.
  10403. */
  10404. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10405. /**
  10406. * Light type const id of the directional light.
  10407. */
  10408. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10409. /**
  10410. * Light type const id of the spot light.
  10411. */
  10412. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10413. /**
  10414. * Light type const id of the hemispheric light.
  10415. */
  10416. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10417. /**
  10418. * Diffuse gives the basic color to an object.
  10419. */
  10420. diffuse: Color3;
  10421. /**
  10422. * Specular produces a highlight color on an object.
  10423. * Note: This is note affecting PBR materials.
  10424. */
  10425. specular: Color3;
  10426. /**
  10427. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10428. * falling off base on range or angle.
  10429. * This can be set to any values in Light.FALLOFF_x.
  10430. *
  10431. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10432. * other types of materials.
  10433. */
  10434. falloffType: number;
  10435. /**
  10436. * Strength of the light.
  10437. * Note: By default it is define in the framework own unit.
  10438. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10439. */
  10440. intensity: number;
  10441. private _range;
  10442. protected _inverseSquaredRange: number;
  10443. /**
  10444. * Defines how far from the source the light is impacting in scene units.
  10445. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10446. */
  10447. /**
  10448. * Defines how far from the source the light is impacting in scene units.
  10449. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10450. */
  10451. range: number;
  10452. /**
  10453. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10454. * of light.
  10455. */
  10456. private _photometricScale;
  10457. private _intensityMode;
  10458. /**
  10459. * Gets the photometric scale used to interpret the intensity.
  10460. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10461. */
  10462. /**
  10463. * Sets the photometric scale used to interpret the intensity.
  10464. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10465. */
  10466. intensityMode: number;
  10467. private _radius;
  10468. /**
  10469. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10470. */
  10471. /**
  10472. * sets the light radius used by PBR Materials to simulate soft area lights.
  10473. */
  10474. radius: number;
  10475. private _renderPriority;
  10476. /**
  10477. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10478. * exceeding the number allowed of the materials.
  10479. */
  10480. renderPriority: number;
  10481. private _shadowEnabled;
  10482. /**
  10483. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10484. * the current shadow generator.
  10485. */
  10486. /**
  10487. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10488. * the current shadow generator.
  10489. */
  10490. shadowEnabled: boolean;
  10491. private _includedOnlyMeshes;
  10492. /**
  10493. * Gets the only meshes impacted by this light.
  10494. */
  10495. /**
  10496. * Sets the only meshes impacted by this light.
  10497. */
  10498. includedOnlyMeshes: AbstractMesh[];
  10499. private _excludedMeshes;
  10500. /**
  10501. * Gets the meshes not impacted by this light.
  10502. */
  10503. /**
  10504. * Sets the meshes not impacted by this light.
  10505. */
  10506. excludedMeshes: AbstractMesh[];
  10507. private _excludeWithLayerMask;
  10508. /**
  10509. * Gets the layer id use to find what meshes are not impacted by the light.
  10510. * Inactive if 0
  10511. */
  10512. /**
  10513. * Sets the layer id use to find what meshes are not impacted by the light.
  10514. * Inactive if 0
  10515. */
  10516. excludeWithLayerMask: number;
  10517. private _includeOnlyWithLayerMask;
  10518. /**
  10519. * Gets the layer id use to find what meshes are impacted by the light.
  10520. * Inactive if 0
  10521. */
  10522. /**
  10523. * Sets the layer id use to find what meshes are impacted by the light.
  10524. * Inactive if 0
  10525. */
  10526. includeOnlyWithLayerMask: number;
  10527. private _lightmapMode;
  10528. /**
  10529. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10530. */
  10531. /**
  10532. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10533. */
  10534. lightmapMode: number;
  10535. /**
  10536. * Shadow generator associted to the light.
  10537. * @hidden Internal use only.
  10538. */
  10539. _shadowGenerator: Nullable<IShadowGenerator>;
  10540. /**
  10541. * @hidden Internal use only.
  10542. */
  10543. _excludedMeshesIds: string[];
  10544. /**
  10545. * @hidden Internal use only.
  10546. */
  10547. _includedOnlyMeshesIds: string[];
  10548. /**
  10549. * The current light unifom buffer.
  10550. * @hidden Internal use only.
  10551. */
  10552. _uniformBuffer: UniformBuffer;
  10553. /**
  10554. * Creates a Light object in the scene.
  10555. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10556. * @param name The firendly name of the light
  10557. * @param scene The scene the light belongs too
  10558. */
  10559. constructor(name: string, scene: Scene);
  10560. protected abstract _buildUniformLayout(): void;
  10561. /**
  10562. * Sets the passed Effect "effect" with the Light information.
  10563. * @param effect The effect to update
  10564. * @param lightIndex The index of the light in the effect to update
  10565. * @returns The light
  10566. */
  10567. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10568. /**
  10569. * Returns the string "Light".
  10570. * @returns the class name
  10571. */
  10572. getClassName(): string;
  10573. /** @hidden */
  10574. readonly _isLight: boolean;
  10575. /**
  10576. * Converts the light information to a readable string for debug purpose.
  10577. * @param fullDetails Supports for multiple levels of logging within scene loading
  10578. * @returns the human readable light info
  10579. */
  10580. toString(fullDetails?: boolean): string;
  10581. /** @hidden */
  10582. protected _syncParentEnabledState(): void;
  10583. /**
  10584. * Set the enabled state of this node.
  10585. * @param value - the new enabled state
  10586. */
  10587. setEnabled(value: boolean): void;
  10588. /**
  10589. * Returns the Light associated shadow generator if any.
  10590. * @return the associated shadow generator.
  10591. */
  10592. getShadowGenerator(): Nullable<IShadowGenerator>;
  10593. /**
  10594. * Returns a Vector3, the absolute light position in the World.
  10595. * @returns the world space position of the light
  10596. */
  10597. getAbsolutePosition(): Vector3;
  10598. /**
  10599. * Specifies if the light will affect the passed mesh.
  10600. * @param mesh The mesh to test against the light
  10601. * @return true the mesh is affected otherwise, false.
  10602. */
  10603. canAffectMesh(mesh: AbstractMesh): boolean;
  10604. /**
  10605. * Sort function to order lights for rendering.
  10606. * @param a First Light object to compare to second.
  10607. * @param b Second Light object to compare first.
  10608. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10609. */
  10610. static CompareLightsPriority(a: Light, b: Light): number;
  10611. /**
  10612. * Releases resources associated with this node.
  10613. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10614. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10615. */
  10616. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10617. /**
  10618. * Returns the light type ID (integer).
  10619. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10620. */
  10621. getTypeID(): number;
  10622. /**
  10623. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10624. * @returns the scaled intensity in intensity mode unit
  10625. */
  10626. getScaledIntensity(): number;
  10627. /**
  10628. * Returns a new Light object, named "name", from the current one.
  10629. * @param name The name of the cloned light
  10630. * @returns the new created light
  10631. */
  10632. clone(name: string): Nullable<Light>;
  10633. /**
  10634. * Serializes the current light into a Serialization object.
  10635. * @returns the serialized object.
  10636. */
  10637. serialize(): any;
  10638. /**
  10639. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10640. * This new light is named "name" and added to the passed scene.
  10641. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10642. * @param name The friendly name of the light
  10643. * @param scene The scene the new light will belong to
  10644. * @returns the constructor function
  10645. */
  10646. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10647. /**
  10648. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10649. * @param parsedLight The JSON representation of the light
  10650. * @param scene The scene to create the parsed light in
  10651. * @returns the created light after parsing
  10652. */
  10653. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10654. private _hookArrayForExcluded;
  10655. private _hookArrayForIncludedOnly;
  10656. private _resyncMeshes;
  10657. /**
  10658. * Forces the meshes to update their light related information in their rendering used effects
  10659. * @hidden Internal Use Only
  10660. */
  10661. _markMeshesAsLightDirty(): void;
  10662. /**
  10663. * Recomputes the cached photometric scale if needed.
  10664. */
  10665. private _computePhotometricScale;
  10666. /**
  10667. * Returns the Photometric Scale according to the light type and intensity mode.
  10668. */
  10669. private _getPhotometricScale;
  10670. /**
  10671. * Reorder the light in the scene according to their defined priority.
  10672. * @hidden Internal Use Only
  10673. */
  10674. _reorderLightsInScene(): void;
  10675. /**
  10676. * Prepares the list of defines specific to the light type.
  10677. * @param defines the list of defines
  10678. * @param lightIndex defines the index of the light for the effect
  10679. */
  10680. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10681. }
  10682. }
  10683. declare module "babylonjs/Actions/action" {
  10684. import { Observable } from "babylonjs/Misc/observable";
  10685. import { Condition } from "babylonjs/Actions/condition";
  10686. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10687. import { ActionManager } from "babylonjs/Actions/actionManager";
  10688. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10689. /**
  10690. * Interface used to define Action
  10691. */
  10692. export interface IAction {
  10693. /**
  10694. * Trigger for the action
  10695. */
  10696. trigger: number;
  10697. /** Options of the trigger */
  10698. triggerOptions: any;
  10699. /**
  10700. * Gets the trigger parameters
  10701. * @returns the trigger parameters
  10702. */
  10703. getTriggerParameter(): any;
  10704. /**
  10705. * Internal only - executes current action event
  10706. * @hidden
  10707. */
  10708. _executeCurrent(evt?: ActionEvent): void;
  10709. /**
  10710. * Serialize placeholder for child classes
  10711. * @param parent of child
  10712. * @returns the serialized object
  10713. */
  10714. serialize(parent: any): any;
  10715. /**
  10716. * Internal only
  10717. * @hidden
  10718. */
  10719. _prepare(): void;
  10720. /**
  10721. * Internal only - manager for action
  10722. * @hidden
  10723. */
  10724. _actionManager: AbstractActionManager;
  10725. }
  10726. /**
  10727. * The action to be carried out following a trigger
  10728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10729. */
  10730. export class Action implements IAction {
  10731. /** the trigger, with or without parameters, for the action */
  10732. triggerOptions: any;
  10733. /**
  10734. * Trigger for the action
  10735. */
  10736. trigger: number;
  10737. /**
  10738. * Internal only - manager for action
  10739. * @hidden
  10740. */
  10741. _actionManager: ActionManager;
  10742. private _nextActiveAction;
  10743. private _child;
  10744. private _condition?;
  10745. private _triggerParameter;
  10746. /**
  10747. * An event triggered prior to action being executed.
  10748. */
  10749. onBeforeExecuteObservable: Observable<Action>;
  10750. /**
  10751. * Creates a new Action
  10752. * @param triggerOptions the trigger, with or without parameters, for the action
  10753. * @param condition an optional determinant of action
  10754. */
  10755. constructor(
  10756. /** the trigger, with or without parameters, for the action */
  10757. triggerOptions: any, condition?: Condition);
  10758. /**
  10759. * Internal only
  10760. * @hidden
  10761. */
  10762. _prepare(): void;
  10763. /**
  10764. * Gets the trigger parameters
  10765. * @returns the trigger parameters
  10766. */
  10767. getTriggerParameter(): any;
  10768. /**
  10769. * Internal only - executes current action event
  10770. * @hidden
  10771. */
  10772. _executeCurrent(evt?: ActionEvent): void;
  10773. /**
  10774. * Execute placeholder for child classes
  10775. * @param evt optional action event
  10776. */
  10777. execute(evt?: ActionEvent): void;
  10778. /**
  10779. * Skips to next active action
  10780. */
  10781. skipToNextActiveAction(): void;
  10782. /**
  10783. * Adds action to chain of actions, may be a DoNothingAction
  10784. * @param action defines the next action to execute
  10785. * @returns The action passed in
  10786. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10787. */
  10788. then(action: Action): Action;
  10789. /**
  10790. * Internal only
  10791. * @hidden
  10792. */
  10793. _getProperty(propertyPath: string): string;
  10794. /**
  10795. * Internal only
  10796. * @hidden
  10797. */
  10798. _getEffectiveTarget(target: any, propertyPath: string): any;
  10799. /**
  10800. * Serialize placeholder for child classes
  10801. * @param parent of child
  10802. * @returns the serialized object
  10803. */
  10804. serialize(parent: any): any;
  10805. /**
  10806. * Internal only called by serialize
  10807. * @hidden
  10808. */
  10809. protected _serialize(serializedAction: any, parent?: any): any;
  10810. /**
  10811. * Internal only
  10812. * @hidden
  10813. */
  10814. static _SerializeValueAsString: (value: any) => string;
  10815. /**
  10816. * Internal only
  10817. * @hidden
  10818. */
  10819. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10820. name: string;
  10821. targetType: string;
  10822. value: string;
  10823. };
  10824. }
  10825. }
  10826. declare module "babylonjs/Actions/condition" {
  10827. import { ActionManager } from "babylonjs/Actions/actionManager";
  10828. /**
  10829. * A Condition applied to an Action
  10830. */
  10831. export class Condition {
  10832. /**
  10833. * Internal only - manager for action
  10834. * @hidden
  10835. */
  10836. _actionManager: ActionManager;
  10837. /**
  10838. * Internal only
  10839. * @hidden
  10840. */
  10841. _evaluationId: number;
  10842. /**
  10843. * Internal only
  10844. * @hidden
  10845. */
  10846. _currentResult: boolean;
  10847. /**
  10848. * Creates a new Condition
  10849. * @param actionManager the manager of the action the condition is applied to
  10850. */
  10851. constructor(actionManager: ActionManager);
  10852. /**
  10853. * Check if the current condition is valid
  10854. * @returns a boolean
  10855. */
  10856. isValid(): boolean;
  10857. /**
  10858. * Internal only
  10859. * @hidden
  10860. */
  10861. _getProperty(propertyPath: string): string;
  10862. /**
  10863. * Internal only
  10864. * @hidden
  10865. */
  10866. _getEffectiveTarget(target: any, propertyPath: string): any;
  10867. /**
  10868. * Serialize placeholder for child classes
  10869. * @returns the serialized object
  10870. */
  10871. serialize(): any;
  10872. /**
  10873. * Internal only
  10874. * @hidden
  10875. */
  10876. protected _serialize(serializedCondition: any): any;
  10877. }
  10878. /**
  10879. * Defines specific conditional operators as extensions of Condition
  10880. */
  10881. export class ValueCondition extends Condition {
  10882. /** path to specify the property of the target the conditional operator uses */
  10883. propertyPath: string;
  10884. /** the value compared by the conditional operator against the current value of the property */
  10885. value: any;
  10886. /** the conditional operator, default ValueCondition.IsEqual */
  10887. operator: number;
  10888. /**
  10889. * Internal only
  10890. * @hidden
  10891. */
  10892. private static _IsEqual;
  10893. /**
  10894. * Internal only
  10895. * @hidden
  10896. */
  10897. private static _IsDifferent;
  10898. /**
  10899. * Internal only
  10900. * @hidden
  10901. */
  10902. private static _IsGreater;
  10903. /**
  10904. * Internal only
  10905. * @hidden
  10906. */
  10907. private static _IsLesser;
  10908. /**
  10909. * returns the number for IsEqual
  10910. */
  10911. static readonly IsEqual: number;
  10912. /**
  10913. * Returns the number for IsDifferent
  10914. */
  10915. static readonly IsDifferent: number;
  10916. /**
  10917. * Returns the number for IsGreater
  10918. */
  10919. static readonly IsGreater: number;
  10920. /**
  10921. * Returns the number for IsLesser
  10922. */
  10923. static readonly IsLesser: number;
  10924. /**
  10925. * Internal only The action manager for the condition
  10926. * @hidden
  10927. */
  10928. _actionManager: ActionManager;
  10929. /**
  10930. * Internal only
  10931. * @hidden
  10932. */
  10933. private _target;
  10934. /**
  10935. * Internal only
  10936. * @hidden
  10937. */
  10938. private _effectiveTarget;
  10939. /**
  10940. * Internal only
  10941. * @hidden
  10942. */
  10943. private _property;
  10944. /**
  10945. * Creates a new ValueCondition
  10946. * @param actionManager manager for the action the condition applies to
  10947. * @param target for the action
  10948. * @param propertyPath path to specify the property of the target the conditional operator uses
  10949. * @param value the value compared by the conditional operator against the current value of the property
  10950. * @param operator the conditional operator, default ValueCondition.IsEqual
  10951. */
  10952. constructor(actionManager: ActionManager, target: any,
  10953. /** path to specify the property of the target the conditional operator uses */
  10954. propertyPath: string,
  10955. /** the value compared by the conditional operator against the current value of the property */
  10956. value: any,
  10957. /** the conditional operator, default ValueCondition.IsEqual */
  10958. operator?: number);
  10959. /**
  10960. * Compares the given value with the property value for the specified conditional operator
  10961. * @returns the result of the comparison
  10962. */
  10963. isValid(): boolean;
  10964. /**
  10965. * Serialize the ValueCondition into a JSON compatible object
  10966. * @returns serialization object
  10967. */
  10968. serialize(): any;
  10969. /**
  10970. * Gets the name of the conditional operator for the ValueCondition
  10971. * @param operator the conditional operator
  10972. * @returns the name
  10973. */
  10974. static GetOperatorName(operator: number): string;
  10975. }
  10976. /**
  10977. * Defines a predicate condition as an extension of Condition
  10978. */
  10979. export class PredicateCondition extends Condition {
  10980. /** defines the predicate function used to validate the condition */
  10981. predicate: () => boolean;
  10982. /**
  10983. * Internal only - manager for action
  10984. * @hidden
  10985. */
  10986. _actionManager: ActionManager;
  10987. /**
  10988. * Creates a new PredicateCondition
  10989. * @param actionManager manager for the action the condition applies to
  10990. * @param predicate defines the predicate function used to validate the condition
  10991. */
  10992. constructor(actionManager: ActionManager,
  10993. /** defines the predicate function used to validate the condition */
  10994. predicate: () => boolean);
  10995. /**
  10996. * @returns the validity of the predicate condition
  10997. */
  10998. isValid(): boolean;
  10999. }
  11000. /**
  11001. * Defines a state condition as an extension of Condition
  11002. */
  11003. export class StateCondition extends Condition {
  11004. /** Value to compare with target state */
  11005. value: string;
  11006. /**
  11007. * Internal only - manager for action
  11008. * @hidden
  11009. */
  11010. _actionManager: ActionManager;
  11011. /**
  11012. * Internal only
  11013. * @hidden
  11014. */
  11015. private _target;
  11016. /**
  11017. * Creates a new StateCondition
  11018. * @param actionManager manager for the action the condition applies to
  11019. * @param target of the condition
  11020. * @param value to compare with target state
  11021. */
  11022. constructor(actionManager: ActionManager, target: any,
  11023. /** Value to compare with target state */
  11024. value: string);
  11025. /**
  11026. * Gets a boolean indicating if the current condition is met
  11027. * @returns the validity of the state
  11028. */
  11029. isValid(): boolean;
  11030. /**
  11031. * Serialize the StateCondition into a JSON compatible object
  11032. * @returns serialization object
  11033. */
  11034. serialize(): any;
  11035. }
  11036. }
  11037. declare module "babylonjs/Actions/directActions" {
  11038. import { Action } from "babylonjs/Actions/action";
  11039. import { Condition } from "babylonjs/Actions/condition";
  11040. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11041. /**
  11042. * This defines an action responsible to toggle a boolean once triggered.
  11043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11044. */
  11045. export class SwitchBooleanAction extends Action {
  11046. /**
  11047. * The path to the boolean property in the target object
  11048. */
  11049. propertyPath: string;
  11050. private _target;
  11051. private _effectiveTarget;
  11052. private _property;
  11053. /**
  11054. * Instantiate the action
  11055. * @param triggerOptions defines the trigger options
  11056. * @param target defines the object containing the boolean
  11057. * @param propertyPath defines the path to the boolean property in the target object
  11058. * @param condition defines the trigger related conditions
  11059. */
  11060. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11061. /** @hidden */
  11062. _prepare(): void;
  11063. /**
  11064. * Execute the action toggle the boolean value.
  11065. */
  11066. execute(): void;
  11067. /**
  11068. * Serializes the actions and its related information.
  11069. * @param parent defines the object to serialize in
  11070. * @returns the serialized object
  11071. */
  11072. serialize(parent: any): any;
  11073. }
  11074. /**
  11075. * This defines an action responsible to set a the state field of the target
  11076. * to a desired value once triggered.
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11078. */
  11079. export class SetStateAction extends Action {
  11080. /**
  11081. * The value to store in the state field.
  11082. */
  11083. value: string;
  11084. private _target;
  11085. /**
  11086. * Instantiate the action
  11087. * @param triggerOptions defines the trigger options
  11088. * @param target defines the object containing the state property
  11089. * @param value defines the value to store in the state field
  11090. * @param condition defines the trigger related conditions
  11091. */
  11092. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11093. /**
  11094. * Execute the action and store the value on the target state property.
  11095. */
  11096. execute(): void;
  11097. /**
  11098. * Serializes the actions and its related information.
  11099. * @param parent defines the object to serialize in
  11100. * @returns the serialized object
  11101. */
  11102. serialize(parent: any): any;
  11103. }
  11104. /**
  11105. * This defines an action responsible to set a property of the target
  11106. * to a desired value once triggered.
  11107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11108. */
  11109. export class SetValueAction extends Action {
  11110. /**
  11111. * The path of the property to set in the target.
  11112. */
  11113. propertyPath: string;
  11114. /**
  11115. * The value to set in the property
  11116. */
  11117. value: any;
  11118. private _target;
  11119. private _effectiveTarget;
  11120. private _property;
  11121. /**
  11122. * Instantiate the action
  11123. * @param triggerOptions defines the trigger options
  11124. * @param target defines the object containing the property
  11125. * @param propertyPath defines the path of the property to set in the target
  11126. * @param value defines the value to set in the property
  11127. * @param condition defines the trigger related conditions
  11128. */
  11129. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11130. /** @hidden */
  11131. _prepare(): void;
  11132. /**
  11133. * Execute the action and set the targetted property to the desired value.
  11134. */
  11135. execute(): void;
  11136. /**
  11137. * Serializes the actions and its related information.
  11138. * @param parent defines the object to serialize in
  11139. * @returns the serialized object
  11140. */
  11141. serialize(parent: any): any;
  11142. }
  11143. /**
  11144. * This defines an action responsible to increment the target value
  11145. * to a desired value once triggered.
  11146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11147. */
  11148. export class IncrementValueAction extends Action {
  11149. /**
  11150. * The path of the property to increment in the target.
  11151. */
  11152. propertyPath: string;
  11153. /**
  11154. * The value we should increment the property by.
  11155. */
  11156. value: any;
  11157. private _target;
  11158. private _effectiveTarget;
  11159. private _property;
  11160. /**
  11161. * Instantiate the action
  11162. * @param triggerOptions defines the trigger options
  11163. * @param target defines the object containing the property
  11164. * @param propertyPath defines the path of the property to increment in the target
  11165. * @param value defines the value value we should increment the property by
  11166. * @param condition defines the trigger related conditions
  11167. */
  11168. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11169. /** @hidden */
  11170. _prepare(): void;
  11171. /**
  11172. * Execute the action and increment the target of the value amount.
  11173. */
  11174. execute(): void;
  11175. /**
  11176. * Serializes the actions and its related information.
  11177. * @param parent defines the object to serialize in
  11178. * @returns the serialized object
  11179. */
  11180. serialize(parent: any): any;
  11181. }
  11182. /**
  11183. * This defines an action responsible to start an animation once triggered.
  11184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11185. */
  11186. export class PlayAnimationAction extends Action {
  11187. /**
  11188. * Where the animation should start (animation frame)
  11189. */
  11190. from: number;
  11191. /**
  11192. * Where the animation should stop (animation frame)
  11193. */
  11194. to: number;
  11195. /**
  11196. * Define if the animation should loop or stop after the first play.
  11197. */
  11198. loop?: boolean;
  11199. private _target;
  11200. /**
  11201. * Instantiate the action
  11202. * @param triggerOptions defines the trigger options
  11203. * @param target defines the target animation or animation name
  11204. * @param from defines from where the animation should start (animation frame)
  11205. * @param end defines where the animation should stop (animation frame)
  11206. * @param loop defines if the animation should loop or stop after the first play
  11207. * @param condition defines the trigger related conditions
  11208. */
  11209. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11210. /** @hidden */
  11211. _prepare(): void;
  11212. /**
  11213. * Execute the action and play the animation.
  11214. */
  11215. execute(): void;
  11216. /**
  11217. * Serializes the actions and its related information.
  11218. * @param parent defines the object to serialize in
  11219. * @returns the serialized object
  11220. */
  11221. serialize(parent: any): any;
  11222. }
  11223. /**
  11224. * This defines an action responsible to stop an animation once triggered.
  11225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11226. */
  11227. export class StopAnimationAction extends Action {
  11228. private _target;
  11229. /**
  11230. * Instantiate the action
  11231. * @param triggerOptions defines the trigger options
  11232. * @param target defines the target animation or animation name
  11233. * @param condition defines the trigger related conditions
  11234. */
  11235. constructor(triggerOptions: any, target: any, condition?: Condition);
  11236. /** @hidden */
  11237. _prepare(): void;
  11238. /**
  11239. * Execute the action and stop the animation.
  11240. */
  11241. execute(): void;
  11242. /**
  11243. * Serializes the actions and its related information.
  11244. * @param parent defines the object to serialize in
  11245. * @returns the serialized object
  11246. */
  11247. serialize(parent: any): any;
  11248. }
  11249. /**
  11250. * This defines an action responsible that does nothing once triggered.
  11251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11252. */
  11253. export class DoNothingAction extends Action {
  11254. /**
  11255. * Instantiate the action
  11256. * @param triggerOptions defines the trigger options
  11257. * @param condition defines the trigger related conditions
  11258. */
  11259. constructor(triggerOptions?: any, condition?: Condition);
  11260. /**
  11261. * Execute the action and do nothing.
  11262. */
  11263. execute(): void;
  11264. /**
  11265. * Serializes the actions and its related information.
  11266. * @param parent defines the object to serialize in
  11267. * @returns the serialized object
  11268. */
  11269. serialize(parent: any): any;
  11270. }
  11271. /**
  11272. * This defines an action responsible to trigger several actions once triggered.
  11273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11274. */
  11275. export class CombineAction extends Action {
  11276. /**
  11277. * The list of aggregated animations to run.
  11278. */
  11279. children: Action[];
  11280. /**
  11281. * Instantiate the action
  11282. * @param triggerOptions defines the trigger options
  11283. * @param children defines the list of aggregated animations to run
  11284. * @param condition defines the trigger related conditions
  11285. */
  11286. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11287. /** @hidden */
  11288. _prepare(): void;
  11289. /**
  11290. * Execute the action and executes all the aggregated actions.
  11291. */
  11292. execute(evt: ActionEvent): void;
  11293. /**
  11294. * Serializes the actions and its related information.
  11295. * @param parent defines the object to serialize in
  11296. * @returns the serialized object
  11297. */
  11298. serialize(parent: any): any;
  11299. }
  11300. /**
  11301. * This defines an action responsible to run code (external event) once triggered.
  11302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11303. */
  11304. export class ExecuteCodeAction extends Action {
  11305. /**
  11306. * The callback function to run.
  11307. */
  11308. func: (evt: ActionEvent) => void;
  11309. /**
  11310. * Instantiate the action
  11311. * @param triggerOptions defines the trigger options
  11312. * @param func defines the callback function to run
  11313. * @param condition defines the trigger related conditions
  11314. */
  11315. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11316. /**
  11317. * Execute the action and run the attached code.
  11318. */
  11319. execute(evt: ActionEvent): void;
  11320. }
  11321. /**
  11322. * This defines an action responsible to set the parent property of the target once triggered.
  11323. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11324. */
  11325. export class SetParentAction extends Action {
  11326. private _parent;
  11327. private _target;
  11328. /**
  11329. * Instantiate the action
  11330. * @param triggerOptions defines the trigger options
  11331. * @param target defines the target containing the parent property
  11332. * @param parent defines from where the animation should start (animation frame)
  11333. * @param condition defines the trigger related conditions
  11334. */
  11335. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11336. /** @hidden */
  11337. _prepare(): void;
  11338. /**
  11339. * Execute the action and set the parent property.
  11340. */
  11341. execute(): void;
  11342. /**
  11343. * Serializes the actions and its related information.
  11344. * @param parent defines the object to serialize in
  11345. * @returns the serialized object
  11346. */
  11347. serialize(parent: any): any;
  11348. }
  11349. }
  11350. declare module "babylonjs/Actions/actionManager" {
  11351. import { Nullable } from "babylonjs/types";
  11352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11353. import { Scene } from "babylonjs/scene";
  11354. import { IAction } from "babylonjs/Actions/action";
  11355. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11356. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11357. /**
  11358. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11359. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11361. */
  11362. export class ActionManager extends AbstractActionManager {
  11363. /**
  11364. * Nothing
  11365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11366. */
  11367. static readonly NothingTrigger: number;
  11368. /**
  11369. * On pick
  11370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11371. */
  11372. static readonly OnPickTrigger: number;
  11373. /**
  11374. * On left pick
  11375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11376. */
  11377. static readonly OnLeftPickTrigger: number;
  11378. /**
  11379. * On right pick
  11380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11381. */
  11382. static readonly OnRightPickTrigger: number;
  11383. /**
  11384. * On center pick
  11385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11386. */
  11387. static readonly OnCenterPickTrigger: number;
  11388. /**
  11389. * On pick down
  11390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11391. */
  11392. static readonly OnPickDownTrigger: number;
  11393. /**
  11394. * On double pick
  11395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11396. */
  11397. static readonly OnDoublePickTrigger: number;
  11398. /**
  11399. * On pick up
  11400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11401. */
  11402. static readonly OnPickUpTrigger: number;
  11403. /**
  11404. * On pick out.
  11405. * This trigger will only be raised if you also declared a OnPickDown
  11406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11407. */
  11408. static readonly OnPickOutTrigger: number;
  11409. /**
  11410. * On long press
  11411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11412. */
  11413. static readonly OnLongPressTrigger: number;
  11414. /**
  11415. * On pointer over
  11416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11417. */
  11418. static readonly OnPointerOverTrigger: number;
  11419. /**
  11420. * On pointer out
  11421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11422. */
  11423. static readonly OnPointerOutTrigger: number;
  11424. /**
  11425. * On every frame
  11426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11427. */
  11428. static readonly OnEveryFrameTrigger: number;
  11429. /**
  11430. * On intersection enter
  11431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11432. */
  11433. static readonly OnIntersectionEnterTrigger: number;
  11434. /**
  11435. * On intersection exit
  11436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11437. */
  11438. static readonly OnIntersectionExitTrigger: number;
  11439. /**
  11440. * On key down
  11441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11442. */
  11443. static readonly OnKeyDownTrigger: number;
  11444. /**
  11445. * On key up
  11446. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11447. */
  11448. static readonly OnKeyUpTrigger: number;
  11449. private _scene;
  11450. /**
  11451. * Creates a new action manager
  11452. * @param scene defines the hosting scene
  11453. */
  11454. constructor(scene: Scene);
  11455. /**
  11456. * Releases all associated resources
  11457. */
  11458. dispose(): void;
  11459. /**
  11460. * Gets hosting scene
  11461. * @returns the hosting scene
  11462. */
  11463. getScene(): Scene;
  11464. /**
  11465. * Does this action manager handles actions of any of the given triggers
  11466. * @param triggers defines the triggers to be tested
  11467. * @return a boolean indicating whether one (or more) of the triggers is handled
  11468. */
  11469. hasSpecificTriggers(triggers: number[]): boolean;
  11470. /**
  11471. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11472. * speed.
  11473. * @param triggerA defines the trigger to be tested
  11474. * @param triggerB defines the trigger to be tested
  11475. * @return a boolean indicating whether one (or more) of the triggers is handled
  11476. */
  11477. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11478. /**
  11479. * Does this action manager handles actions of a given trigger
  11480. * @param trigger defines the trigger to be tested
  11481. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11482. * @return whether the trigger is handled
  11483. */
  11484. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11485. /**
  11486. * Does this action manager has pointer triggers
  11487. */
  11488. readonly hasPointerTriggers: boolean;
  11489. /**
  11490. * Does this action manager has pick triggers
  11491. */
  11492. readonly hasPickTriggers: boolean;
  11493. /**
  11494. * Registers an action to this action manager
  11495. * @param action defines the action to be registered
  11496. * @return the action amended (prepared) after registration
  11497. */
  11498. registerAction(action: IAction): Nullable<IAction>;
  11499. /**
  11500. * Unregisters an action to this action manager
  11501. * @param action defines the action to be unregistered
  11502. * @return a boolean indicating whether the action has been unregistered
  11503. */
  11504. unregisterAction(action: IAction): Boolean;
  11505. /**
  11506. * Process a specific trigger
  11507. * @param trigger defines the trigger to process
  11508. * @param evt defines the event details to be processed
  11509. */
  11510. processTrigger(trigger: number, evt?: IActionEvent): void;
  11511. /** @hidden */
  11512. _getEffectiveTarget(target: any, propertyPath: string): any;
  11513. /** @hidden */
  11514. _getProperty(propertyPath: string): string;
  11515. /**
  11516. * Serialize this manager to a JSON object
  11517. * @param name defines the property name to store this manager
  11518. * @returns a JSON representation of this manager
  11519. */
  11520. serialize(name: string): any;
  11521. /**
  11522. * Creates a new ActionManager from a JSON data
  11523. * @param parsedActions defines the JSON data to read from
  11524. * @param object defines the hosting mesh
  11525. * @param scene defines the hosting scene
  11526. */
  11527. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11528. /**
  11529. * Get a trigger name by index
  11530. * @param trigger defines the trigger index
  11531. * @returns a trigger name
  11532. */
  11533. static GetTriggerName(trigger: number): string;
  11534. }
  11535. }
  11536. declare module "babylonjs/Culling/ray" {
  11537. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11538. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11540. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11541. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11542. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11543. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11544. /**
  11545. * Class representing a ray with position and direction
  11546. */
  11547. export class Ray {
  11548. /** origin point */
  11549. origin: Vector3;
  11550. /** direction */
  11551. direction: Vector3;
  11552. /** length of the ray */
  11553. length: number;
  11554. private static readonly TmpVector3;
  11555. private _tmpRay;
  11556. /**
  11557. * Creates a new ray
  11558. * @param origin origin point
  11559. * @param direction direction
  11560. * @param length length of the ray
  11561. */
  11562. constructor(
  11563. /** origin point */
  11564. origin: Vector3,
  11565. /** direction */
  11566. direction: Vector3,
  11567. /** length of the ray */
  11568. length?: number);
  11569. /**
  11570. * Checks if the ray intersects a box
  11571. * @param minimum bound of the box
  11572. * @param maximum bound of the box
  11573. * @param intersectionTreshold extra extend to be added to the box in all direction
  11574. * @returns if the box was hit
  11575. */
  11576. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11577. /**
  11578. * Checks if the ray intersects a box
  11579. * @param box the bounding box to check
  11580. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11581. * @returns if the box was hit
  11582. */
  11583. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11584. /**
  11585. * If the ray hits a sphere
  11586. * @param sphere the bounding sphere to check
  11587. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11588. * @returns true if it hits the sphere
  11589. */
  11590. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11591. /**
  11592. * If the ray hits a triange
  11593. * @param vertex0 triangle vertex
  11594. * @param vertex1 triangle vertex
  11595. * @param vertex2 triangle vertex
  11596. * @returns intersection information if hit
  11597. */
  11598. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11599. /**
  11600. * Checks if ray intersects a plane
  11601. * @param plane the plane to check
  11602. * @returns the distance away it was hit
  11603. */
  11604. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11605. /**
  11606. * Checks if ray intersects a mesh
  11607. * @param mesh the mesh to check
  11608. * @param fastCheck if only the bounding box should checked
  11609. * @returns picking info of the intersecton
  11610. */
  11611. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11612. /**
  11613. * Checks if ray intersects a mesh
  11614. * @param meshes the meshes to check
  11615. * @param fastCheck if only the bounding box should checked
  11616. * @param results array to store result in
  11617. * @returns Array of picking infos
  11618. */
  11619. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11620. private _comparePickingInfo;
  11621. private static smallnum;
  11622. private static rayl;
  11623. /**
  11624. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11625. * @param sega the first point of the segment to test the intersection against
  11626. * @param segb the second point of the segment to test the intersection against
  11627. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11628. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11629. */
  11630. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11631. /**
  11632. * Update the ray from viewport position
  11633. * @param x position
  11634. * @param y y position
  11635. * @param viewportWidth viewport width
  11636. * @param viewportHeight viewport height
  11637. * @param world world matrix
  11638. * @param view view matrix
  11639. * @param projection projection matrix
  11640. * @returns this ray updated
  11641. */
  11642. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11643. /**
  11644. * Creates a ray with origin and direction of 0,0,0
  11645. * @returns the new ray
  11646. */
  11647. static Zero(): Ray;
  11648. /**
  11649. * Creates a new ray from screen space and viewport
  11650. * @param x position
  11651. * @param y y position
  11652. * @param viewportWidth viewport width
  11653. * @param viewportHeight viewport height
  11654. * @param world world matrix
  11655. * @param view view matrix
  11656. * @param projection projection matrix
  11657. * @returns new ray
  11658. */
  11659. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11660. /**
  11661. * 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
  11662. * transformed to the given world matrix.
  11663. * @param origin The origin point
  11664. * @param end The end point
  11665. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11666. * @returns the new ray
  11667. */
  11668. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11669. /**
  11670. * Transforms a ray by a matrix
  11671. * @param ray ray to transform
  11672. * @param matrix matrix to apply
  11673. * @returns the resulting new ray
  11674. */
  11675. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11676. /**
  11677. * Transforms a ray by a matrix
  11678. * @param ray ray to transform
  11679. * @param matrix matrix to apply
  11680. * @param result ray to store result in
  11681. */
  11682. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11683. /**
  11684. * Unproject a ray from screen space to object space
  11685. * @param sourceX defines the screen space x coordinate to use
  11686. * @param sourceY defines the screen space y coordinate to use
  11687. * @param viewportWidth defines the current width of the viewport
  11688. * @param viewportHeight defines the current height of the viewport
  11689. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11690. * @param view defines the view matrix to use
  11691. * @param projection defines the projection matrix to use
  11692. */
  11693. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11694. }
  11695. /**
  11696. * Type used to define predicate used to select faces when a mesh intersection is detected
  11697. */
  11698. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11699. module "babylonjs/scene" {
  11700. interface Scene {
  11701. /** @hidden */
  11702. _tempPickingRay: Nullable<Ray>;
  11703. /** @hidden */
  11704. _cachedRayForTransform: Ray;
  11705. /** @hidden */
  11706. _pickWithRayInverseMatrix: Matrix;
  11707. /** @hidden */
  11708. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11709. /** @hidden */
  11710. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11711. }
  11712. }
  11713. }
  11714. declare module "babylonjs/sceneComponent" {
  11715. import { Scene } from "babylonjs/scene";
  11716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11717. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11718. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11719. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11720. import { Nullable } from "babylonjs/types";
  11721. import { Camera } from "babylonjs/Cameras/camera";
  11722. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11723. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11724. import { AbstractScene } from "babylonjs/abstractScene";
  11725. /**
  11726. * Groups all the scene component constants in one place to ease maintenance.
  11727. * @hidden
  11728. */
  11729. export class SceneComponentConstants {
  11730. static readonly NAME_EFFECTLAYER: string;
  11731. static readonly NAME_LAYER: string;
  11732. static readonly NAME_LENSFLARESYSTEM: string;
  11733. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11734. static readonly NAME_PARTICLESYSTEM: string;
  11735. static readonly NAME_GAMEPAD: string;
  11736. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11737. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11738. static readonly NAME_DEPTHRENDERER: string;
  11739. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11740. static readonly NAME_SPRITE: string;
  11741. static readonly NAME_OUTLINERENDERER: string;
  11742. static readonly NAME_PROCEDURALTEXTURE: string;
  11743. static readonly NAME_SHADOWGENERATOR: string;
  11744. static readonly NAME_OCTREE: string;
  11745. static readonly NAME_PHYSICSENGINE: string;
  11746. static readonly NAME_AUDIO: string;
  11747. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11748. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11749. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11750. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11751. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11752. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11753. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11754. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11755. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11756. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11757. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11758. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11759. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11760. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11761. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11762. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11763. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11764. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11765. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11766. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11767. static readonly STEP_AFTERRENDER_AUDIO: number;
  11768. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11769. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11770. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11771. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11772. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11773. static readonly STEP_POINTERMOVE_SPRITE: number;
  11774. static readonly STEP_POINTERDOWN_SPRITE: number;
  11775. static readonly STEP_POINTERUP_SPRITE: number;
  11776. }
  11777. /**
  11778. * This represents a scene component.
  11779. *
  11780. * This is used to decouple the dependency the scene is having on the different workloads like
  11781. * layers, post processes...
  11782. */
  11783. export interface ISceneComponent {
  11784. /**
  11785. * The name of the component. Each component must have a unique name.
  11786. */
  11787. name: string;
  11788. /**
  11789. * The scene the component belongs to.
  11790. */
  11791. scene: Scene;
  11792. /**
  11793. * Register the component to one instance of a scene.
  11794. */
  11795. register(): void;
  11796. /**
  11797. * Rebuilds the elements related to this component in case of
  11798. * context lost for instance.
  11799. */
  11800. rebuild(): void;
  11801. /**
  11802. * Disposes the component and the associated ressources.
  11803. */
  11804. dispose(): void;
  11805. }
  11806. /**
  11807. * This represents a SERIALIZABLE scene component.
  11808. *
  11809. * This extends Scene Component to add Serialization methods on top.
  11810. */
  11811. export interface ISceneSerializableComponent extends ISceneComponent {
  11812. /**
  11813. * Adds all the element from the container to the scene
  11814. * @param container the container holding the elements
  11815. */
  11816. addFromContainer(container: AbstractScene): void;
  11817. /**
  11818. * Removes all the elements in the container from the scene
  11819. * @param container contains the elements to remove
  11820. * @param dispose if the removed element should be disposed (default: false)
  11821. */
  11822. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11823. /**
  11824. * Serializes the component data to the specified json object
  11825. * @param serializationObject The object to serialize to
  11826. */
  11827. serialize(serializationObject: any): void;
  11828. }
  11829. /**
  11830. * Strong typing of a Mesh related stage step action
  11831. */
  11832. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11833. /**
  11834. * Strong typing of a Evaluate Sub Mesh related stage step action
  11835. */
  11836. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11837. /**
  11838. * Strong typing of a Active Mesh related stage step action
  11839. */
  11840. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11841. /**
  11842. * Strong typing of a Camera related stage step action
  11843. */
  11844. export type CameraStageAction = (camera: Camera) => void;
  11845. /**
  11846. * Strong typing of a Camera Frame buffer related stage step action
  11847. */
  11848. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11849. /**
  11850. * Strong typing of a Render Target related stage step action
  11851. */
  11852. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11853. /**
  11854. * Strong typing of a RenderingGroup related stage step action
  11855. */
  11856. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11857. /**
  11858. * Strong typing of a Mesh Render related stage step action
  11859. */
  11860. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11861. /**
  11862. * Strong typing of a simple stage step action
  11863. */
  11864. export type SimpleStageAction = () => void;
  11865. /**
  11866. * Strong typing of a render target action.
  11867. */
  11868. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11869. /**
  11870. * Strong typing of a pointer move action.
  11871. */
  11872. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11873. /**
  11874. * Strong typing of a pointer up/down action.
  11875. */
  11876. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11877. /**
  11878. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11879. * @hidden
  11880. */
  11881. export class Stage<T extends Function> extends Array<{
  11882. index: number;
  11883. component: ISceneComponent;
  11884. action: T;
  11885. }> {
  11886. /**
  11887. * Hide ctor from the rest of the world.
  11888. * @param items The items to add.
  11889. */
  11890. private constructor();
  11891. /**
  11892. * Creates a new Stage.
  11893. * @returns A new instance of a Stage
  11894. */
  11895. static Create<T extends Function>(): Stage<T>;
  11896. /**
  11897. * Registers a step in an ordered way in the targeted stage.
  11898. * @param index Defines the position to register the step in
  11899. * @param component Defines the component attached to the step
  11900. * @param action Defines the action to launch during the step
  11901. */
  11902. registerStep(index: number, component: ISceneComponent, action: T): void;
  11903. /**
  11904. * Clears all the steps from the stage.
  11905. */
  11906. clear(): void;
  11907. }
  11908. }
  11909. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11910. import { Nullable } from "babylonjs/types";
  11911. import { Observable } from "babylonjs/Misc/observable";
  11912. import { Scene } from "babylonjs/scene";
  11913. import { Sprite } from "babylonjs/Sprites/sprite";
  11914. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11915. import { Ray } from "babylonjs/Culling/ray";
  11916. import { Camera } from "babylonjs/Cameras/camera";
  11917. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11918. import { ISceneComponent } from "babylonjs/sceneComponent";
  11919. module "babylonjs/scene" {
  11920. interface Scene {
  11921. /** @hidden */
  11922. _pointerOverSprite: Nullable<Sprite>;
  11923. /** @hidden */
  11924. _pickedDownSprite: Nullable<Sprite>;
  11925. /** @hidden */
  11926. _tempSpritePickingRay: Nullable<Ray>;
  11927. /**
  11928. * All of the sprite managers added to this scene
  11929. * @see http://doc.babylonjs.com/babylon101/sprites
  11930. */
  11931. spriteManagers: Array<ISpriteManager>;
  11932. /**
  11933. * An event triggered when sprites rendering is about to start
  11934. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11935. */
  11936. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11937. /**
  11938. * An event triggered when sprites rendering is done
  11939. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11940. */
  11941. onAfterSpritesRenderingObservable: Observable<Scene>;
  11942. /** @hidden */
  11943. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11944. /** Launch a ray to try to pick a sprite in the scene
  11945. * @param x position on screen
  11946. * @param y position on screen
  11947. * @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
  11948. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11949. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11950. * @returns a PickingInfo
  11951. */
  11952. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11953. /** Use the given ray to pick a sprite in the scene
  11954. * @param ray The ray (in world space) to use to pick meshes
  11955. * @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
  11956. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11957. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11958. * @returns a PickingInfo
  11959. */
  11960. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11961. /**
  11962. * Force the sprite under the pointer
  11963. * @param sprite defines the sprite to use
  11964. */
  11965. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11966. /**
  11967. * Gets the sprite under the pointer
  11968. * @returns a Sprite or null if no sprite is under the pointer
  11969. */
  11970. getPointerOverSprite(): Nullable<Sprite>;
  11971. }
  11972. }
  11973. /**
  11974. * Defines the sprite scene component responsible to manage sprites
  11975. * in a given scene.
  11976. */
  11977. export class SpriteSceneComponent implements ISceneComponent {
  11978. /**
  11979. * The component name helpfull to identify the component in the list of scene components.
  11980. */
  11981. readonly name: string;
  11982. /**
  11983. * The scene the component belongs to.
  11984. */
  11985. scene: Scene;
  11986. /** @hidden */
  11987. private _spritePredicate;
  11988. /**
  11989. * Creates a new instance of the component for the given scene
  11990. * @param scene Defines the scene to register the component in
  11991. */
  11992. constructor(scene: Scene);
  11993. /**
  11994. * Registers the component in a given scene
  11995. */
  11996. register(): void;
  11997. /**
  11998. * Rebuilds the elements related to this component in case of
  11999. * context lost for instance.
  12000. */
  12001. rebuild(): void;
  12002. /**
  12003. * Disposes the component and the associated ressources.
  12004. */
  12005. dispose(): void;
  12006. private _pickSpriteButKeepRay;
  12007. private _pointerMove;
  12008. private _pointerDown;
  12009. private _pointerUp;
  12010. }
  12011. }
  12012. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  12013. /** @hidden */
  12014. export var fogFragmentDeclaration: {
  12015. name: string;
  12016. shader: string;
  12017. };
  12018. }
  12019. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12020. /** @hidden */
  12021. export var fogFragment: {
  12022. name: string;
  12023. shader: string;
  12024. };
  12025. }
  12026. declare module "babylonjs/Shaders/sprites.fragment" {
  12027. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12028. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12029. /** @hidden */
  12030. export var spritesPixelShader: {
  12031. name: string;
  12032. shader: string;
  12033. };
  12034. }
  12035. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12036. /** @hidden */
  12037. export var fogVertexDeclaration: {
  12038. name: string;
  12039. shader: string;
  12040. };
  12041. }
  12042. declare module "babylonjs/Shaders/sprites.vertex" {
  12043. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12044. /** @hidden */
  12045. export var spritesVertexShader: {
  12046. name: string;
  12047. shader: string;
  12048. };
  12049. }
  12050. declare module "babylonjs/Sprites/spriteManager" {
  12051. import { IDisposable, Scene } from "babylonjs/scene";
  12052. import { Nullable } from "babylonjs/types";
  12053. import { Observable } from "babylonjs/Misc/observable";
  12054. import { Sprite } from "babylonjs/Sprites/sprite";
  12055. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12056. import { Camera } from "babylonjs/Cameras/camera";
  12057. import { Texture } from "babylonjs/Materials/Textures/texture";
  12058. import "babylonjs/Shaders/sprites.fragment";
  12059. import "babylonjs/Shaders/sprites.vertex";
  12060. import { Ray } from "babylonjs/Culling/ray";
  12061. /**
  12062. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12063. */
  12064. export interface ISpriteManager extends IDisposable {
  12065. /**
  12066. * Restricts the camera to viewing objects with the same layerMask.
  12067. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12068. */
  12069. layerMask: number;
  12070. /**
  12071. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12072. */
  12073. isPickable: boolean;
  12074. /**
  12075. * Specifies the rendering group id for this mesh (0 by default)
  12076. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12077. */
  12078. renderingGroupId: number;
  12079. /**
  12080. * Defines the list of sprites managed by the manager.
  12081. */
  12082. sprites: Array<Sprite>;
  12083. /**
  12084. * Tests the intersection of a sprite with a specific ray.
  12085. * @param ray The ray we are sending to test the collision
  12086. * @param camera The camera space we are sending rays in
  12087. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12088. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12089. * @returns picking info or null.
  12090. */
  12091. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12092. /**
  12093. * Renders the list of sprites on screen.
  12094. */
  12095. render(): void;
  12096. }
  12097. /**
  12098. * Class used to manage multiple sprites on the same spritesheet
  12099. * @see http://doc.babylonjs.com/babylon101/sprites
  12100. */
  12101. export class SpriteManager implements ISpriteManager {
  12102. /** defines the manager's name */
  12103. name: string;
  12104. /** Gets the list of sprites */
  12105. sprites: Sprite[];
  12106. /** Gets or sets the rendering group id (0 by default) */
  12107. renderingGroupId: number;
  12108. /** Gets or sets camera layer mask */
  12109. layerMask: number;
  12110. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12111. fogEnabled: boolean;
  12112. /** Gets or sets a boolean indicating if the sprites are pickable */
  12113. isPickable: boolean;
  12114. /** Defines the default width of a cell in the spritesheet */
  12115. cellWidth: number;
  12116. /** Defines the default height of a cell in the spritesheet */
  12117. cellHeight: number;
  12118. /**
  12119. * An event triggered when the manager is disposed.
  12120. */
  12121. onDisposeObservable: Observable<SpriteManager>;
  12122. private _onDisposeObserver;
  12123. /**
  12124. * Callback called when the manager is disposed
  12125. */
  12126. onDispose: () => void;
  12127. private _capacity;
  12128. private _spriteTexture;
  12129. private _epsilon;
  12130. private _scene;
  12131. private _vertexData;
  12132. private _buffer;
  12133. private _vertexBuffers;
  12134. private _indexBuffer;
  12135. private _effectBase;
  12136. private _effectFog;
  12137. /**
  12138. * Gets or sets the spritesheet texture
  12139. */
  12140. texture: Texture;
  12141. /**
  12142. * Creates a new sprite manager
  12143. * @param name defines the manager's name
  12144. * @param imgUrl defines the sprite sheet url
  12145. * @param capacity defines the maximum allowed number of sprites
  12146. * @param cellSize defines the size of a sprite cell
  12147. * @param scene defines the hosting scene
  12148. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12149. * @param samplingMode defines the smapling mode to use with spritesheet
  12150. */
  12151. constructor(
  12152. /** defines the manager's name */
  12153. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12154. private _appendSpriteVertex;
  12155. /**
  12156. * Intersects the sprites with a ray
  12157. * @param ray defines the ray to intersect with
  12158. * @param camera defines the current active camera
  12159. * @param predicate defines a predicate used to select candidate sprites
  12160. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12161. * @returns null if no hit or a PickingInfo
  12162. */
  12163. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12164. /**
  12165. * Render all child sprites
  12166. */
  12167. render(): void;
  12168. /**
  12169. * Release associated resources
  12170. */
  12171. dispose(): void;
  12172. }
  12173. }
  12174. declare module "babylonjs/Sprites/sprite" {
  12175. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12176. import { Nullable } from "babylonjs/types";
  12177. import { ActionManager } from "babylonjs/Actions/actionManager";
  12178. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12179. /**
  12180. * Class used to represent a sprite
  12181. * @see http://doc.babylonjs.com/babylon101/sprites
  12182. */
  12183. export class Sprite {
  12184. /** defines the name */
  12185. name: string;
  12186. /** Gets or sets the current world position */
  12187. position: Vector3;
  12188. /** Gets or sets the main color */
  12189. color: Color4;
  12190. /** Gets or sets the width */
  12191. width: number;
  12192. /** Gets or sets the height */
  12193. height: number;
  12194. /** Gets or sets rotation angle */
  12195. angle: number;
  12196. /** Gets or sets the cell index in the sprite sheet */
  12197. cellIndex: number;
  12198. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12199. invertU: number;
  12200. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12201. invertV: number;
  12202. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12203. disposeWhenFinishedAnimating: boolean;
  12204. /** Gets the list of attached animations */
  12205. animations: Animation[];
  12206. /** Gets or sets a boolean indicating if the sprite can be picked */
  12207. isPickable: boolean;
  12208. /**
  12209. * Gets or sets the associated action manager
  12210. */
  12211. actionManager: Nullable<ActionManager>;
  12212. private _animationStarted;
  12213. private _loopAnimation;
  12214. private _fromIndex;
  12215. private _toIndex;
  12216. private _delay;
  12217. private _direction;
  12218. private _manager;
  12219. private _time;
  12220. private _onAnimationEnd;
  12221. /**
  12222. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12223. */
  12224. isVisible: boolean;
  12225. /**
  12226. * Gets or sets the sprite size
  12227. */
  12228. size: number;
  12229. /**
  12230. * Creates a new Sprite
  12231. * @param name defines the name
  12232. * @param manager defines the manager
  12233. */
  12234. constructor(
  12235. /** defines the name */
  12236. name: string, manager: ISpriteManager);
  12237. /**
  12238. * Starts an animation
  12239. * @param from defines the initial key
  12240. * @param to defines the end key
  12241. * @param loop defines if the animation must loop
  12242. * @param delay defines the start delay (in ms)
  12243. * @param onAnimationEnd defines a callback to call when animation ends
  12244. */
  12245. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12246. /** Stops current animation (if any) */
  12247. stopAnimation(): void;
  12248. /** @hidden */
  12249. _animate(deltaTime: number): void;
  12250. /** Release associated resources */
  12251. dispose(): void;
  12252. }
  12253. }
  12254. declare module "babylonjs/Collisions/pickingInfo" {
  12255. import { Nullable } from "babylonjs/types";
  12256. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12258. import { Sprite } from "babylonjs/Sprites/sprite";
  12259. import { Ray } from "babylonjs/Culling/ray";
  12260. /**
  12261. * Information about the result of picking within a scene
  12262. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12263. */
  12264. export class PickingInfo {
  12265. /** @hidden */
  12266. _pickingUnavailable: boolean;
  12267. /**
  12268. * If the pick collided with an object
  12269. */
  12270. hit: boolean;
  12271. /**
  12272. * Distance away where the pick collided
  12273. */
  12274. distance: number;
  12275. /**
  12276. * The location of pick collision
  12277. */
  12278. pickedPoint: Nullable<Vector3>;
  12279. /**
  12280. * The mesh corresponding the the pick collision
  12281. */
  12282. pickedMesh: Nullable<AbstractMesh>;
  12283. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12284. bu: number;
  12285. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12286. bv: number;
  12287. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12288. faceId: number;
  12289. /** Id of the the submesh that was picked */
  12290. subMeshId: number;
  12291. /** If a sprite was picked, this will be the sprite the pick collided with */
  12292. pickedSprite: Nullable<Sprite>;
  12293. /**
  12294. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12295. */
  12296. originMesh: Nullable<AbstractMesh>;
  12297. /**
  12298. * The ray that was used to perform the picking.
  12299. */
  12300. ray: Nullable<Ray>;
  12301. /**
  12302. * Gets the normal correspodning to the face the pick collided with
  12303. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12304. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12305. * @returns The normal correspodning to the face the pick collided with
  12306. */
  12307. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12308. /**
  12309. * Gets the texture coordinates of where the pick occured
  12310. * @returns the vector containing the coordnates of the texture
  12311. */
  12312. getTextureCoordinates(): Nullable<Vector2>;
  12313. }
  12314. }
  12315. declare module "babylonjs/Events/pointerEvents" {
  12316. import { Nullable } from "babylonjs/types";
  12317. import { Vector2 } from "babylonjs/Maths/math";
  12318. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12319. import { Ray } from "babylonjs/Culling/ray";
  12320. /**
  12321. * Gather the list of pointer event types as constants.
  12322. */
  12323. export class PointerEventTypes {
  12324. /**
  12325. * 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.
  12326. */
  12327. static readonly POINTERDOWN: number;
  12328. /**
  12329. * The pointerup event is fired when a pointer is no longer active.
  12330. */
  12331. static readonly POINTERUP: number;
  12332. /**
  12333. * The pointermove event is fired when a pointer changes coordinates.
  12334. */
  12335. static readonly POINTERMOVE: number;
  12336. /**
  12337. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12338. */
  12339. static readonly POINTERWHEEL: number;
  12340. /**
  12341. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12342. */
  12343. static readonly POINTERPICK: number;
  12344. /**
  12345. * The pointertap event is fired when a the object has been touched and released without drag.
  12346. */
  12347. static readonly POINTERTAP: number;
  12348. /**
  12349. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12350. */
  12351. static readonly POINTERDOUBLETAP: number;
  12352. }
  12353. /**
  12354. * Base class of pointer info types.
  12355. */
  12356. export class PointerInfoBase {
  12357. /**
  12358. * Defines the type of event (PointerEventTypes)
  12359. */
  12360. type: number;
  12361. /**
  12362. * Defines the related dom event
  12363. */
  12364. event: PointerEvent | MouseWheelEvent;
  12365. /**
  12366. * Instantiates the base class of pointers info.
  12367. * @param type Defines the type of event (PointerEventTypes)
  12368. * @param event Defines the related dom event
  12369. */
  12370. constructor(
  12371. /**
  12372. * Defines the type of event (PointerEventTypes)
  12373. */
  12374. type: number,
  12375. /**
  12376. * Defines the related dom event
  12377. */
  12378. event: PointerEvent | MouseWheelEvent);
  12379. }
  12380. /**
  12381. * This class is used to store pointer related info for the onPrePointerObservable event.
  12382. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12383. */
  12384. export class PointerInfoPre extends PointerInfoBase {
  12385. /**
  12386. * Ray from a pointer if availible (eg. 6dof controller)
  12387. */
  12388. ray: Nullable<Ray>;
  12389. /**
  12390. * Defines the local position of the pointer on the canvas.
  12391. */
  12392. localPosition: Vector2;
  12393. /**
  12394. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12395. */
  12396. skipOnPointerObservable: boolean;
  12397. /**
  12398. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12399. * @param type Defines the type of event (PointerEventTypes)
  12400. * @param event Defines the related dom event
  12401. * @param localX Defines the local x coordinates of the pointer when the event occured
  12402. * @param localY Defines the local y coordinates of the pointer when the event occured
  12403. */
  12404. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12405. }
  12406. /**
  12407. * This type contains all the data related to a pointer event in Babylon.js.
  12408. * 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.
  12409. */
  12410. export class PointerInfo extends PointerInfoBase {
  12411. /**
  12412. * Defines the picking info associated to the info (if any)\
  12413. */
  12414. pickInfo: Nullable<PickingInfo>;
  12415. /**
  12416. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12417. * @param type Defines the type of event (PointerEventTypes)
  12418. * @param event Defines the related dom event
  12419. * @param pickInfo Defines the picking info associated to the info (if any)\
  12420. */
  12421. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12422. /**
  12423. * Defines the picking info associated to the info (if any)\
  12424. */
  12425. pickInfo: Nullable<PickingInfo>);
  12426. }
  12427. /**
  12428. * Data relating to a touch event on the screen.
  12429. */
  12430. export interface PointerTouch {
  12431. /**
  12432. * X coordinate of touch.
  12433. */
  12434. x: number;
  12435. /**
  12436. * Y coordinate of touch.
  12437. */
  12438. y: number;
  12439. /**
  12440. * Id of touch. Unique for each finger.
  12441. */
  12442. pointerId: number;
  12443. /**
  12444. * Event type passed from DOM.
  12445. */
  12446. type: any;
  12447. }
  12448. }
  12449. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12450. import { Observable } from "babylonjs/Misc/observable";
  12451. import { Nullable } from "babylonjs/types";
  12452. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12453. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12454. /**
  12455. * Manage the mouse inputs to control the movement of a free camera.
  12456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12457. */
  12458. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12459. /**
  12460. * Define if touch is enabled in the mouse input
  12461. */
  12462. touchEnabled: boolean;
  12463. /**
  12464. * Defines the camera the input is attached to.
  12465. */
  12466. camera: FreeCamera;
  12467. /**
  12468. * Defines the buttons associated with the input to handle camera move.
  12469. */
  12470. buttons: number[];
  12471. /**
  12472. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12473. */
  12474. angularSensibility: number;
  12475. private _pointerInput;
  12476. private _onMouseMove;
  12477. private _observer;
  12478. private previousPosition;
  12479. /**
  12480. * Observable for when a pointer move event occurs containing the move offset
  12481. */
  12482. onPointerMovedObservable: Observable<{
  12483. offsetX: number;
  12484. offsetY: number;
  12485. }>;
  12486. /**
  12487. * @hidden
  12488. * If the camera should be rotated automatically based on pointer movement
  12489. */
  12490. _allowCameraRotation: boolean;
  12491. /**
  12492. * Manage the mouse inputs to control the movement of a free camera.
  12493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12494. * @param touchEnabled Defines if touch is enabled or not
  12495. */
  12496. constructor(
  12497. /**
  12498. * Define if touch is enabled in the mouse input
  12499. */
  12500. touchEnabled?: boolean);
  12501. /**
  12502. * Attach the input controls to a specific dom element to get the input from.
  12503. * @param element Defines the element the controls should be listened from
  12504. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12505. */
  12506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12507. /**
  12508. * Called on JS contextmenu event.
  12509. * Override this method to provide functionality.
  12510. */
  12511. protected onContextMenu(evt: PointerEvent): void;
  12512. /**
  12513. * Detach the current controls from the specified dom element.
  12514. * @param element Defines the element to stop listening the inputs from
  12515. */
  12516. detachControl(element: Nullable<HTMLElement>): void;
  12517. /**
  12518. * Gets the class name of the current intput.
  12519. * @returns the class name
  12520. */
  12521. getClassName(): string;
  12522. /**
  12523. * Get the friendly name associated with the input class.
  12524. * @returns the input friendly name
  12525. */
  12526. getSimpleName(): string;
  12527. }
  12528. }
  12529. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12530. import { Nullable } from "babylonjs/types";
  12531. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12532. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12533. /**
  12534. * Manage the touch inputs to control the movement of a free camera.
  12535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12536. */
  12537. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12538. /**
  12539. * Defines the camera the input is attached to.
  12540. */
  12541. camera: FreeCamera;
  12542. /**
  12543. * Defines the touch sensibility for rotation.
  12544. * The higher the faster.
  12545. */
  12546. touchAngularSensibility: number;
  12547. /**
  12548. * Defines the touch sensibility for move.
  12549. * The higher the faster.
  12550. */
  12551. touchMoveSensibility: number;
  12552. private _offsetX;
  12553. private _offsetY;
  12554. private _pointerPressed;
  12555. private _pointerInput;
  12556. private _observer;
  12557. private _onLostFocus;
  12558. /**
  12559. * Attach the input controls to a specific dom element to get the input from.
  12560. * @param element Defines the element the controls should be listened from
  12561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12562. */
  12563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12564. /**
  12565. * Detach the current controls from the specified dom element.
  12566. * @param element Defines the element to stop listening the inputs from
  12567. */
  12568. detachControl(element: Nullable<HTMLElement>): void;
  12569. /**
  12570. * Update the current camera state depending on the inputs that have been used this frame.
  12571. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12572. */
  12573. checkInputs(): void;
  12574. /**
  12575. * Gets the class name of the current intput.
  12576. * @returns the class name
  12577. */
  12578. getClassName(): string;
  12579. /**
  12580. * Get the friendly name associated with the input class.
  12581. * @returns the input friendly name
  12582. */
  12583. getSimpleName(): string;
  12584. }
  12585. }
  12586. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12587. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12588. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12589. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12590. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12591. import { Nullable } from "babylonjs/types";
  12592. /**
  12593. * Default Inputs manager for the FreeCamera.
  12594. * It groups all the default supported inputs for ease of use.
  12595. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12596. */
  12597. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12598. /**
  12599. * @hidden
  12600. */
  12601. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12602. /**
  12603. * @hidden
  12604. */
  12605. _mouseInput: Nullable<FreeCameraMouseInput>;
  12606. /**
  12607. * Instantiates a new FreeCameraInputsManager.
  12608. * @param camera Defines the camera the inputs belong to
  12609. */
  12610. constructor(camera: FreeCamera);
  12611. /**
  12612. * Add keyboard input support to the input manager.
  12613. * @returns the current input manager
  12614. */
  12615. addKeyboard(): FreeCameraInputsManager;
  12616. /**
  12617. * Add mouse input support to the input manager.
  12618. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12619. * @returns the current input manager
  12620. */
  12621. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12622. /**
  12623. * Removes the mouse input support from the manager
  12624. * @returns the current input manager
  12625. */
  12626. removeMouse(): FreeCameraInputsManager;
  12627. /**
  12628. * Add touch input support to the input manager.
  12629. * @returns the current input manager
  12630. */
  12631. addTouch(): FreeCameraInputsManager;
  12632. }
  12633. }
  12634. declare module "babylonjs/Cameras/freeCamera" {
  12635. import { Vector3 } from "babylonjs/Maths/math";
  12636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12637. import { Scene } from "babylonjs/scene";
  12638. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12639. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12640. /**
  12641. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12642. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12643. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12644. */
  12645. export class FreeCamera extends TargetCamera {
  12646. /**
  12647. * Define the collision ellipsoid of the camera.
  12648. * This is helpful to simulate a camera body like the player body around the camera
  12649. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12650. */
  12651. ellipsoid: Vector3;
  12652. /**
  12653. * Define an offset for the position of the ellipsoid around the camera.
  12654. * This can be helpful to determine the center of the body near the gravity center of the body
  12655. * instead of its head.
  12656. */
  12657. ellipsoidOffset: Vector3;
  12658. /**
  12659. * Enable or disable collisions of the camera with the rest of the scene objects.
  12660. */
  12661. checkCollisions: boolean;
  12662. /**
  12663. * Enable or disable gravity on the camera.
  12664. */
  12665. applyGravity: boolean;
  12666. /**
  12667. * Define the input manager associated to the camera.
  12668. */
  12669. inputs: FreeCameraInputsManager;
  12670. /**
  12671. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12672. * Higher values reduce sensitivity.
  12673. */
  12674. /**
  12675. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12676. * Higher values reduce sensitivity.
  12677. */
  12678. angularSensibility: number;
  12679. /**
  12680. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12681. */
  12682. keysUp: number[];
  12683. /**
  12684. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12685. */
  12686. keysDown: number[];
  12687. /**
  12688. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12689. */
  12690. keysLeft: number[];
  12691. /**
  12692. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12693. */
  12694. keysRight: number[];
  12695. /**
  12696. * Event raised when the camera collide with a mesh in the scene.
  12697. */
  12698. onCollide: (collidedMesh: AbstractMesh) => void;
  12699. private _collider;
  12700. private _needMoveForGravity;
  12701. private _oldPosition;
  12702. private _diffPosition;
  12703. private _newPosition;
  12704. /** @hidden */
  12705. _localDirection: Vector3;
  12706. /** @hidden */
  12707. _transformedDirection: Vector3;
  12708. /**
  12709. * Instantiates a Free Camera.
  12710. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12711. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12712. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12713. * @param name Define the name of the camera in the scene
  12714. * @param position Define the start position of the camera in the scene
  12715. * @param scene Define the scene the camera belongs to
  12716. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12717. */
  12718. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12719. /**
  12720. * Attached controls to the current camera.
  12721. * @param element Defines the element the controls should be listened from
  12722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12723. */
  12724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12725. /**
  12726. * Detach the current controls from the camera.
  12727. * The camera will stop reacting to inputs.
  12728. * @param element Defines the element to stop listening the inputs from
  12729. */
  12730. detachControl(element: HTMLElement): void;
  12731. private _collisionMask;
  12732. /**
  12733. * Define a collision mask to limit the list of object the camera can collide with
  12734. */
  12735. collisionMask: number;
  12736. /** @hidden */
  12737. _collideWithWorld(displacement: Vector3): void;
  12738. private _onCollisionPositionChange;
  12739. /** @hidden */
  12740. _checkInputs(): void;
  12741. /** @hidden */
  12742. _decideIfNeedsToMove(): boolean;
  12743. /** @hidden */
  12744. _updatePosition(): void;
  12745. /**
  12746. * Destroy the camera and release the current resources hold by it.
  12747. */
  12748. dispose(): void;
  12749. /**
  12750. * Gets the current object class name.
  12751. * @return the class name
  12752. */
  12753. getClassName(): string;
  12754. }
  12755. }
  12756. declare module "babylonjs/Gamepads/gamepad" {
  12757. import { Observable } from "babylonjs/Misc/observable";
  12758. /**
  12759. * Represents a gamepad control stick position
  12760. */
  12761. export class StickValues {
  12762. /**
  12763. * The x component of the control stick
  12764. */
  12765. x: number;
  12766. /**
  12767. * The y component of the control stick
  12768. */
  12769. y: number;
  12770. /**
  12771. * Initializes the gamepad x and y control stick values
  12772. * @param x The x component of the gamepad control stick value
  12773. * @param y The y component of the gamepad control stick value
  12774. */
  12775. constructor(
  12776. /**
  12777. * The x component of the control stick
  12778. */
  12779. x: number,
  12780. /**
  12781. * The y component of the control stick
  12782. */
  12783. y: number);
  12784. }
  12785. /**
  12786. * An interface which manages callbacks for gamepad button changes
  12787. */
  12788. export interface GamepadButtonChanges {
  12789. /**
  12790. * Called when a gamepad has been changed
  12791. */
  12792. changed: boolean;
  12793. /**
  12794. * Called when a gamepad press event has been triggered
  12795. */
  12796. pressChanged: boolean;
  12797. /**
  12798. * Called when a touch event has been triggered
  12799. */
  12800. touchChanged: boolean;
  12801. /**
  12802. * Called when a value has changed
  12803. */
  12804. valueChanged: boolean;
  12805. }
  12806. /**
  12807. * Represents a gamepad
  12808. */
  12809. export class Gamepad {
  12810. /**
  12811. * The id of the gamepad
  12812. */
  12813. id: string;
  12814. /**
  12815. * The index of the gamepad
  12816. */
  12817. index: number;
  12818. /**
  12819. * The browser gamepad
  12820. */
  12821. browserGamepad: any;
  12822. /**
  12823. * Specifies what type of gamepad this represents
  12824. */
  12825. type: number;
  12826. private _leftStick;
  12827. private _rightStick;
  12828. /** @hidden */
  12829. _isConnected: boolean;
  12830. private _leftStickAxisX;
  12831. private _leftStickAxisY;
  12832. private _rightStickAxisX;
  12833. private _rightStickAxisY;
  12834. /**
  12835. * Triggered when the left control stick has been changed
  12836. */
  12837. private _onleftstickchanged;
  12838. /**
  12839. * Triggered when the right control stick has been changed
  12840. */
  12841. private _onrightstickchanged;
  12842. /**
  12843. * Represents a gamepad controller
  12844. */
  12845. static GAMEPAD: number;
  12846. /**
  12847. * Represents a generic controller
  12848. */
  12849. static GENERIC: number;
  12850. /**
  12851. * Represents an XBox controller
  12852. */
  12853. static XBOX: number;
  12854. /**
  12855. * Represents a pose-enabled controller
  12856. */
  12857. static POSE_ENABLED: number;
  12858. /**
  12859. * Specifies whether the left control stick should be Y-inverted
  12860. */
  12861. protected _invertLeftStickY: boolean;
  12862. /**
  12863. * Specifies if the gamepad has been connected
  12864. */
  12865. readonly isConnected: boolean;
  12866. /**
  12867. * Initializes the gamepad
  12868. * @param id The id of the gamepad
  12869. * @param index The index of the gamepad
  12870. * @param browserGamepad The browser gamepad
  12871. * @param leftStickX The x component of the left joystick
  12872. * @param leftStickY The y component of the left joystick
  12873. * @param rightStickX The x component of the right joystick
  12874. * @param rightStickY The y component of the right joystick
  12875. */
  12876. constructor(
  12877. /**
  12878. * The id of the gamepad
  12879. */
  12880. id: string,
  12881. /**
  12882. * The index of the gamepad
  12883. */
  12884. index: number,
  12885. /**
  12886. * The browser gamepad
  12887. */
  12888. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12889. /**
  12890. * Callback triggered when the left joystick has changed
  12891. * @param callback
  12892. */
  12893. onleftstickchanged(callback: (values: StickValues) => void): void;
  12894. /**
  12895. * Callback triggered when the right joystick has changed
  12896. * @param callback
  12897. */
  12898. onrightstickchanged(callback: (values: StickValues) => void): void;
  12899. /**
  12900. * Gets the left joystick
  12901. */
  12902. /**
  12903. * Sets the left joystick values
  12904. */
  12905. leftStick: StickValues;
  12906. /**
  12907. * Gets the right joystick
  12908. */
  12909. /**
  12910. * Sets the right joystick value
  12911. */
  12912. rightStick: StickValues;
  12913. /**
  12914. * Updates the gamepad joystick positions
  12915. */
  12916. update(): void;
  12917. /**
  12918. * Disposes the gamepad
  12919. */
  12920. dispose(): void;
  12921. }
  12922. /**
  12923. * Represents a generic gamepad
  12924. */
  12925. export class GenericPad extends Gamepad {
  12926. private _buttons;
  12927. private _onbuttondown;
  12928. private _onbuttonup;
  12929. /**
  12930. * Observable triggered when a button has been pressed
  12931. */
  12932. onButtonDownObservable: Observable<number>;
  12933. /**
  12934. * Observable triggered when a button has been released
  12935. */
  12936. onButtonUpObservable: Observable<number>;
  12937. /**
  12938. * Callback triggered when a button has been pressed
  12939. * @param callback Called when a button has been pressed
  12940. */
  12941. onbuttondown(callback: (buttonPressed: number) => void): void;
  12942. /**
  12943. * Callback triggered when a button has been released
  12944. * @param callback Called when a button has been released
  12945. */
  12946. onbuttonup(callback: (buttonReleased: number) => void): void;
  12947. /**
  12948. * Initializes the generic gamepad
  12949. * @param id The id of the generic gamepad
  12950. * @param index The index of the generic gamepad
  12951. * @param browserGamepad The browser gamepad
  12952. */
  12953. constructor(id: string, index: number, browserGamepad: any);
  12954. private _setButtonValue;
  12955. /**
  12956. * Updates the generic gamepad
  12957. */
  12958. update(): void;
  12959. /**
  12960. * Disposes the generic gamepad
  12961. */
  12962. dispose(): void;
  12963. }
  12964. }
  12965. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12966. import { Observable } from "babylonjs/Misc/observable";
  12967. import { Nullable } from "babylonjs/types";
  12968. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12969. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12971. import { Ray } from "babylonjs/Culling/ray";
  12972. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12973. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12974. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12975. /**
  12976. * Defines the types of pose enabled controllers that are supported
  12977. */
  12978. export enum PoseEnabledControllerType {
  12979. /**
  12980. * HTC Vive
  12981. */
  12982. VIVE = 0,
  12983. /**
  12984. * Oculus Rift
  12985. */
  12986. OCULUS = 1,
  12987. /**
  12988. * Windows mixed reality
  12989. */
  12990. WINDOWS = 2,
  12991. /**
  12992. * Samsung gear VR
  12993. */
  12994. GEAR_VR = 3,
  12995. /**
  12996. * Google Daydream
  12997. */
  12998. DAYDREAM = 4,
  12999. /**
  13000. * Generic
  13001. */
  13002. GENERIC = 5
  13003. }
  13004. /**
  13005. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13006. */
  13007. export interface MutableGamepadButton {
  13008. /**
  13009. * Value of the button/trigger
  13010. */
  13011. value: number;
  13012. /**
  13013. * If the button/trigger is currently touched
  13014. */
  13015. touched: boolean;
  13016. /**
  13017. * If the button/trigger is currently pressed
  13018. */
  13019. pressed: boolean;
  13020. }
  13021. /**
  13022. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13023. * @hidden
  13024. */
  13025. export interface ExtendedGamepadButton extends GamepadButton {
  13026. /**
  13027. * If the button/trigger is currently pressed
  13028. */
  13029. readonly pressed: boolean;
  13030. /**
  13031. * If the button/trigger is currently touched
  13032. */
  13033. readonly touched: boolean;
  13034. /**
  13035. * Value of the button/trigger
  13036. */
  13037. readonly value: number;
  13038. }
  13039. /** @hidden */
  13040. export interface _GamePadFactory {
  13041. /**
  13042. * Returns wether or not the current gamepad can be created for this type of controller.
  13043. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13044. * @returns true if it can be created, otherwise false
  13045. */
  13046. canCreate(gamepadInfo: any): boolean;
  13047. /**
  13048. * Creates a new instance of the Gamepad.
  13049. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13050. * @returns the new gamepad instance
  13051. */
  13052. create(gamepadInfo: any): Gamepad;
  13053. }
  13054. /**
  13055. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13056. */
  13057. export class PoseEnabledControllerHelper {
  13058. /** @hidden */
  13059. static _ControllerFactories: _GamePadFactory[];
  13060. /** @hidden */
  13061. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13062. /**
  13063. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13064. * @param vrGamepad the gamepad to initialized
  13065. * @returns a vr controller of the type the gamepad identified as
  13066. */
  13067. static InitiateController(vrGamepad: any): Gamepad;
  13068. }
  13069. /**
  13070. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13071. */
  13072. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13073. private _deviceRoomPosition;
  13074. private _deviceRoomRotationQuaternion;
  13075. /**
  13076. * The device position in babylon space
  13077. */
  13078. devicePosition: Vector3;
  13079. /**
  13080. * The device rotation in babylon space
  13081. */
  13082. deviceRotationQuaternion: Quaternion;
  13083. /**
  13084. * The scale factor of the device in babylon space
  13085. */
  13086. deviceScaleFactor: number;
  13087. /**
  13088. * (Likely devicePosition should be used instead) The device position in its room space
  13089. */
  13090. position: Vector3;
  13091. /**
  13092. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13093. */
  13094. rotationQuaternion: Quaternion;
  13095. /**
  13096. * The type of controller (Eg. Windows mixed reality)
  13097. */
  13098. controllerType: PoseEnabledControllerType;
  13099. protected _calculatedPosition: Vector3;
  13100. private _calculatedRotation;
  13101. /**
  13102. * The raw pose from the device
  13103. */
  13104. rawPose: DevicePose;
  13105. private _trackPosition;
  13106. private _maxRotationDistFromHeadset;
  13107. private _draggedRoomRotation;
  13108. /**
  13109. * @hidden
  13110. */
  13111. _disableTrackPosition(fixedPosition: Vector3): void;
  13112. /**
  13113. * Internal, the mesh attached to the controller
  13114. * @hidden
  13115. */
  13116. _mesh: Nullable<AbstractMesh>;
  13117. private _poseControlledCamera;
  13118. private _leftHandSystemQuaternion;
  13119. /**
  13120. * Internal, matrix used to convert room space to babylon space
  13121. * @hidden
  13122. */
  13123. _deviceToWorld: Matrix;
  13124. /**
  13125. * Node to be used when casting a ray from the controller
  13126. * @hidden
  13127. */
  13128. _pointingPoseNode: Nullable<TransformNode>;
  13129. /**
  13130. * Name of the child mesh that can be used to cast a ray from the controller
  13131. */
  13132. static readonly POINTING_POSE: string;
  13133. /**
  13134. * Creates a new PoseEnabledController from a gamepad
  13135. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13136. */
  13137. constructor(browserGamepad: any);
  13138. private _workingMatrix;
  13139. /**
  13140. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13141. */
  13142. update(): void;
  13143. /**
  13144. * Updates only the pose device and mesh without doing any button event checking
  13145. */
  13146. protected _updatePoseAndMesh(): void;
  13147. /**
  13148. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13149. * @param poseData raw pose fromthe device
  13150. */
  13151. updateFromDevice(poseData: DevicePose): void;
  13152. /**
  13153. * @hidden
  13154. */
  13155. _meshAttachedObservable: Observable<AbstractMesh>;
  13156. /**
  13157. * Attaches a mesh to the controller
  13158. * @param mesh the mesh to be attached
  13159. */
  13160. attachToMesh(mesh: AbstractMesh): void;
  13161. /**
  13162. * Attaches the controllers mesh to a camera
  13163. * @param camera the camera the mesh should be attached to
  13164. */
  13165. attachToPoseControlledCamera(camera: TargetCamera): void;
  13166. /**
  13167. * Disposes of the controller
  13168. */
  13169. dispose(): void;
  13170. /**
  13171. * The mesh that is attached to the controller
  13172. */
  13173. readonly mesh: Nullable<AbstractMesh>;
  13174. /**
  13175. * Gets the ray of the controller in the direction the controller is pointing
  13176. * @param length the length the resulting ray should be
  13177. * @returns a ray in the direction the controller is pointing
  13178. */
  13179. getForwardRay(length?: number): Ray;
  13180. }
  13181. }
  13182. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13183. import { Observable } from "babylonjs/Misc/observable";
  13184. import { Scene } from "babylonjs/scene";
  13185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13186. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13187. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13188. /**
  13189. * Defines the WebVRController object that represents controllers tracked in 3D space
  13190. */
  13191. export abstract class WebVRController extends PoseEnabledController {
  13192. /**
  13193. * Internal, the default controller model for the controller
  13194. */
  13195. protected _defaultModel: AbstractMesh;
  13196. /**
  13197. * Fired when the trigger state has changed
  13198. */
  13199. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13200. /**
  13201. * Fired when the main button state has changed
  13202. */
  13203. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13204. /**
  13205. * Fired when the secondary button state has changed
  13206. */
  13207. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13208. /**
  13209. * Fired when the pad state has changed
  13210. */
  13211. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13212. /**
  13213. * Fired when controllers stick values have changed
  13214. */
  13215. onPadValuesChangedObservable: Observable<StickValues>;
  13216. /**
  13217. * Array of button availible on the controller
  13218. */
  13219. protected _buttons: Array<MutableGamepadButton>;
  13220. private _onButtonStateChange;
  13221. /**
  13222. * Fired when a controller button's state has changed
  13223. * @param callback the callback containing the button that was modified
  13224. */
  13225. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13226. /**
  13227. * X and Y axis corrisponding to the controllers joystick
  13228. */
  13229. pad: StickValues;
  13230. /**
  13231. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13232. */
  13233. hand: string;
  13234. /**
  13235. * The default controller model for the controller
  13236. */
  13237. readonly defaultModel: AbstractMesh;
  13238. /**
  13239. * Creates a new WebVRController from a gamepad
  13240. * @param vrGamepad the gamepad that the WebVRController should be created from
  13241. */
  13242. constructor(vrGamepad: any);
  13243. /**
  13244. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13245. */
  13246. update(): void;
  13247. /**
  13248. * Function to be called when a button is modified
  13249. */
  13250. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13251. /**
  13252. * Loads a mesh and attaches it to the controller
  13253. * @param scene the scene the mesh should be added to
  13254. * @param meshLoaded callback for when the mesh has been loaded
  13255. */
  13256. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13257. private _setButtonValue;
  13258. private _changes;
  13259. private _checkChanges;
  13260. /**
  13261. * Disposes of th webVRCOntroller
  13262. */
  13263. dispose(): void;
  13264. }
  13265. }
  13266. declare module "babylonjs/Lights/hemisphericLight" {
  13267. import { Nullable } from "babylonjs/types";
  13268. import { Scene } from "babylonjs/scene";
  13269. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13270. import { Effect } from "babylonjs/Materials/effect";
  13271. import { Light } from "babylonjs/Lights/light";
  13272. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13273. /**
  13274. * The HemisphericLight simulates the ambient environment light,
  13275. * so the passed direction is the light reflection direction, not the incoming direction.
  13276. */
  13277. export class HemisphericLight extends Light {
  13278. /**
  13279. * The groundColor is the light in the opposite direction to the one specified during creation.
  13280. * 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.
  13281. */
  13282. groundColor: Color3;
  13283. /**
  13284. * The light reflection direction, not the incoming direction.
  13285. */
  13286. direction: Vector3;
  13287. /**
  13288. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13289. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13290. * The HemisphericLight can't cast shadows.
  13291. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13292. * @param name The friendly name of the light
  13293. * @param direction The direction of the light reflection
  13294. * @param scene The scene the light belongs to
  13295. */
  13296. constructor(name: string, direction: Vector3, scene: Scene);
  13297. protected _buildUniformLayout(): void;
  13298. /**
  13299. * Returns the string "HemisphericLight".
  13300. * @return The class name
  13301. */
  13302. getClassName(): string;
  13303. /**
  13304. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13305. * Returns the updated direction.
  13306. * @param target The target the direction should point to
  13307. * @return The computed direction
  13308. */
  13309. setDirectionToTarget(target: Vector3): Vector3;
  13310. /**
  13311. * Returns the shadow generator associated to the light.
  13312. * @returns Always null for hemispheric lights because it does not support shadows.
  13313. */
  13314. getShadowGenerator(): Nullable<IShadowGenerator>;
  13315. /**
  13316. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13317. * @param effect The effect to update
  13318. * @param lightIndex The index of the light in the effect to update
  13319. * @returns The hemispheric light
  13320. */
  13321. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13322. /**
  13323. * Computes the world matrix of the node
  13324. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13325. * @param useWasUpdatedFlag defines a reserved property
  13326. * @returns the world matrix
  13327. */
  13328. computeWorldMatrix(): Matrix;
  13329. /**
  13330. * Returns the integer 3.
  13331. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13332. */
  13333. getTypeID(): number;
  13334. /**
  13335. * Prepares the list of defines specific to the light type.
  13336. * @param defines the list of defines
  13337. * @param lightIndex defines the index of the light for the effect
  13338. */
  13339. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13340. }
  13341. }
  13342. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13343. /** @hidden */
  13344. export var vrMultiviewToSingleviewPixelShader: {
  13345. name: string;
  13346. shader: string;
  13347. };
  13348. }
  13349. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13350. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13351. import { Scene } from "babylonjs/scene";
  13352. /**
  13353. * Renders to multiple views with a single draw call
  13354. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13355. */
  13356. export class MultiviewRenderTarget extends RenderTargetTexture {
  13357. /**
  13358. * Creates a multiview render target
  13359. * @param scene scene used with the render target
  13360. * @param size the size of the render target (used for each view)
  13361. */
  13362. constructor(scene: Scene, size?: number | {
  13363. width: number;
  13364. height: number;
  13365. } | {
  13366. ratio: number;
  13367. });
  13368. /**
  13369. * @hidden
  13370. * @param faceIndex the face index, if its a cube texture
  13371. */
  13372. _bindFrameBuffer(faceIndex?: number): void;
  13373. /**
  13374. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13375. * @returns the view count
  13376. */
  13377. getViewCount(): number;
  13378. }
  13379. }
  13380. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13381. import { Camera } from "babylonjs/Cameras/camera";
  13382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13383. import { Nullable } from "babylonjs/types";
  13384. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13385. import { Matrix } from "babylonjs/Maths/math";
  13386. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13387. module "babylonjs/Engines/engine" {
  13388. interface Engine {
  13389. /**
  13390. * Creates a new multiview render target
  13391. * @param width defines the width of the texture
  13392. * @param height defines the height of the texture
  13393. * @returns the created multiview texture
  13394. */
  13395. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13396. /**
  13397. * Binds a multiview framebuffer to be drawn to
  13398. * @param multiviewTexture texture to bind
  13399. */
  13400. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13401. }
  13402. }
  13403. module "babylonjs/Cameras/camera" {
  13404. interface Camera {
  13405. /**
  13406. * @hidden
  13407. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13408. */
  13409. _useMultiviewToSingleView: boolean;
  13410. /**
  13411. * @hidden
  13412. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13413. */
  13414. _multiviewTexture: Nullable<RenderTargetTexture>;
  13415. /**
  13416. * @hidden
  13417. * ensures the multiview texture of the camera exists and has the specified width/height
  13418. * @param width height to set on the multiview texture
  13419. * @param height width to set on the multiview texture
  13420. */
  13421. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13422. }
  13423. }
  13424. module "babylonjs/scene" {
  13425. interface Scene {
  13426. /** @hidden */
  13427. _transformMatrixR: Matrix;
  13428. /** @hidden */
  13429. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13430. /** @hidden */
  13431. _createMultiviewUbo(): void;
  13432. /** @hidden */
  13433. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13434. /** @hidden */
  13435. _renderMultiviewToSingleView(camera: Camera): void;
  13436. }
  13437. }
  13438. }
  13439. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13440. import { Camera } from "babylonjs/Cameras/camera";
  13441. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13442. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13443. import "babylonjs/Engines/Extensions/engine.multiview";
  13444. /**
  13445. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13446. * This will not be used for webXR as it supports displaying texture arrays directly
  13447. */
  13448. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13449. /**
  13450. * Initializes a VRMultiviewToSingleview
  13451. * @param name name of the post process
  13452. * @param camera camera to be applied to
  13453. * @param scaleFactor scaling factor to the size of the output texture
  13454. */
  13455. constructor(name: string, camera: Camera, scaleFactor: number);
  13456. }
  13457. }
  13458. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13459. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  13460. import { Nullable } from "babylonjs/types";
  13461. import { Size } from "babylonjs/Maths/math";
  13462. import { Observable } from "babylonjs/Misc/observable";
  13463. module "babylonjs/Engines/engine" {
  13464. /**
  13465. * Defines the interface used by display changed events
  13466. */
  13467. interface IDisplayChangedEventArgs {
  13468. /** Gets the vrDisplay object (if any) */
  13469. vrDisplay: Nullable<any>;
  13470. /** Gets a boolean indicating if webVR is supported */
  13471. vrSupported: boolean;
  13472. }
  13473. interface Engine {
  13474. /** @hidden */
  13475. _vrDisplay: any;
  13476. /** @hidden */
  13477. _vrSupported: boolean;
  13478. /** @hidden */
  13479. _oldSize: Size;
  13480. /** @hidden */
  13481. _oldHardwareScaleFactor: number;
  13482. /** @hidden */
  13483. _vrExclusivePointerMode: boolean;
  13484. /** @hidden */
  13485. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13486. /** @hidden */
  13487. _onVRDisplayPointerRestricted: () => void;
  13488. /** @hidden */
  13489. _onVRDisplayPointerUnrestricted: () => void;
  13490. /** @hidden */
  13491. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13492. /** @hidden */
  13493. _onVrDisplayDisconnect: Nullable<() => void>;
  13494. /** @hidden */
  13495. _onVrDisplayPresentChange: Nullable<() => void>;
  13496. /**
  13497. * Observable signaled when VR display mode changes
  13498. */
  13499. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13500. /**
  13501. * Observable signaled when VR request present is complete
  13502. */
  13503. onVRRequestPresentComplete: Observable<boolean>;
  13504. /**
  13505. * Observable signaled when VR request present starts
  13506. */
  13507. onVRRequestPresentStart: Observable<Engine>;
  13508. /**
  13509. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13510. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13511. */
  13512. isInVRExclusivePointerMode: boolean;
  13513. /**
  13514. * Gets a boolean indicating if a webVR device was detected
  13515. * @returns true if a webVR device was detected
  13516. */
  13517. isVRDevicePresent(): boolean;
  13518. /**
  13519. * Gets the current webVR device
  13520. * @returns the current webVR device (or null)
  13521. */
  13522. getVRDevice(): any;
  13523. /**
  13524. * Initializes a webVR display and starts listening to display change events
  13525. * The onVRDisplayChangedObservable will be notified upon these changes
  13526. * @returns A promise containing a VRDisplay and if vr is supported
  13527. */
  13528. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13529. /** @hidden */
  13530. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13531. /**
  13532. * Call this function to switch to webVR mode
  13533. * Will do nothing if webVR is not supported or if there is no webVR device
  13534. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13535. */
  13536. enableVR(): void;
  13537. /** @hidden */
  13538. _onVRFullScreenTriggered(): void;
  13539. }
  13540. }
  13541. }
  13542. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13543. import { Nullable } from "babylonjs/types";
  13544. import { Observable } from "babylonjs/Misc/observable";
  13545. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13546. import { Scene } from "babylonjs/scene";
  13547. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13548. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13549. import { Node } from "babylonjs/node";
  13550. import { Ray } from "babylonjs/Culling/ray";
  13551. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13552. import "babylonjs/Engines/Extensions/engine.webVR";
  13553. /**
  13554. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13555. * IMPORTANT!! The data is right-hand data.
  13556. * @export
  13557. * @interface DevicePose
  13558. */
  13559. export interface DevicePose {
  13560. /**
  13561. * The position of the device, values in array are [x,y,z].
  13562. */
  13563. readonly position: Nullable<Float32Array>;
  13564. /**
  13565. * The linearVelocity of the device, values in array are [x,y,z].
  13566. */
  13567. readonly linearVelocity: Nullable<Float32Array>;
  13568. /**
  13569. * The linearAcceleration of the device, values in array are [x,y,z].
  13570. */
  13571. readonly linearAcceleration: Nullable<Float32Array>;
  13572. /**
  13573. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13574. */
  13575. readonly orientation: Nullable<Float32Array>;
  13576. /**
  13577. * The angularVelocity of the device, values in array are [x,y,z].
  13578. */
  13579. readonly angularVelocity: Nullable<Float32Array>;
  13580. /**
  13581. * The angularAcceleration of the device, values in array are [x,y,z].
  13582. */
  13583. readonly angularAcceleration: Nullable<Float32Array>;
  13584. }
  13585. /**
  13586. * Interface representing a pose controlled object in Babylon.
  13587. * A pose controlled object has both regular pose values as well as pose values
  13588. * from an external device such as a VR head mounted display
  13589. */
  13590. export interface PoseControlled {
  13591. /**
  13592. * The position of the object in babylon space.
  13593. */
  13594. position: Vector3;
  13595. /**
  13596. * The rotation quaternion of the object in babylon space.
  13597. */
  13598. rotationQuaternion: Quaternion;
  13599. /**
  13600. * The position of the device in babylon space.
  13601. */
  13602. devicePosition?: Vector3;
  13603. /**
  13604. * The rotation quaternion of the device in babylon space.
  13605. */
  13606. deviceRotationQuaternion: Quaternion;
  13607. /**
  13608. * The raw pose coming from the device.
  13609. */
  13610. rawPose: Nullable<DevicePose>;
  13611. /**
  13612. * The scale of the device to be used when translating from device space to babylon space.
  13613. */
  13614. deviceScaleFactor: number;
  13615. /**
  13616. * Updates the poseControlled values based on the input device pose.
  13617. * @param poseData the pose data to update the object with
  13618. */
  13619. updateFromDevice(poseData: DevicePose): void;
  13620. }
  13621. /**
  13622. * Set of options to customize the webVRCamera
  13623. */
  13624. export interface WebVROptions {
  13625. /**
  13626. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13627. */
  13628. trackPosition?: boolean;
  13629. /**
  13630. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13631. */
  13632. positionScale?: number;
  13633. /**
  13634. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13635. */
  13636. displayName?: string;
  13637. /**
  13638. * Should the native controller meshes be initialized. (default: true)
  13639. */
  13640. controllerMeshes?: boolean;
  13641. /**
  13642. * Creating a default HemiLight only on controllers. (default: true)
  13643. */
  13644. defaultLightingOnControllers?: boolean;
  13645. /**
  13646. * If you don't want to use the default VR button of the helper. (default: false)
  13647. */
  13648. useCustomVRButton?: boolean;
  13649. /**
  13650. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13651. */
  13652. customVRButton?: HTMLButtonElement;
  13653. /**
  13654. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13655. */
  13656. rayLength?: number;
  13657. /**
  13658. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13659. */
  13660. defaultHeight?: number;
  13661. /**
  13662. * If multiview should be used if availible (default: false)
  13663. */
  13664. useMultiview?: boolean;
  13665. }
  13666. /**
  13667. * This represents a WebVR camera.
  13668. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13669. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13670. */
  13671. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13672. private webVROptions;
  13673. /**
  13674. * @hidden
  13675. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13676. */
  13677. _vrDevice: any;
  13678. /**
  13679. * The rawPose of the vrDevice.
  13680. */
  13681. rawPose: Nullable<DevicePose>;
  13682. private _onVREnabled;
  13683. private _specsVersion;
  13684. private _attached;
  13685. private _frameData;
  13686. protected _descendants: Array<Node>;
  13687. private _deviceRoomPosition;
  13688. /** @hidden */
  13689. _deviceRoomRotationQuaternion: Quaternion;
  13690. private _standingMatrix;
  13691. /**
  13692. * Represents device position in babylon space.
  13693. */
  13694. devicePosition: Vector3;
  13695. /**
  13696. * Represents device rotation in babylon space.
  13697. */
  13698. deviceRotationQuaternion: Quaternion;
  13699. /**
  13700. * The scale of the device to be used when translating from device space to babylon space.
  13701. */
  13702. deviceScaleFactor: number;
  13703. private _deviceToWorld;
  13704. private _worldToDevice;
  13705. /**
  13706. * References to the webVR controllers for the vrDevice.
  13707. */
  13708. controllers: Array<WebVRController>;
  13709. /**
  13710. * Emits an event when a controller is attached.
  13711. */
  13712. onControllersAttachedObservable: Observable<WebVRController[]>;
  13713. /**
  13714. * Emits an event when a controller's mesh has been loaded;
  13715. */
  13716. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13717. /**
  13718. * Emits an event when the HMD's pose has been updated.
  13719. */
  13720. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13721. private _poseSet;
  13722. /**
  13723. * If the rig cameras be used as parent instead of this camera.
  13724. */
  13725. rigParenting: boolean;
  13726. private _lightOnControllers;
  13727. private _defaultHeight?;
  13728. /**
  13729. * Instantiates a WebVRFreeCamera.
  13730. * @param name The name of the WebVRFreeCamera
  13731. * @param position The starting anchor position for the camera
  13732. * @param scene The scene the camera belongs to
  13733. * @param webVROptions a set of customizable options for the webVRCamera
  13734. */
  13735. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13736. /**
  13737. * Gets the device distance from the ground in meters.
  13738. * @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.
  13739. */
  13740. deviceDistanceToRoomGround(): number;
  13741. /**
  13742. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13743. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13744. */
  13745. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13746. /**
  13747. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13748. * @returns A promise with a boolean set to if the standing matrix is supported.
  13749. */
  13750. useStandingMatrixAsync(): Promise<boolean>;
  13751. /**
  13752. * Disposes the camera
  13753. */
  13754. dispose(): void;
  13755. /**
  13756. * Gets a vrController by name.
  13757. * @param name The name of the controller to retreive
  13758. * @returns the controller matching the name specified or null if not found
  13759. */
  13760. getControllerByName(name: string): Nullable<WebVRController>;
  13761. private _leftController;
  13762. /**
  13763. * The controller corrisponding to the users left hand.
  13764. */
  13765. readonly leftController: Nullable<WebVRController>;
  13766. private _rightController;
  13767. /**
  13768. * The controller corrisponding to the users right hand.
  13769. */
  13770. readonly rightController: Nullable<WebVRController>;
  13771. /**
  13772. * Casts a ray forward from the vrCamera's gaze.
  13773. * @param length Length of the ray (default: 100)
  13774. * @returns the ray corrisponding to the gaze
  13775. */
  13776. getForwardRay(length?: number): Ray;
  13777. /**
  13778. * @hidden
  13779. * Updates the camera based on device's frame data
  13780. */
  13781. _checkInputs(): void;
  13782. /**
  13783. * Updates the poseControlled values based on the input device pose.
  13784. * @param poseData Pose coming from the device
  13785. */
  13786. updateFromDevice(poseData: DevicePose): void;
  13787. private _htmlElementAttached;
  13788. private _detachIfAttached;
  13789. /**
  13790. * WebVR's attach control will start broadcasting frames to the device.
  13791. * Note that in certain browsers (chrome for example) this function must be called
  13792. * within a user-interaction callback. Example:
  13793. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13794. *
  13795. * @param element html element to attach the vrDevice to
  13796. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13797. */
  13798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13799. /**
  13800. * Detaches the camera from the html element and disables VR
  13801. *
  13802. * @param element html element to detach from
  13803. */
  13804. detachControl(element: HTMLElement): void;
  13805. /**
  13806. * @returns the name of this class
  13807. */
  13808. getClassName(): string;
  13809. /**
  13810. * Calls resetPose on the vrDisplay
  13811. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13812. */
  13813. resetToCurrentRotation(): void;
  13814. /**
  13815. * @hidden
  13816. * Updates the rig cameras (left and right eye)
  13817. */
  13818. _updateRigCameras(): void;
  13819. private _workingVector;
  13820. private _oneVector;
  13821. private _workingMatrix;
  13822. private updateCacheCalled;
  13823. private _correctPositionIfNotTrackPosition;
  13824. /**
  13825. * @hidden
  13826. * Updates the cached values of the camera
  13827. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13828. */
  13829. _updateCache(ignoreParentClass?: boolean): void;
  13830. /**
  13831. * @hidden
  13832. * Get current device position in babylon world
  13833. */
  13834. _computeDevicePosition(): void;
  13835. /**
  13836. * Updates the current device position and rotation in the babylon world
  13837. */
  13838. update(): void;
  13839. /**
  13840. * @hidden
  13841. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13842. * @returns an identity matrix
  13843. */
  13844. _getViewMatrix(): Matrix;
  13845. private _tmpMatrix;
  13846. /**
  13847. * This function is called by the two RIG cameras.
  13848. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13849. * @hidden
  13850. */
  13851. _getWebVRViewMatrix(): Matrix;
  13852. /** @hidden */
  13853. _getWebVRProjectionMatrix(): Matrix;
  13854. private _onGamepadConnectedObserver;
  13855. private _onGamepadDisconnectedObserver;
  13856. private _updateCacheWhenTrackingDisabledObserver;
  13857. /**
  13858. * Initializes the controllers and their meshes
  13859. */
  13860. initControllers(): void;
  13861. }
  13862. }
  13863. declare module "babylonjs/PostProcesses/postProcess" {
  13864. import { Nullable } from "babylonjs/types";
  13865. import { SmartArray } from "babylonjs/Misc/smartArray";
  13866. import { Observable } from "babylonjs/Misc/observable";
  13867. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13868. import { Camera } from "babylonjs/Cameras/camera";
  13869. import { Effect } from "babylonjs/Materials/effect";
  13870. import "babylonjs/Shaders/postprocess.vertex";
  13871. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13872. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13873. import { Engine } from "babylonjs/Engines/engine";
  13874. /**
  13875. * Size options for a post process
  13876. */
  13877. export type PostProcessOptions = {
  13878. width: number;
  13879. height: number;
  13880. };
  13881. /**
  13882. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13883. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13884. */
  13885. export class PostProcess {
  13886. /** Name of the PostProcess. */
  13887. name: string;
  13888. /**
  13889. * Gets or sets the unique id of the post process
  13890. */
  13891. uniqueId: number;
  13892. /**
  13893. * Width of the texture to apply the post process on
  13894. */
  13895. width: number;
  13896. /**
  13897. * Height of the texture to apply the post process on
  13898. */
  13899. height: number;
  13900. /**
  13901. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13902. * @hidden
  13903. */
  13904. _outputTexture: Nullable<InternalTexture>;
  13905. /**
  13906. * Sampling mode used by the shader
  13907. * See https://doc.babylonjs.com/classes/3.1/texture
  13908. */
  13909. renderTargetSamplingMode: number;
  13910. /**
  13911. * Clear color to use when screen clearing
  13912. */
  13913. clearColor: Color4;
  13914. /**
  13915. * If the buffer needs to be cleared before applying the post process. (default: true)
  13916. * Should be set to false if shader will overwrite all previous pixels.
  13917. */
  13918. autoClear: boolean;
  13919. /**
  13920. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13921. */
  13922. alphaMode: number;
  13923. /**
  13924. * Sets the setAlphaBlendConstants of the babylon engine
  13925. */
  13926. alphaConstants: Color4;
  13927. /**
  13928. * Animations to be used for the post processing
  13929. */
  13930. animations: import("babylonjs/Animations/animation").Animation[];
  13931. /**
  13932. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13933. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13934. */
  13935. enablePixelPerfectMode: boolean;
  13936. /**
  13937. * Force the postprocess to be applied without taking in account viewport
  13938. */
  13939. forceFullscreenViewport: boolean;
  13940. /**
  13941. * List of inspectable custom properties (used by the Inspector)
  13942. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13943. */
  13944. inspectableCustomProperties: IInspectable[];
  13945. /**
  13946. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13947. *
  13948. * | Value | Type | Description |
  13949. * | ----- | ----------------------------------- | ----------- |
  13950. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13951. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13952. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13953. *
  13954. */
  13955. scaleMode: number;
  13956. /**
  13957. * Force textures to be a power of two (default: false)
  13958. */
  13959. alwaysForcePOT: boolean;
  13960. private _samples;
  13961. /**
  13962. * Number of sample textures (default: 1)
  13963. */
  13964. samples: number;
  13965. /**
  13966. * Modify the scale of the post process to be the same as the viewport (default: false)
  13967. */
  13968. adaptScaleToCurrentViewport: boolean;
  13969. private _camera;
  13970. private _scene;
  13971. private _engine;
  13972. private _options;
  13973. private _reusable;
  13974. private _textureType;
  13975. /**
  13976. * Smart array of input and output textures for the post process.
  13977. * @hidden
  13978. */
  13979. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13980. /**
  13981. * The index in _textures that corresponds to the output texture.
  13982. * @hidden
  13983. */
  13984. _currentRenderTextureInd: number;
  13985. private _effect;
  13986. private _samplers;
  13987. private _fragmentUrl;
  13988. private _vertexUrl;
  13989. private _parameters;
  13990. private _scaleRatio;
  13991. protected _indexParameters: any;
  13992. private _shareOutputWithPostProcess;
  13993. private _texelSize;
  13994. private _forcedOutputTexture;
  13995. /**
  13996. * Returns the fragment url or shader name used in the post process.
  13997. * @returns the fragment url or name in the shader store.
  13998. */
  13999. getEffectName(): string;
  14000. /**
  14001. * An event triggered when the postprocess is activated.
  14002. */
  14003. onActivateObservable: Observable<Camera>;
  14004. private _onActivateObserver;
  14005. /**
  14006. * A function that is added to the onActivateObservable
  14007. */
  14008. onActivate: Nullable<(camera: Camera) => void>;
  14009. /**
  14010. * An event triggered when the postprocess changes its size.
  14011. */
  14012. onSizeChangedObservable: Observable<PostProcess>;
  14013. private _onSizeChangedObserver;
  14014. /**
  14015. * A function that is added to the onSizeChangedObservable
  14016. */
  14017. onSizeChanged: (postProcess: PostProcess) => void;
  14018. /**
  14019. * An event triggered when the postprocess applies its effect.
  14020. */
  14021. onApplyObservable: Observable<Effect>;
  14022. private _onApplyObserver;
  14023. /**
  14024. * A function that is added to the onApplyObservable
  14025. */
  14026. onApply: (effect: Effect) => void;
  14027. /**
  14028. * An event triggered before rendering the postprocess
  14029. */
  14030. onBeforeRenderObservable: Observable<Effect>;
  14031. private _onBeforeRenderObserver;
  14032. /**
  14033. * A function that is added to the onBeforeRenderObservable
  14034. */
  14035. onBeforeRender: (effect: Effect) => void;
  14036. /**
  14037. * An event triggered after rendering the postprocess
  14038. */
  14039. onAfterRenderObservable: Observable<Effect>;
  14040. private _onAfterRenderObserver;
  14041. /**
  14042. * A function that is added to the onAfterRenderObservable
  14043. */
  14044. onAfterRender: (efect: Effect) => void;
  14045. /**
  14046. * 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
  14047. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14048. */
  14049. inputTexture: InternalTexture;
  14050. /**
  14051. * Gets the camera which post process is applied to.
  14052. * @returns The camera the post process is applied to.
  14053. */
  14054. getCamera(): Camera;
  14055. /**
  14056. * Gets the texel size of the postprocess.
  14057. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14058. */
  14059. readonly texelSize: Vector2;
  14060. /**
  14061. * Creates a new instance PostProcess
  14062. * @param name The name of the PostProcess.
  14063. * @param fragmentUrl The url of the fragment shader to be used.
  14064. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14065. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14066. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14067. * @param camera The camera to apply the render pass to.
  14068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14069. * @param engine The engine which the post process will be applied. (default: current engine)
  14070. * @param reusable If the post process can be reused on the same frame. (default: false)
  14071. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14072. * @param textureType Type of textures used when performing the post process. (default: 0)
  14073. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14074. * @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
  14075. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14076. */
  14077. constructor(
  14078. /** Name of the PostProcess. */
  14079. 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);
  14080. /**
  14081. * Gets a string idenfifying the name of the class
  14082. * @returns "PostProcess" string
  14083. */
  14084. getClassName(): string;
  14085. /**
  14086. * Gets the engine which this post process belongs to.
  14087. * @returns The engine the post process was enabled with.
  14088. */
  14089. getEngine(): Engine;
  14090. /**
  14091. * The effect that is created when initializing the post process.
  14092. * @returns The created effect corrisponding the the postprocess.
  14093. */
  14094. getEffect(): Effect;
  14095. /**
  14096. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14097. * @param postProcess The post process to share the output with.
  14098. * @returns This post process.
  14099. */
  14100. shareOutputWith(postProcess: PostProcess): PostProcess;
  14101. /**
  14102. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14103. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14104. */
  14105. useOwnOutput(): void;
  14106. /**
  14107. * Updates the effect with the current post process compile time values and recompiles the shader.
  14108. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14109. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14110. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14111. * @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
  14112. * @param onCompiled Called when the shader has been compiled.
  14113. * @param onError Called if there is an error when compiling a shader.
  14114. */
  14115. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14116. /**
  14117. * The post process is reusable if it can be used multiple times within one frame.
  14118. * @returns If the post process is reusable
  14119. */
  14120. isReusable(): boolean;
  14121. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14122. markTextureDirty(): void;
  14123. /**
  14124. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14125. * 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.
  14126. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14127. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14128. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14129. * @returns The target texture that was bound to be written to.
  14130. */
  14131. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14132. /**
  14133. * If the post process is supported.
  14134. */
  14135. readonly isSupported: boolean;
  14136. /**
  14137. * The aspect ratio of the output texture.
  14138. */
  14139. readonly aspectRatio: number;
  14140. /**
  14141. * Get a value indicating if the post-process is ready to be used
  14142. * @returns true if the post-process is ready (shader is compiled)
  14143. */
  14144. isReady(): boolean;
  14145. /**
  14146. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14147. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14148. */
  14149. apply(): Nullable<Effect>;
  14150. private _disposeTextures;
  14151. /**
  14152. * Disposes the post process.
  14153. * @param camera The camera to dispose the post process on.
  14154. */
  14155. dispose(camera?: Camera): void;
  14156. }
  14157. }
  14158. declare module "babylonjs/PostProcesses/postProcessManager" {
  14159. import { Nullable } from "babylonjs/types";
  14160. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14161. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14162. import { Scene } from "babylonjs/scene";
  14163. /**
  14164. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14165. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14166. */
  14167. export class PostProcessManager {
  14168. private _scene;
  14169. private _indexBuffer;
  14170. private _vertexBuffers;
  14171. /**
  14172. * Creates a new instance PostProcess
  14173. * @param scene The scene that the post process is associated with.
  14174. */
  14175. constructor(scene: Scene);
  14176. private _prepareBuffers;
  14177. private _buildIndexBuffer;
  14178. /**
  14179. * Rebuilds the vertex buffers of the manager.
  14180. * @hidden
  14181. */
  14182. _rebuild(): void;
  14183. /**
  14184. * Prepares a frame to be run through a post process.
  14185. * @param sourceTexture The input texture to the post procesess. (default: null)
  14186. * @param postProcesses An array of post processes to be run. (default: null)
  14187. * @returns True if the post processes were able to be run.
  14188. * @hidden
  14189. */
  14190. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14191. /**
  14192. * Manually render a set of post processes to a texture.
  14193. * @param postProcesses An array of post processes to be run.
  14194. * @param targetTexture The target texture to render to.
  14195. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14196. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14197. * @param lodLevel defines which lod of the texture to render to
  14198. */
  14199. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14200. /**
  14201. * Finalize the result of the output of the postprocesses.
  14202. * @param doNotPresent If true the result will not be displayed to the screen.
  14203. * @param targetTexture The target texture to render to.
  14204. * @param faceIndex The index of the face to bind the target texture to.
  14205. * @param postProcesses The array of post processes to render.
  14206. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14207. * @hidden
  14208. */
  14209. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14210. /**
  14211. * Disposes of the post process manager.
  14212. */
  14213. dispose(): void;
  14214. }
  14215. }
  14216. declare module "babylonjs/Layers/layerSceneComponent" {
  14217. import { Scene } from "babylonjs/scene";
  14218. import { ISceneComponent } from "babylonjs/sceneComponent";
  14219. import { Layer } from "babylonjs/Layers/layer";
  14220. module "babylonjs/abstractScene" {
  14221. interface AbstractScene {
  14222. /**
  14223. * The list of layers (background and foreground) of the scene
  14224. */
  14225. layers: Array<Layer>;
  14226. }
  14227. }
  14228. /**
  14229. * Defines the layer scene component responsible to manage any layers
  14230. * in a given scene.
  14231. */
  14232. export class LayerSceneComponent implements ISceneComponent {
  14233. /**
  14234. * The component name helpfull to identify the component in the list of scene components.
  14235. */
  14236. readonly name: string;
  14237. /**
  14238. * The scene the component belongs to.
  14239. */
  14240. scene: Scene;
  14241. private _engine;
  14242. /**
  14243. * Creates a new instance of the component for the given scene
  14244. * @param scene Defines the scene to register the component in
  14245. */
  14246. constructor(scene: Scene);
  14247. /**
  14248. * Registers the component in a given scene
  14249. */
  14250. register(): void;
  14251. /**
  14252. * Rebuilds the elements related to this component in case of
  14253. * context lost for instance.
  14254. */
  14255. rebuild(): void;
  14256. /**
  14257. * Disposes the component and the associated ressources.
  14258. */
  14259. dispose(): void;
  14260. private _draw;
  14261. private _drawCameraPredicate;
  14262. private _drawCameraBackground;
  14263. private _drawCameraForeground;
  14264. private _drawRenderTargetPredicate;
  14265. private _drawRenderTargetBackground;
  14266. private _drawRenderTargetForeground;
  14267. }
  14268. }
  14269. declare module "babylonjs/Shaders/layer.fragment" {
  14270. /** @hidden */
  14271. export var layerPixelShader: {
  14272. name: string;
  14273. shader: string;
  14274. };
  14275. }
  14276. declare module "babylonjs/Shaders/layer.vertex" {
  14277. /** @hidden */
  14278. export var layerVertexShader: {
  14279. name: string;
  14280. shader: string;
  14281. };
  14282. }
  14283. declare module "babylonjs/Layers/layer" {
  14284. import { Observable } from "babylonjs/Misc/observable";
  14285. import { Nullable } from "babylonjs/types";
  14286. import { Scene } from "babylonjs/scene";
  14287. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14288. import { Texture } from "babylonjs/Materials/Textures/texture";
  14289. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14290. import "babylonjs/Shaders/layer.fragment";
  14291. import "babylonjs/Shaders/layer.vertex";
  14292. /**
  14293. * This represents a full screen 2d layer.
  14294. * This can be useful to display a picture in the background of your scene for instance.
  14295. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14296. */
  14297. export class Layer {
  14298. /**
  14299. * Define the name of the layer.
  14300. */
  14301. name: string;
  14302. /**
  14303. * Define the texture the layer should display.
  14304. */
  14305. texture: Nullable<Texture>;
  14306. /**
  14307. * Is the layer in background or foreground.
  14308. */
  14309. isBackground: boolean;
  14310. /**
  14311. * Define the color of the layer (instead of texture).
  14312. */
  14313. color: Color4;
  14314. /**
  14315. * Define the scale of the layer in order to zoom in out of the texture.
  14316. */
  14317. scale: Vector2;
  14318. /**
  14319. * Define an offset for the layer in order to shift the texture.
  14320. */
  14321. offset: Vector2;
  14322. /**
  14323. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14324. */
  14325. alphaBlendingMode: number;
  14326. /**
  14327. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14328. * Alpha test will not mix with the background color in case of transparency.
  14329. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14330. */
  14331. alphaTest: boolean;
  14332. /**
  14333. * Define a mask to restrict the layer to only some of the scene cameras.
  14334. */
  14335. layerMask: number;
  14336. /**
  14337. * Define the list of render target the layer is visible into.
  14338. */
  14339. renderTargetTextures: RenderTargetTexture[];
  14340. /**
  14341. * Define if the layer is only used in renderTarget or if it also
  14342. * renders in the main frame buffer of the canvas.
  14343. */
  14344. renderOnlyInRenderTargetTextures: boolean;
  14345. private _scene;
  14346. private _vertexBuffers;
  14347. private _indexBuffer;
  14348. private _effect;
  14349. private _alphaTestEffect;
  14350. /**
  14351. * An event triggered when the layer is disposed.
  14352. */
  14353. onDisposeObservable: Observable<Layer>;
  14354. private _onDisposeObserver;
  14355. /**
  14356. * Back compatibility with callback before the onDisposeObservable existed.
  14357. * The set callback will be triggered when the layer has been disposed.
  14358. */
  14359. onDispose: () => void;
  14360. /**
  14361. * An event triggered before rendering the scene
  14362. */
  14363. onBeforeRenderObservable: Observable<Layer>;
  14364. private _onBeforeRenderObserver;
  14365. /**
  14366. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14367. * The set callback will be triggered just before rendering the layer.
  14368. */
  14369. onBeforeRender: () => void;
  14370. /**
  14371. * An event triggered after rendering the scene
  14372. */
  14373. onAfterRenderObservable: Observable<Layer>;
  14374. private _onAfterRenderObserver;
  14375. /**
  14376. * Back compatibility with callback before the onAfterRenderObservable existed.
  14377. * The set callback will be triggered just after rendering the layer.
  14378. */
  14379. onAfterRender: () => void;
  14380. /**
  14381. * Instantiates a new layer.
  14382. * This represents a full screen 2d layer.
  14383. * This can be useful to display a picture in the background of your scene for instance.
  14384. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14385. * @param name Define the name of the layer in the scene
  14386. * @param imgUrl Define the url of the texture to display in the layer
  14387. * @param scene Define the scene the layer belongs to
  14388. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14389. * @param color Defines a color for the layer
  14390. */
  14391. constructor(
  14392. /**
  14393. * Define the name of the layer.
  14394. */
  14395. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14396. private _createIndexBuffer;
  14397. /** @hidden */
  14398. _rebuild(): void;
  14399. /**
  14400. * Renders the layer in the scene.
  14401. */
  14402. render(): void;
  14403. /**
  14404. * Disposes and releases the associated ressources.
  14405. */
  14406. dispose(): void;
  14407. }
  14408. }
  14409. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14410. import { Scene } from "babylonjs/scene";
  14411. import { ISceneComponent } from "babylonjs/sceneComponent";
  14412. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14413. module "babylonjs/abstractScene" {
  14414. interface AbstractScene {
  14415. /**
  14416. * The list of procedural textures added to the scene
  14417. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14418. */
  14419. proceduralTextures: Array<ProceduralTexture>;
  14420. }
  14421. }
  14422. /**
  14423. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14424. * in a given scene.
  14425. */
  14426. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14427. /**
  14428. * The component name helpfull to identify the component in the list of scene components.
  14429. */
  14430. readonly name: string;
  14431. /**
  14432. * The scene the component belongs to.
  14433. */
  14434. scene: Scene;
  14435. /**
  14436. * Creates a new instance of the component for the given scene
  14437. * @param scene Defines the scene to register the component in
  14438. */
  14439. constructor(scene: Scene);
  14440. /**
  14441. * Registers the component in a given scene
  14442. */
  14443. register(): void;
  14444. /**
  14445. * Rebuilds the elements related to this component in case of
  14446. * context lost for instance.
  14447. */
  14448. rebuild(): void;
  14449. /**
  14450. * Disposes the component and the associated ressources.
  14451. */
  14452. dispose(): void;
  14453. private _beforeClear;
  14454. }
  14455. }
  14456. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14457. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14458. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14459. module "babylonjs/Engines/engine" {
  14460. interface Engine {
  14461. /**
  14462. * Creates a new render target cube texture
  14463. * @param size defines the size of the texture
  14464. * @param options defines the options used to create the texture
  14465. * @returns a new render target cube texture stored in an InternalTexture
  14466. */
  14467. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14468. }
  14469. }
  14470. }
  14471. declare module "babylonjs/Shaders/procedural.vertex" {
  14472. /** @hidden */
  14473. export var proceduralVertexShader: {
  14474. name: string;
  14475. shader: string;
  14476. };
  14477. }
  14478. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14479. import { Observable } from "babylonjs/Misc/observable";
  14480. import { Nullable } from "babylonjs/types";
  14481. import { Scene } from "babylonjs/scene";
  14482. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14483. import { Effect } from "babylonjs/Materials/effect";
  14484. import { Texture } from "babylonjs/Materials/Textures/texture";
  14485. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14486. import "babylonjs/Shaders/procedural.vertex";
  14487. /**
  14488. * 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.
  14489. * This is the base class of any Procedural texture and contains most of the shareable code.
  14490. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14491. */
  14492. export class ProceduralTexture extends Texture {
  14493. isCube: boolean;
  14494. /**
  14495. * Define if the texture is enabled or not (disabled texture will not render)
  14496. */
  14497. isEnabled: boolean;
  14498. /**
  14499. * Define if the texture must be cleared before rendering (default is true)
  14500. */
  14501. autoClear: boolean;
  14502. /**
  14503. * Callback called when the texture is generated
  14504. */
  14505. onGenerated: () => void;
  14506. /**
  14507. * Event raised when the texture is generated
  14508. */
  14509. onGeneratedObservable: Observable<ProceduralTexture>;
  14510. /** @hidden */
  14511. _generateMipMaps: boolean;
  14512. /** @hidden **/
  14513. _effect: Effect;
  14514. /** @hidden */
  14515. _textures: {
  14516. [key: string]: Texture;
  14517. };
  14518. private _size;
  14519. private _currentRefreshId;
  14520. private _refreshRate;
  14521. private _vertexBuffers;
  14522. private _indexBuffer;
  14523. private _uniforms;
  14524. private _samplers;
  14525. private _fragment;
  14526. private _floats;
  14527. private _ints;
  14528. private _floatsArrays;
  14529. private _colors3;
  14530. private _colors4;
  14531. private _vectors2;
  14532. private _vectors3;
  14533. private _matrices;
  14534. private _fallbackTexture;
  14535. private _fallbackTextureUsed;
  14536. private _engine;
  14537. private _cachedDefines;
  14538. private _contentUpdateId;
  14539. private _contentData;
  14540. /**
  14541. * Instantiates a new procedural texture.
  14542. * 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.
  14543. * This is the base class of any Procedural texture and contains most of the shareable code.
  14544. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14545. * @param name Define the name of the texture
  14546. * @param size Define the size of the texture to create
  14547. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14548. * @param scene Define the scene the texture belongs to
  14549. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14550. * @param generateMipMaps Define if the texture should creates mip maps or not
  14551. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14552. */
  14553. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14554. /**
  14555. * The effect that is created when initializing the post process.
  14556. * @returns The created effect corrisponding the the postprocess.
  14557. */
  14558. getEffect(): Effect;
  14559. /**
  14560. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14561. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14562. */
  14563. getContent(): Nullable<ArrayBufferView>;
  14564. private _createIndexBuffer;
  14565. /** @hidden */
  14566. _rebuild(): void;
  14567. /**
  14568. * Resets the texture in order to recreate its associated resources.
  14569. * This can be called in case of context loss
  14570. */
  14571. reset(): void;
  14572. protected _getDefines(): string;
  14573. /**
  14574. * Is the texture ready to be used ? (rendered at least once)
  14575. * @returns true if ready, otherwise, false.
  14576. */
  14577. isReady(): boolean;
  14578. /**
  14579. * Resets the refresh counter of the texture and start bak from scratch.
  14580. * Could be useful to regenerate the texture if it is setup to render only once.
  14581. */
  14582. resetRefreshCounter(): void;
  14583. /**
  14584. * Set the fragment shader to use in order to render the texture.
  14585. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14586. */
  14587. setFragment(fragment: any): void;
  14588. /**
  14589. * Define the refresh rate of the texture or the rendering frequency.
  14590. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14591. */
  14592. refreshRate: number;
  14593. /** @hidden */
  14594. _shouldRender(): boolean;
  14595. /**
  14596. * Get the size the texture is rendering at.
  14597. * @returns the size (texture is always squared)
  14598. */
  14599. getRenderSize(): number;
  14600. /**
  14601. * Resize the texture to new value.
  14602. * @param size Define the new size the texture should have
  14603. * @param generateMipMaps Define whether the new texture should create mip maps
  14604. */
  14605. resize(size: number, generateMipMaps: boolean): void;
  14606. private _checkUniform;
  14607. /**
  14608. * Set a texture in the shader program used to render.
  14609. * @param name Define the name of the uniform samplers as defined in the shader
  14610. * @param texture Define the texture to bind to this sampler
  14611. * @return the texture itself allowing "fluent" like uniform updates
  14612. */
  14613. setTexture(name: string, texture: Texture): ProceduralTexture;
  14614. /**
  14615. * Set a float in the shader.
  14616. * @param name Define the name of the uniform as defined in the shader
  14617. * @param value Define the value to give to the uniform
  14618. * @return the texture itself allowing "fluent" like uniform updates
  14619. */
  14620. setFloat(name: string, value: number): ProceduralTexture;
  14621. /**
  14622. * Set a int in the shader.
  14623. * @param name Define the name of the uniform as defined in the shader
  14624. * @param value Define the value to give to the uniform
  14625. * @return the texture itself allowing "fluent" like uniform updates
  14626. */
  14627. setInt(name: string, value: number): ProceduralTexture;
  14628. /**
  14629. * Set an array of floats in the shader.
  14630. * @param name Define the name of the uniform as defined in the shader
  14631. * @param value Define the value to give to the uniform
  14632. * @return the texture itself allowing "fluent" like uniform updates
  14633. */
  14634. setFloats(name: string, value: number[]): ProceduralTexture;
  14635. /**
  14636. * Set a vec3 in the shader from a Color3.
  14637. * @param name Define the name of the uniform as defined in the shader
  14638. * @param value Define the value to give to the uniform
  14639. * @return the texture itself allowing "fluent" like uniform updates
  14640. */
  14641. setColor3(name: string, value: Color3): ProceduralTexture;
  14642. /**
  14643. * Set a vec4 in the shader from a Color4.
  14644. * @param name Define the name of the uniform as defined in the shader
  14645. * @param value Define the value to give to the uniform
  14646. * @return the texture itself allowing "fluent" like uniform updates
  14647. */
  14648. setColor4(name: string, value: Color4): ProceduralTexture;
  14649. /**
  14650. * Set a vec2 in the shader from a Vector2.
  14651. * @param name Define the name of the uniform as defined in the shader
  14652. * @param value Define the value to give to the uniform
  14653. * @return the texture itself allowing "fluent" like uniform updates
  14654. */
  14655. setVector2(name: string, value: Vector2): ProceduralTexture;
  14656. /**
  14657. * Set a vec3 in the shader from a Vector3.
  14658. * @param name Define the name of the uniform as defined in the shader
  14659. * @param value Define the value to give to the uniform
  14660. * @return the texture itself allowing "fluent" like uniform updates
  14661. */
  14662. setVector3(name: string, value: Vector3): ProceduralTexture;
  14663. /**
  14664. * Set a mat4 in the shader from a MAtrix.
  14665. * @param name Define the name of the uniform as defined in the shader
  14666. * @param value Define the value to give to the uniform
  14667. * @return the texture itself allowing "fluent" like uniform updates
  14668. */
  14669. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14670. /**
  14671. * Render the texture to its associated render target.
  14672. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14673. */
  14674. render(useCameraPostProcess?: boolean): void;
  14675. /**
  14676. * Clone the texture.
  14677. * @returns the cloned texture
  14678. */
  14679. clone(): ProceduralTexture;
  14680. /**
  14681. * Dispose the texture and release its asoociated resources.
  14682. */
  14683. dispose(): void;
  14684. }
  14685. }
  14686. declare module "babylonjs/Particles/baseParticleSystem" {
  14687. import { Nullable } from "babylonjs/types";
  14688. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14690. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14691. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14692. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14693. import { Scene } from "babylonjs/scene";
  14694. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14695. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14696. import { Texture } from "babylonjs/Materials/Textures/texture";
  14697. import { Animation } from "babylonjs/Animations/animation";
  14698. /**
  14699. * This represents the base class for particle system in Babylon.
  14700. * 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.
  14701. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14702. * @example https://doc.babylonjs.com/babylon101/particles
  14703. */
  14704. export class BaseParticleSystem {
  14705. /**
  14706. * Source color is added to the destination color without alpha affecting the result
  14707. */
  14708. static BLENDMODE_ONEONE: number;
  14709. /**
  14710. * Blend current color and particle color using particle’s alpha
  14711. */
  14712. static BLENDMODE_STANDARD: number;
  14713. /**
  14714. * Add current color and particle color multiplied by particle’s alpha
  14715. */
  14716. static BLENDMODE_ADD: number;
  14717. /**
  14718. * Multiply current color with particle color
  14719. */
  14720. static BLENDMODE_MULTIPLY: number;
  14721. /**
  14722. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14723. */
  14724. static BLENDMODE_MULTIPLYADD: number;
  14725. /**
  14726. * List of animations used by the particle system.
  14727. */
  14728. animations: Animation[];
  14729. /**
  14730. * The id of the Particle system.
  14731. */
  14732. id: string;
  14733. /**
  14734. * The friendly name of the Particle system.
  14735. */
  14736. name: string;
  14737. /**
  14738. * The rendering group used by the Particle system to chose when to render.
  14739. */
  14740. renderingGroupId: number;
  14741. /**
  14742. * The emitter represents the Mesh or position we are attaching the particle system to.
  14743. */
  14744. emitter: Nullable<AbstractMesh | Vector3>;
  14745. /**
  14746. * The maximum number of particles to emit per frame
  14747. */
  14748. emitRate: number;
  14749. /**
  14750. * If you want to launch only a few particles at once, that can be done, as well.
  14751. */
  14752. manualEmitCount: number;
  14753. /**
  14754. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14755. */
  14756. updateSpeed: number;
  14757. /**
  14758. * The amount of time the particle system is running (depends of the overall update speed).
  14759. */
  14760. targetStopDuration: number;
  14761. /**
  14762. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14763. */
  14764. disposeOnStop: boolean;
  14765. /**
  14766. * Minimum power of emitting particles.
  14767. */
  14768. minEmitPower: number;
  14769. /**
  14770. * Maximum power of emitting particles.
  14771. */
  14772. maxEmitPower: number;
  14773. /**
  14774. * Minimum life time of emitting particles.
  14775. */
  14776. minLifeTime: number;
  14777. /**
  14778. * Maximum life time of emitting particles.
  14779. */
  14780. maxLifeTime: number;
  14781. /**
  14782. * Minimum Size of emitting particles.
  14783. */
  14784. minSize: number;
  14785. /**
  14786. * Maximum Size of emitting particles.
  14787. */
  14788. maxSize: number;
  14789. /**
  14790. * Minimum scale of emitting particles on X axis.
  14791. */
  14792. minScaleX: number;
  14793. /**
  14794. * Maximum scale of emitting particles on X axis.
  14795. */
  14796. maxScaleX: number;
  14797. /**
  14798. * Minimum scale of emitting particles on Y axis.
  14799. */
  14800. minScaleY: number;
  14801. /**
  14802. * Maximum scale of emitting particles on Y axis.
  14803. */
  14804. maxScaleY: number;
  14805. /**
  14806. * Gets or sets the minimal initial rotation in radians.
  14807. */
  14808. minInitialRotation: number;
  14809. /**
  14810. * Gets or sets the maximal initial rotation in radians.
  14811. */
  14812. maxInitialRotation: number;
  14813. /**
  14814. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14815. */
  14816. minAngularSpeed: number;
  14817. /**
  14818. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14819. */
  14820. maxAngularSpeed: number;
  14821. /**
  14822. * The texture used to render each particle. (this can be a spritesheet)
  14823. */
  14824. particleTexture: Nullable<Texture>;
  14825. /**
  14826. * The layer mask we are rendering the particles through.
  14827. */
  14828. layerMask: number;
  14829. /**
  14830. * This can help using your own shader to render the particle system.
  14831. * The according effect will be created
  14832. */
  14833. customShader: any;
  14834. /**
  14835. * By default particle system starts as soon as they are created. This prevents the
  14836. * automatic start to happen and let you decide when to start emitting particles.
  14837. */
  14838. preventAutoStart: boolean;
  14839. private _noiseTexture;
  14840. /**
  14841. * Gets or sets a texture used to add random noise to particle positions
  14842. */
  14843. noiseTexture: Nullable<ProceduralTexture>;
  14844. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14845. noiseStrength: Vector3;
  14846. /**
  14847. * Callback triggered when the particle animation is ending.
  14848. */
  14849. onAnimationEnd: Nullable<() => void>;
  14850. /**
  14851. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14852. */
  14853. blendMode: number;
  14854. /**
  14855. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14856. * to override the particles.
  14857. */
  14858. forceDepthWrite: boolean;
  14859. /** 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 */
  14860. preWarmCycles: number;
  14861. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14862. preWarmStepOffset: number;
  14863. /**
  14864. * 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)
  14865. */
  14866. spriteCellChangeSpeed: number;
  14867. /**
  14868. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14869. */
  14870. startSpriteCellID: number;
  14871. /**
  14872. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14873. */
  14874. endSpriteCellID: number;
  14875. /**
  14876. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14877. */
  14878. spriteCellWidth: number;
  14879. /**
  14880. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14881. */
  14882. spriteCellHeight: number;
  14883. /**
  14884. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14885. */
  14886. spriteRandomStartCell: boolean;
  14887. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14888. translationPivot: Vector2;
  14889. /** @hidden */
  14890. protected _isAnimationSheetEnabled: boolean;
  14891. /**
  14892. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14893. */
  14894. beginAnimationOnStart: boolean;
  14895. /**
  14896. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14897. */
  14898. beginAnimationFrom: number;
  14899. /**
  14900. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14901. */
  14902. beginAnimationTo: number;
  14903. /**
  14904. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14905. */
  14906. beginAnimationLoop: boolean;
  14907. /**
  14908. * Gets or sets a world offset applied to all particles
  14909. */
  14910. worldOffset: Vector3;
  14911. /**
  14912. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14913. */
  14914. isAnimationSheetEnabled: boolean;
  14915. /**
  14916. * Get hosting scene
  14917. * @returns the scene
  14918. */
  14919. getScene(): Scene;
  14920. /**
  14921. * You can use gravity if you want to give an orientation to your particles.
  14922. */
  14923. gravity: Vector3;
  14924. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14925. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14926. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14927. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14928. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14929. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14930. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14931. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14932. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14933. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14934. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14935. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14936. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14937. /**
  14938. * Defines the delay in milliseconds before starting the system (0 by default)
  14939. */
  14940. startDelay: number;
  14941. /**
  14942. * Gets the current list of drag gradients.
  14943. * You must use addDragGradient and removeDragGradient to udpate this list
  14944. * @returns the list of drag gradients
  14945. */
  14946. getDragGradients(): Nullable<Array<FactorGradient>>;
  14947. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14948. limitVelocityDamping: number;
  14949. /**
  14950. * Gets the current list of limit velocity gradients.
  14951. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14952. * @returns the list of limit velocity gradients
  14953. */
  14954. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14955. /**
  14956. * Gets the current list of color gradients.
  14957. * You must use addColorGradient and removeColorGradient to udpate this list
  14958. * @returns the list of color gradients
  14959. */
  14960. getColorGradients(): Nullable<Array<ColorGradient>>;
  14961. /**
  14962. * Gets the current list of size gradients.
  14963. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14964. * @returns the list of size gradients
  14965. */
  14966. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14967. /**
  14968. * Gets the current list of color remap gradients.
  14969. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14970. * @returns the list of color remap gradients
  14971. */
  14972. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14973. /**
  14974. * Gets the current list of alpha remap gradients.
  14975. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14976. * @returns the list of alpha remap gradients
  14977. */
  14978. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14979. /**
  14980. * Gets the current list of life time gradients.
  14981. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14982. * @returns the list of life time gradients
  14983. */
  14984. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14985. /**
  14986. * Gets the current list of angular speed gradients.
  14987. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14988. * @returns the list of angular speed gradients
  14989. */
  14990. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14991. /**
  14992. * Gets the current list of velocity gradients.
  14993. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14994. * @returns the list of velocity gradients
  14995. */
  14996. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14997. /**
  14998. * Gets the current list of start size gradients.
  14999. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15000. * @returns the list of start size gradients
  15001. */
  15002. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15003. /**
  15004. * Gets the current list of emit rate gradients.
  15005. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15006. * @returns the list of emit rate gradients
  15007. */
  15008. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15009. /**
  15010. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15011. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15012. */
  15013. direction1: Vector3;
  15014. /**
  15015. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15016. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15017. */
  15018. direction2: Vector3;
  15019. /**
  15020. * 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.
  15021. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15022. */
  15023. minEmitBox: Vector3;
  15024. /**
  15025. * 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.
  15026. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15027. */
  15028. maxEmitBox: Vector3;
  15029. /**
  15030. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15031. */
  15032. color1: Color4;
  15033. /**
  15034. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15035. */
  15036. color2: Color4;
  15037. /**
  15038. * Color the particle will have at the end of its lifetime
  15039. */
  15040. colorDead: Color4;
  15041. /**
  15042. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15043. */
  15044. textureMask: Color4;
  15045. /**
  15046. * The particle emitter type defines the emitter used by the particle system.
  15047. * It can be for example box, sphere, or cone...
  15048. */
  15049. particleEmitterType: IParticleEmitterType;
  15050. /** @hidden */
  15051. _isSubEmitter: boolean;
  15052. /**
  15053. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15054. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15055. */
  15056. billboardMode: number;
  15057. protected _isBillboardBased: boolean;
  15058. /**
  15059. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15060. */
  15061. isBillboardBased: boolean;
  15062. /**
  15063. * The scene the particle system belongs to.
  15064. */
  15065. protected _scene: Scene;
  15066. /**
  15067. * Local cache of defines for image processing.
  15068. */
  15069. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15070. /**
  15071. * Default configuration related to image processing available in the standard Material.
  15072. */
  15073. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15074. /**
  15075. * Gets the image processing configuration used either in this material.
  15076. */
  15077. /**
  15078. * Sets the Default image processing configuration used either in the this material.
  15079. *
  15080. * If sets to null, the scene one is in use.
  15081. */
  15082. imageProcessingConfiguration: ImageProcessingConfiguration;
  15083. /**
  15084. * Attaches a new image processing configuration to the Standard Material.
  15085. * @param configuration
  15086. */
  15087. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15088. /** @hidden */
  15089. protected _reset(): void;
  15090. /** @hidden */
  15091. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15092. /**
  15093. * Instantiates a particle system.
  15094. * 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.
  15095. * @param name The name of the particle system
  15096. */
  15097. constructor(name: string);
  15098. /**
  15099. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15100. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15101. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15102. * @returns the emitter
  15103. */
  15104. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15105. /**
  15106. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15107. * @param radius The radius of the hemisphere to emit from
  15108. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15109. * @returns the emitter
  15110. */
  15111. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15112. /**
  15113. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15114. * @param radius The radius of the sphere to emit from
  15115. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15116. * @returns the emitter
  15117. */
  15118. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15119. /**
  15120. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15121. * @param radius The radius of the sphere to emit from
  15122. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15123. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15124. * @returns the emitter
  15125. */
  15126. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15127. /**
  15128. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15129. * @param radius The radius of the emission cylinder
  15130. * @param height The height of the emission cylinder
  15131. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15132. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15133. * @returns the emitter
  15134. */
  15135. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15136. /**
  15137. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15138. * @param radius The radius of the cylinder to emit from
  15139. * @param height The height of the emission cylinder
  15140. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15143. * @returns the emitter
  15144. */
  15145. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15146. /**
  15147. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15148. * @param radius The radius of the cone to emit from
  15149. * @param angle The base angle of the cone
  15150. * @returns the emitter
  15151. */
  15152. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15153. /**
  15154. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15155. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15156. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15157. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15158. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15159. * @returns the emitter
  15160. */
  15161. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15162. }
  15163. }
  15164. declare module "babylonjs/Particles/subEmitter" {
  15165. import { Scene } from "babylonjs/scene";
  15166. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15167. /**
  15168. * Type of sub emitter
  15169. */
  15170. export enum SubEmitterType {
  15171. /**
  15172. * Attached to the particle over it's lifetime
  15173. */
  15174. ATTACHED = 0,
  15175. /**
  15176. * Created when the particle dies
  15177. */
  15178. END = 1
  15179. }
  15180. /**
  15181. * Sub emitter class used to emit particles from an existing particle
  15182. */
  15183. export class SubEmitter {
  15184. /**
  15185. * the particle system to be used by the sub emitter
  15186. */
  15187. particleSystem: ParticleSystem;
  15188. /**
  15189. * Type of the submitter (Default: END)
  15190. */
  15191. type: SubEmitterType;
  15192. /**
  15193. * 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)
  15194. * Note: This only is supported when using an emitter of type Mesh
  15195. */
  15196. inheritDirection: boolean;
  15197. /**
  15198. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15199. */
  15200. inheritedVelocityAmount: number;
  15201. /**
  15202. * Creates a sub emitter
  15203. * @param particleSystem the particle system to be used by the sub emitter
  15204. */
  15205. constructor(
  15206. /**
  15207. * the particle system to be used by the sub emitter
  15208. */
  15209. particleSystem: ParticleSystem);
  15210. /**
  15211. * Clones the sub emitter
  15212. * @returns the cloned sub emitter
  15213. */
  15214. clone(): SubEmitter;
  15215. /**
  15216. * Serialize current object to a JSON object
  15217. * @returns the serialized object
  15218. */
  15219. serialize(): any;
  15220. /** @hidden */
  15221. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15222. /**
  15223. * Creates a new SubEmitter from a serialized JSON version
  15224. * @param serializationObject defines the JSON object to read from
  15225. * @param scene defines the hosting scene
  15226. * @param rootUrl defines the rootUrl for data loading
  15227. * @returns a new SubEmitter
  15228. */
  15229. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15230. /** Release associated resources */
  15231. dispose(): void;
  15232. }
  15233. }
  15234. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15235. /** @hidden */
  15236. export var clipPlaneFragmentDeclaration: {
  15237. name: string;
  15238. shader: string;
  15239. };
  15240. }
  15241. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15242. /** @hidden */
  15243. export var imageProcessingDeclaration: {
  15244. name: string;
  15245. shader: string;
  15246. };
  15247. }
  15248. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15249. /** @hidden */
  15250. export var imageProcessingFunctions: {
  15251. name: string;
  15252. shader: string;
  15253. };
  15254. }
  15255. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15256. /** @hidden */
  15257. export var clipPlaneFragment: {
  15258. name: string;
  15259. shader: string;
  15260. };
  15261. }
  15262. declare module "babylonjs/Shaders/particles.fragment" {
  15263. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15264. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15265. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15266. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15267. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15268. /** @hidden */
  15269. export var particlesPixelShader: {
  15270. name: string;
  15271. shader: string;
  15272. };
  15273. }
  15274. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15275. /** @hidden */
  15276. export var clipPlaneVertexDeclaration: {
  15277. name: string;
  15278. shader: string;
  15279. };
  15280. }
  15281. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15282. /** @hidden */
  15283. export var clipPlaneVertex: {
  15284. name: string;
  15285. shader: string;
  15286. };
  15287. }
  15288. declare module "babylonjs/Shaders/particles.vertex" {
  15289. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15290. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15291. /** @hidden */
  15292. export var particlesVertexShader: {
  15293. name: string;
  15294. shader: string;
  15295. };
  15296. }
  15297. declare module "babylonjs/Particles/particleSystem" {
  15298. import { Nullable } from "babylonjs/types";
  15299. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15300. import { Observable } from "babylonjs/Misc/observable";
  15301. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15302. import { Effect } from "babylonjs/Materials/effect";
  15303. import { Scene, IDisposable } from "babylonjs/scene";
  15304. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15305. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15306. import { Particle } from "babylonjs/Particles/particle";
  15307. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15308. import "babylonjs/Shaders/particles.fragment";
  15309. import "babylonjs/Shaders/particles.vertex";
  15310. /**
  15311. * This represents a particle system in Babylon.
  15312. * 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.
  15313. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15314. * @example https://doc.babylonjs.com/babylon101/particles
  15315. */
  15316. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15317. /**
  15318. * Billboard mode will only apply to Y axis
  15319. */
  15320. static readonly BILLBOARDMODE_Y: number;
  15321. /**
  15322. * Billboard mode will apply to all axes
  15323. */
  15324. static readonly BILLBOARDMODE_ALL: number;
  15325. /**
  15326. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15327. */
  15328. static readonly BILLBOARDMODE_STRETCHED: number;
  15329. /**
  15330. * This function can be defined to provide custom update for active particles.
  15331. * This function will be called instead of regular update (age, position, color, etc.).
  15332. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15333. */
  15334. updateFunction: (particles: Particle[]) => void;
  15335. private _emitterWorldMatrix;
  15336. /**
  15337. * This function can be defined to specify initial direction for every new particle.
  15338. * It by default use the emitterType defined function
  15339. */
  15340. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15341. /**
  15342. * This function can be defined to specify initial position for every new particle.
  15343. * It by default use the emitterType defined function
  15344. */
  15345. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15346. /**
  15347. * @hidden
  15348. */
  15349. _inheritedVelocityOffset: Vector3;
  15350. /**
  15351. * An event triggered when the system is disposed
  15352. */
  15353. onDisposeObservable: Observable<ParticleSystem>;
  15354. private _onDisposeObserver;
  15355. /**
  15356. * Sets a callback that will be triggered when the system is disposed
  15357. */
  15358. onDispose: () => void;
  15359. private _particles;
  15360. private _epsilon;
  15361. private _capacity;
  15362. private _stockParticles;
  15363. private _newPartsExcess;
  15364. private _vertexData;
  15365. private _vertexBuffer;
  15366. private _vertexBuffers;
  15367. private _spriteBuffer;
  15368. private _indexBuffer;
  15369. private _effect;
  15370. private _customEffect;
  15371. private _cachedDefines;
  15372. private _scaledColorStep;
  15373. private _colorDiff;
  15374. private _scaledDirection;
  15375. private _scaledGravity;
  15376. private _currentRenderId;
  15377. private _alive;
  15378. private _useInstancing;
  15379. private _started;
  15380. private _stopped;
  15381. private _actualFrame;
  15382. private _scaledUpdateSpeed;
  15383. private _vertexBufferSize;
  15384. /** @hidden */
  15385. _currentEmitRateGradient: Nullable<FactorGradient>;
  15386. /** @hidden */
  15387. _currentEmitRate1: number;
  15388. /** @hidden */
  15389. _currentEmitRate2: number;
  15390. /** @hidden */
  15391. _currentStartSizeGradient: Nullable<FactorGradient>;
  15392. /** @hidden */
  15393. _currentStartSize1: number;
  15394. /** @hidden */
  15395. _currentStartSize2: number;
  15396. private readonly _rawTextureWidth;
  15397. private _rampGradientsTexture;
  15398. private _useRampGradients;
  15399. /** Gets or sets a boolean indicating that ramp gradients must be used
  15400. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15401. */
  15402. useRampGradients: boolean;
  15403. /**
  15404. * 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.
  15405. * 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: [])
  15406. */
  15407. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15408. private _subEmitters;
  15409. /**
  15410. * @hidden
  15411. * If the particle systems emitter should be disposed when the particle system is disposed
  15412. */
  15413. _disposeEmitterOnDispose: boolean;
  15414. /**
  15415. * The current active Sub-systems, this property is used by the root particle system only.
  15416. */
  15417. activeSubSystems: Array<ParticleSystem>;
  15418. private _rootParticleSystem;
  15419. /**
  15420. * Gets the current list of active particles
  15421. */
  15422. readonly particles: Particle[];
  15423. /**
  15424. * Returns the string "ParticleSystem"
  15425. * @returns a string containing the class name
  15426. */
  15427. getClassName(): string;
  15428. /**
  15429. * Instantiates a particle system.
  15430. * 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.
  15431. * @param name The name of the particle system
  15432. * @param capacity The max number of particles alive at the same time
  15433. * @param scene The scene the particle system belongs to
  15434. * @param customEffect a custom effect used to change the way particles are rendered by default
  15435. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15436. * @param epsilon Offset used to render the particles
  15437. */
  15438. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15439. private _addFactorGradient;
  15440. private _removeFactorGradient;
  15441. /**
  15442. * Adds a new life time gradient
  15443. * @param gradient defines the gradient to use (between 0 and 1)
  15444. * @param factor defines the life time factor to affect to the specified gradient
  15445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15446. * @returns the current particle system
  15447. */
  15448. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15449. /**
  15450. * Remove a specific life time gradient
  15451. * @param gradient defines the gradient to remove
  15452. * @returns the current particle system
  15453. */
  15454. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15455. /**
  15456. * Adds a new size gradient
  15457. * @param gradient defines the gradient to use (between 0 and 1)
  15458. * @param factor defines the size factor to affect to the specified gradient
  15459. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15460. * @returns the current particle system
  15461. */
  15462. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15463. /**
  15464. * Remove a specific size gradient
  15465. * @param gradient defines the gradient to remove
  15466. * @returns the current particle system
  15467. */
  15468. removeSizeGradient(gradient: number): IParticleSystem;
  15469. /**
  15470. * Adds a new color remap gradient
  15471. * @param gradient defines the gradient to use (between 0 and 1)
  15472. * @param min defines the color remap minimal range
  15473. * @param max defines the color remap maximal range
  15474. * @returns the current particle system
  15475. */
  15476. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15477. /**
  15478. * Remove a specific color remap gradient
  15479. * @param gradient defines the gradient to remove
  15480. * @returns the current particle system
  15481. */
  15482. removeColorRemapGradient(gradient: number): IParticleSystem;
  15483. /**
  15484. * Adds a new alpha remap gradient
  15485. * @param gradient defines the gradient to use (between 0 and 1)
  15486. * @param min defines the alpha remap minimal range
  15487. * @param max defines the alpha remap maximal range
  15488. * @returns the current particle system
  15489. */
  15490. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15491. /**
  15492. * Remove a specific alpha remap gradient
  15493. * @param gradient defines the gradient to remove
  15494. * @returns the current particle system
  15495. */
  15496. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15497. /**
  15498. * Adds a new angular speed gradient
  15499. * @param gradient defines the gradient to use (between 0 and 1)
  15500. * @param factor defines the angular speed to affect to the specified gradient
  15501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15502. * @returns the current particle system
  15503. */
  15504. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15505. /**
  15506. * Remove a specific angular speed gradient
  15507. * @param gradient defines the gradient to remove
  15508. * @returns the current particle system
  15509. */
  15510. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15511. /**
  15512. * Adds a new velocity gradient
  15513. * @param gradient defines the gradient to use (between 0 and 1)
  15514. * @param factor defines the velocity to affect to the specified gradient
  15515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15516. * @returns the current particle system
  15517. */
  15518. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15519. /**
  15520. * Remove a specific velocity gradient
  15521. * @param gradient defines the gradient to remove
  15522. * @returns the current particle system
  15523. */
  15524. removeVelocityGradient(gradient: number): IParticleSystem;
  15525. /**
  15526. * Adds a new limit velocity gradient
  15527. * @param gradient defines the gradient to use (between 0 and 1)
  15528. * @param factor defines the limit velocity value to affect to the specified gradient
  15529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15530. * @returns the current particle system
  15531. */
  15532. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15533. /**
  15534. * Remove a specific limit velocity gradient
  15535. * @param gradient defines the gradient to remove
  15536. * @returns the current particle system
  15537. */
  15538. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15539. /**
  15540. * Adds a new drag gradient
  15541. * @param gradient defines the gradient to use (between 0 and 1)
  15542. * @param factor defines the drag value to affect to the specified gradient
  15543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15544. * @returns the current particle system
  15545. */
  15546. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15547. /**
  15548. * Remove a specific drag gradient
  15549. * @param gradient defines the gradient to remove
  15550. * @returns the current particle system
  15551. */
  15552. removeDragGradient(gradient: number): IParticleSystem;
  15553. /**
  15554. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15555. * @param gradient defines the gradient to use (between 0 and 1)
  15556. * @param factor defines the emit rate value to affect to the specified gradient
  15557. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15558. * @returns the current particle system
  15559. */
  15560. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15561. /**
  15562. * Remove a specific emit rate gradient
  15563. * @param gradient defines the gradient to remove
  15564. * @returns the current particle system
  15565. */
  15566. removeEmitRateGradient(gradient: number): IParticleSystem;
  15567. /**
  15568. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15569. * @param gradient defines the gradient to use (between 0 and 1)
  15570. * @param factor defines the start size value to affect to the specified gradient
  15571. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15572. * @returns the current particle system
  15573. */
  15574. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15575. /**
  15576. * Remove a specific start size gradient
  15577. * @param gradient defines the gradient to remove
  15578. * @returns the current particle system
  15579. */
  15580. removeStartSizeGradient(gradient: number): IParticleSystem;
  15581. private _createRampGradientTexture;
  15582. /**
  15583. * Gets the current list of ramp gradients.
  15584. * You must use addRampGradient and removeRampGradient to udpate this list
  15585. * @returns the list of ramp gradients
  15586. */
  15587. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15588. /**
  15589. * Adds a new ramp gradient used to remap particle colors
  15590. * @param gradient defines the gradient to use (between 0 and 1)
  15591. * @param color defines the color to affect to the specified gradient
  15592. * @returns the current particle system
  15593. */
  15594. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15595. /**
  15596. * Remove a specific ramp gradient
  15597. * @param gradient defines the gradient to remove
  15598. * @returns the current particle system
  15599. */
  15600. removeRampGradient(gradient: number): ParticleSystem;
  15601. /**
  15602. * Adds a new color gradient
  15603. * @param gradient defines the gradient to use (between 0 and 1)
  15604. * @param color1 defines the color to affect to the specified gradient
  15605. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15606. * @returns this particle system
  15607. */
  15608. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15609. /**
  15610. * Remove a specific color gradient
  15611. * @param gradient defines the gradient to remove
  15612. * @returns this particle system
  15613. */
  15614. removeColorGradient(gradient: number): IParticleSystem;
  15615. private _fetchR;
  15616. protected _reset(): void;
  15617. private _resetEffect;
  15618. private _createVertexBuffers;
  15619. private _createIndexBuffer;
  15620. /**
  15621. * Gets the maximum number of particles active at the same time.
  15622. * @returns The max number of active particles.
  15623. */
  15624. getCapacity(): number;
  15625. /**
  15626. * Gets whether there are still active particles in the system.
  15627. * @returns True if it is alive, otherwise false.
  15628. */
  15629. isAlive(): boolean;
  15630. /**
  15631. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15632. * @returns True if it has been started, otherwise false.
  15633. */
  15634. isStarted(): boolean;
  15635. private _prepareSubEmitterInternalArray;
  15636. /**
  15637. * Starts the particle system and begins to emit
  15638. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15639. */
  15640. start(delay?: number): void;
  15641. /**
  15642. * Stops the particle system.
  15643. * @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.
  15644. */
  15645. stop(stopSubEmitters?: boolean): void;
  15646. /**
  15647. * Remove all active particles
  15648. */
  15649. reset(): void;
  15650. /**
  15651. * @hidden (for internal use only)
  15652. */
  15653. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15654. /**
  15655. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15656. * Its lifetime will start back at 0.
  15657. */
  15658. recycleParticle: (particle: Particle) => void;
  15659. private _stopSubEmitters;
  15660. private _createParticle;
  15661. private _removeFromRoot;
  15662. private _emitFromParticle;
  15663. private _update;
  15664. /** @hidden */
  15665. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15666. /** @hidden */
  15667. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15668. /** @hidden */
  15669. private _getEffect;
  15670. /**
  15671. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15672. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15673. */
  15674. animate(preWarmOnly?: boolean): void;
  15675. private _appendParticleVertices;
  15676. /**
  15677. * Rebuilds the particle system.
  15678. */
  15679. rebuild(): void;
  15680. /**
  15681. * Is this system ready to be used/rendered
  15682. * @return true if the system is ready
  15683. */
  15684. isReady(): boolean;
  15685. private _render;
  15686. /**
  15687. * Renders the particle system in its current state.
  15688. * @returns the current number of particles
  15689. */
  15690. render(): number;
  15691. /**
  15692. * Disposes the particle system and free the associated resources
  15693. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15694. */
  15695. dispose(disposeTexture?: boolean): void;
  15696. /**
  15697. * Clones the particle system.
  15698. * @param name The name of the cloned object
  15699. * @param newEmitter The new emitter to use
  15700. * @returns the cloned particle system
  15701. */
  15702. clone(name: string, newEmitter: any): ParticleSystem;
  15703. /**
  15704. * Serializes the particle system to a JSON object.
  15705. * @returns the JSON object
  15706. */
  15707. serialize(): any;
  15708. /** @hidden */
  15709. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15710. /** @hidden */
  15711. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15712. /**
  15713. * Parses a JSON object to create a particle system.
  15714. * @param parsedParticleSystem The JSON object to parse
  15715. * @param scene The scene to create the particle system in
  15716. * @param rootUrl The root url to use to load external dependencies like texture
  15717. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15718. * @returns the Parsed particle system
  15719. */
  15720. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15721. }
  15722. }
  15723. declare module "babylonjs/Particles/particle" {
  15724. import { Nullable } from "babylonjs/types";
  15725. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15726. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15727. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15728. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15729. /**
  15730. * A particle represents one of the element emitted by a particle system.
  15731. * This is mainly define by its coordinates, direction, velocity and age.
  15732. */
  15733. export class Particle {
  15734. /**
  15735. * The particle system the particle belongs to.
  15736. */
  15737. particleSystem: ParticleSystem;
  15738. private static _Count;
  15739. /**
  15740. * Unique ID of the particle
  15741. */
  15742. id: number;
  15743. /**
  15744. * The world position of the particle in the scene.
  15745. */
  15746. position: Vector3;
  15747. /**
  15748. * The world direction of the particle in the scene.
  15749. */
  15750. direction: Vector3;
  15751. /**
  15752. * The color of the particle.
  15753. */
  15754. color: Color4;
  15755. /**
  15756. * The color change of the particle per step.
  15757. */
  15758. colorStep: Color4;
  15759. /**
  15760. * Defines how long will the life of the particle be.
  15761. */
  15762. lifeTime: number;
  15763. /**
  15764. * The current age of the particle.
  15765. */
  15766. age: number;
  15767. /**
  15768. * The current size of the particle.
  15769. */
  15770. size: number;
  15771. /**
  15772. * The current scale of the particle.
  15773. */
  15774. scale: Vector2;
  15775. /**
  15776. * The current angle of the particle.
  15777. */
  15778. angle: number;
  15779. /**
  15780. * Defines how fast is the angle changing.
  15781. */
  15782. angularSpeed: number;
  15783. /**
  15784. * Defines the cell index used by the particle to be rendered from a sprite.
  15785. */
  15786. cellIndex: number;
  15787. /**
  15788. * The information required to support color remapping
  15789. */
  15790. remapData: Vector4;
  15791. /** @hidden */
  15792. _randomCellOffset?: number;
  15793. /** @hidden */
  15794. _initialDirection: Nullable<Vector3>;
  15795. /** @hidden */
  15796. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15797. /** @hidden */
  15798. _initialStartSpriteCellID: number;
  15799. /** @hidden */
  15800. _initialEndSpriteCellID: number;
  15801. /** @hidden */
  15802. _currentColorGradient: Nullable<ColorGradient>;
  15803. /** @hidden */
  15804. _currentColor1: Color4;
  15805. /** @hidden */
  15806. _currentColor2: Color4;
  15807. /** @hidden */
  15808. _currentSizeGradient: Nullable<FactorGradient>;
  15809. /** @hidden */
  15810. _currentSize1: number;
  15811. /** @hidden */
  15812. _currentSize2: number;
  15813. /** @hidden */
  15814. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15815. /** @hidden */
  15816. _currentAngularSpeed1: number;
  15817. /** @hidden */
  15818. _currentAngularSpeed2: number;
  15819. /** @hidden */
  15820. _currentVelocityGradient: Nullable<FactorGradient>;
  15821. /** @hidden */
  15822. _currentVelocity1: number;
  15823. /** @hidden */
  15824. _currentVelocity2: number;
  15825. /** @hidden */
  15826. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15827. /** @hidden */
  15828. _currentLimitVelocity1: number;
  15829. /** @hidden */
  15830. _currentLimitVelocity2: number;
  15831. /** @hidden */
  15832. _currentDragGradient: Nullable<FactorGradient>;
  15833. /** @hidden */
  15834. _currentDrag1: number;
  15835. /** @hidden */
  15836. _currentDrag2: number;
  15837. /** @hidden */
  15838. _randomNoiseCoordinates1: Vector3;
  15839. /** @hidden */
  15840. _randomNoiseCoordinates2: Vector3;
  15841. /**
  15842. * Creates a new instance Particle
  15843. * @param particleSystem the particle system the particle belongs to
  15844. */
  15845. constructor(
  15846. /**
  15847. * The particle system the particle belongs to.
  15848. */
  15849. particleSystem: ParticleSystem);
  15850. private updateCellInfoFromSystem;
  15851. /**
  15852. * Defines how the sprite cell index is updated for the particle
  15853. */
  15854. updateCellIndex(): void;
  15855. /** @hidden */
  15856. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15857. /** @hidden */
  15858. _inheritParticleInfoToSubEmitters(): void;
  15859. /** @hidden */
  15860. _reset(): void;
  15861. /**
  15862. * Copy the properties of particle to another one.
  15863. * @param other the particle to copy the information to.
  15864. */
  15865. copyTo(other: Particle): void;
  15866. }
  15867. }
  15868. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15869. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15870. import { Effect } from "babylonjs/Materials/effect";
  15871. import { Particle } from "babylonjs/Particles/particle";
  15872. /**
  15873. * Particle emitter represents a volume emitting particles.
  15874. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15875. */
  15876. export interface IParticleEmitterType {
  15877. /**
  15878. * Called by the particle System when the direction is computed for the created particle.
  15879. * @param worldMatrix is the world matrix of the particle system
  15880. * @param directionToUpdate is the direction vector to update with the result
  15881. * @param particle is the particle we are computed the direction for
  15882. */
  15883. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15884. /**
  15885. * Called by the particle System when the position is computed for the created particle.
  15886. * @param worldMatrix is the world matrix of the particle system
  15887. * @param positionToUpdate is the position vector to update with the result
  15888. * @param particle is the particle we are computed the position for
  15889. */
  15890. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15891. /**
  15892. * Clones the current emitter and returns a copy of it
  15893. * @returns the new emitter
  15894. */
  15895. clone(): IParticleEmitterType;
  15896. /**
  15897. * Called by the GPUParticleSystem to setup the update shader
  15898. * @param effect defines the update shader
  15899. */
  15900. applyToShader(effect: Effect): void;
  15901. /**
  15902. * Returns a string to use to update the GPU particles update shader
  15903. * @returns the effect defines string
  15904. */
  15905. getEffectDefines(): string;
  15906. /**
  15907. * Returns a string representing the class name
  15908. * @returns a string containing the class name
  15909. */
  15910. getClassName(): string;
  15911. /**
  15912. * Serializes the particle system to a JSON object.
  15913. * @returns the JSON object
  15914. */
  15915. serialize(): any;
  15916. /**
  15917. * Parse properties from a JSON object
  15918. * @param serializationObject defines the JSON object
  15919. */
  15920. parse(serializationObject: any): void;
  15921. }
  15922. }
  15923. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15924. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15925. import { Effect } from "babylonjs/Materials/effect";
  15926. import { Particle } from "babylonjs/Particles/particle";
  15927. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15928. /**
  15929. * Particle emitter emitting particles from the inside of a box.
  15930. * It emits the particles randomly between 2 given directions.
  15931. */
  15932. export class BoxParticleEmitter implements IParticleEmitterType {
  15933. /**
  15934. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15935. */
  15936. direction1: Vector3;
  15937. /**
  15938. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15939. */
  15940. direction2: Vector3;
  15941. /**
  15942. * 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.
  15943. */
  15944. minEmitBox: Vector3;
  15945. /**
  15946. * 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.
  15947. */
  15948. maxEmitBox: Vector3;
  15949. /**
  15950. * Creates a new instance BoxParticleEmitter
  15951. */
  15952. constructor();
  15953. /**
  15954. * Called by the particle System when the direction is computed for the created particle.
  15955. * @param worldMatrix is the world matrix of the particle system
  15956. * @param directionToUpdate is the direction vector to update with the result
  15957. * @param particle is the particle we are computed the direction for
  15958. */
  15959. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15960. /**
  15961. * Called by the particle System when the position is computed for the created particle.
  15962. * @param worldMatrix is the world matrix of the particle system
  15963. * @param positionToUpdate is the position vector to update with the result
  15964. * @param particle is the particle we are computed the position for
  15965. */
  15966. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15967. /**
  15968. * Clones the current emitter and returns a copy of it
  15969. * @returns the new emitter
  15970. */
  15971. clone(): BoxParticleEmitter;
  15972. /**
  15973. * Called by the GPUParticleSystem to setup the update shader
  15974. * @param effect defines the update shader
  15975. */
  15976. applyToShader(effect: Effect): void;
  15977. /**
  15978. * Returns a string to use to update the GPU particles update shader
  15979. * @returns a string containng the defines string
  15980. */
  15981. getEffectDefines(): string;
  15982. /**
  15983. * Returns the string "BoxParticleEmitter"
  15984. * @returns a string containing the class name
  15985. */
  15986. getClassName(): string;
  15987. /**
  15988. * Serializes the particle system to a JSON object.
  15989. * @returns the JSON object
  15990. */
  15991. serialize(): any;
  15992. /**
  15993. * Parse properties from a JSON object
  15994. * @param serializationObject defines the JSON object
  15995. */
  15996. parse(serializationObject: any): void;
  15997. }
  15998. }
  15999. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16000. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16001. import { Effect } from "babylonjs/Materials/effect";
  16002. import { Particle } from "babylonjs/Particles/particle";
  16003. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16004. /**
  16005. * Particle emitter emitting particles from the inside of a cone.
  16006. * It emits the particles alongside the cone volume from the base to the particle.
  16007. * The emission direction might be randomized.
  16008. */
  16009. export class ConeParticleEmitter implements IParticleEmitterType {
  16010. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16011. directionRandomizer: number;
  16012. private _radius;
  16013. private _angle;
  16014. private _height;
  16015. /**
  16016. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16017. */
  16018. radiusRange: number;
  16019. /**
  16020. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16021. */
  16022. heightRange: number;
  16023. /**
  16024. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16025. */
  16026. emitFromSpawnPointOnly: boolean;
  16027. /**
  16028. * Gets or sets the radius of the emission cone
  16029. */
  16030. radius: number;
  16031. /**
  16032. * Gets or sets the angle of the emission cone
  16033. */
  16034. angle: number;
  16035. private _buildHeight;
  16036. /**
  16037. * Creates a new instance ConeParticleEmitter
  16038. * @param radius the radius of the emission cone (1 by default)
  16039. * @param angle the cone base angle (PI by default)
  16040. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16041. */
  16042. constructor(radius?: number, angle?: number,
  16043. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16044. directionRandomizer?: number);
  16045. /**
  16046. * Called by the particle System when the direction is computed for the created particle.
  16047. * @param worldMatrix is the world matrix of the particle system
  16048. * @param directionToUpdate is the direction vector to update with the result
  16049. * @param particle is the particle we are computed the direction for
  16050. */
  16051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16052. /**
  16053. * Called by the particle System when the position is computed for the created particle.
  16054. * @param worldMatrix is the world matrix of the particle system
  16055. * @param positionToUpdate is the position vector to update with the result
  16056. * @param particle is the particle we are computed the position for
  16057. */
  16058. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16059. /**
  16060. * Clones the current emitter and returns a copy of it
  16061. * @returns the new emitter
  16062. */
  16063. clone(): ConeParticleEmitter;
  16064. /**
  16065. * Called by the GPUParticleSystem to setup the update shader
  16066. * @param effect defines the update shader
  16067. */
  16068. applyToShader(effect: Effect): void;
  16069. /**
  16070. * Returns a string to use to update the GPU particles update shader
  16071. * @returns a string containng the defines string
  16072. */
  16073. getEffectDefines(): string;
  16074. /**
  16075. * Returns the string "ConeParticleEmitter"
  16076. * @returns a string containing the class name
  16077. */
  16078. getClassName(): string;
  16079. /**
  16080. * Serializes the particle system to a JSON object.
  16081. * @returns the JSON object
  16082. */
  16083. serialize(): any;
  16084. /**
  16085. * Parse properties from a JSON object
  16086. * @param serializationObject defines the JSON object
  16087. */
  16088. parse(serializationObject: any): void;
  16089. }
  16090. }
  16091. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16092. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16093. import { Effect } from "babylonjs/Materials/effect";
  16094. import { Particle } from "babylonjs/Particles/particle";
  16095. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16096. /**
  16097. * Particle emitter emitting particles from the inside of a cylinder.
  16098. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16099. */
  16100. export class CylinderParticleEmitter implements IParticleEmitterType {
  16101. /**
  16102. * The radius of the emission cylinder.
  16103. */
  16104. radius: number;
  16105. /**
  16106. * The height of the emission cylinder.
  16107. */
  16108. height: number;
  16109. /**
  16110. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16111. */
  16112. radiusRange: number;
  16113. /**
  16114. * How much to randomize the particle direction [0-1].
  16115. */
  16116. directionRandomizer: number;
  16117. /**
  16118. * Creates a new instance CylinderParticleEmitter
  16119. * @param radius the radius of the emission cylinder (1 by default)
  16120. * @param height the height of the emission cylinder (1 by default)
  16121. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16122. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16123. */
  16124. constructor(
  16125. /**
  16126. * The radius of the emission cylinder.
  16127. */
  16128. radius?: number,
  16129. /**
  16130. * The height of the emission cylinder.
  16131. */
  16132. height?: number,
  16133. /**
  16134. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16135. */
  16136. radiusRange?: number,
  16137. /**
  16138. * How much to randomize the particle direction [0-1].
  16139. */
  16140. directionRandomizer?: number);
  16141. /**
  16142. * Called by the particle System when the direction is computed for the created particle.
  16143. * @param worldMatrix is the world matrix of the particle system
  16144. * @param directionToUpdate is the direction vector to update with the result
  16145. * @param particle is the particle we are computed the direction for
  16146. */
  16147. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16148. /**
  16149. * Called by the particle System when the position is computed for the created particle.
  16150. * @param worldMatrix is the world matrix of the particle system
  16151. * @param positionToUpdate is the position vector to update with the result
  16152. * @param particle is the particle we are computed the position for
  16153. */
  16154. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16155. /**
  16156. * Clones the current emitter and returns a copy of it
  16157. * @returns the new emitter
  16158. */
  16159. clone(): CylinderParticleEmitter;
  16160. /**
  16161. * Called by the GPUParticleSystem to setup the update shader
  16162. * @param effect defines the update shader
  16163. */
  16164. applyToShader(effect: Effect): void;
  16165. /**
  16166. * Returns a string to use to update the GPU particles update shader
  16167. * @returns a string containng the defines string
  16168. */
  16169. getEffectDefines(): string;
  16170. /**
  16171. * Returns the string "CylinderParticleEmitter"
  16172. * @returns a string containing the class name
  16173. */
  16174. getClassName(): string;
  16175. /**
  16176. * Serializes the particle system to a JSON object.
  16177. * @returns the JSON object
  16178. */
  16179. serialize(): any;
  16180. /**
  16181. * Parse properties from a JSON object
  16182. * @param serializationObject defines the JSON object
  16183. */
  16184. parse(serializationObject: any): void;
  16185. }
  16186. /**
  16187. * Particle emitter emitting particles from the inside of a cylinder.
  16188. * It emits the particles randomly between two vectors.
  16189. */
  16190. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16191. /**
  16192. * The min limit of the emission direction.
  16193. */
  16194. direction1: Vector3;
  16195. /**
  16196. * The max limit of the emission direction.
  16197. */
  16198. direction2: Vector3;
  16199. /**
  16200. * Creates a new instance CylinderDirectedParticleEmitter
  16201. * @param radius the radius of the emission cylinder (1 by default)
  16202. * @param height the height of the emission cylinder (1 by default)
  16203. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16204. * @param direction1 the min limit of the emission direction (up vector by default)
  16205. * @param direction2 the max limit of the emission direction (up vector by default)
  16206. */
  16207. constructor(radius?: number, height?: number, radiusRange?: number,
  16208. /**
  16209. * The min limit of the emission direction.
  16210. */
  16211. direction1?: Vector3,
  16212. /**
  16213. * The max limit of the emission direction.
  16214. */
  16215. direction2?: Vector3);
  16216. /**
  16217. * Called by the particle System when the direction is computed for the created particle.
  16218. * @param worldMatrix is the world matrix of the particle system
  16219. * @param directionToUpdate is the direction vector to update with the result
  16220. * @param particle is the particle we are computed the direction for
  16221. */
  16222. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16223. /**
  16224. * Clones the current emitter and returns a copy of it
  16225. * @returns the new emitter
  16226. */
  16227. clone(): CylinderDirectedParticleEmitter;
  16228. /**
  16229. * Called by the GPUParticleSystem to setup the update shader
  16230. * @param effect defines the update shader
  16231. */
  16232. applyToShader(effect: Effect): void;
  16233. /**
  16234. * Returns a string to use to update the GPU particles update shader
  16235. * @returns a string containng the defines string
  16236. */
  16237. getEffectDefines(): string;
  16238. /**
  16239. * Returns the string "CylinderDirectedParticleEmitter"
  16240. * @returns a string containing the class name
  16241. */
  16242. getClassName(): string;
  16243. /**
  16244. * Serializes the particle system to a JSON object.
  16245. * @returns the JSON object
  16246. */
  16247. serialize(): any;
  16248. /**
  16249. * Parse properties from a JSON object
  16250. * @param serializationObject defines the JSON object
  16251. */
  16252. parse(serializationObject: any): void;
  16253. }
  16254. }
  16255. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16256. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16257. import { Effect } from "babylonjs/Materials/effect";
  16258. import { Particle } from "babylonjs/Particles/particle";
  16259. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16260. /**
  16261. * Particle emitter emitting particles from the inside of a hemisphere.
  16262. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16263. */
  16264. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16265. /**
  16266. * The radius of the emission hemisphere.
  16267. */
  16268. radius: number;
  16269. /**
  16270. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16271. */
  16272. radiusRange: number;
  16273. /**
  16274. * How much to randomize the particle direction [0-1].
  16275. */
  16276. directionRandomizer: number;
  16277. /**
  16278. * Creates a new instance HemisphericParticleEmitter
  16279. * @param radius the radius of the emission hemisphere (1 by default)
  16280. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16281. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16282. */
  16283. constructor(
  16284. /**
  16285. * The radius of the emission hemisphere.
  16286. */
  16287. radius?: number,
  16288. /**
  16289. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16290. */
  16291. radiusRange?: number,
  16292. /**
  16293. * How much to randomize the particle direction [0-1].
  16294. */
  16295. directionRandomizer?: number);
  16296. /**
  16297. * Called by the particle System when the direction is computed for the created particle.
  16298. * @param worldMatrix is the world matrix of the particle system
  16299. * @param directionToUpdate is the direction vector to update with the result
  16300. * @param particle is the particle we are computed the direction for
  16301. */
  16302. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16303. /**
  16304. * Called by the particle System when the position is computed for the created particle.
  16305. * @param worldMatrix is the world matrix of the particle system
  16306. * @param positionToUpdate is the position vector to update with the result
  16307. * @param particle is the particle we are computed the position for
  16308. */
  16309. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16310. /**
  16311. * Clones the current emitter and returns a copy of it
  16312. * @returns the new emitter
  16313. */
  16314. clone(): HemisphericParticleEmitter;
  16315. /**
  16316. * Called by the GPUParticleSystem to setup the update shader
  16317. * @param effect defines the update shader
  16318. */
  16319. applyToShader(effect: Effect): void;
  16320. /**
  16321. * Returns a string to use to update the GPU particles update shader
  16322. * @returns a string containng the defines string
  16323. */
  16324. getEffectDefines(): string;
  16325. /**
  16326. * Returns the string "HemisphericParticleEmitter"
  16327. * @returns a string containing the class name
  16328. */
  16329. getClassName(): string;
  16330. /**
  16331. * Serializes the particle system to a JSON object.
  16332. * @returns the JSON object
  16333. */
  16334. serialize(): any;
  16335. /**
  16336. * Parse properties from a JSON object
  16337. * @param serializationObject defines the JSON object
  16338. */
  16339. parse(serializationObject: any): void;
  16340. }
  16341. }
  16342. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16343. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16344. import { Effect } from "babylonjs/Materials/effect";
  16345. import { Particle } from "babylonjs/Particles/particle";
  16346. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16347. /**
  16348. * Particle emitter emitting particles from a point.
  16349. * It emits the particles randomly between 2 given directions.
  16350. */
  16351. export class PointParticleEmitter implements IParticleEmitterType {
  16352. /**
  16353. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16354. */
  16355. direction1: Vector3;
  16356. /**
  16357. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16358. */
  16359. direction2: Vector3;
  16360. /**
  16361. * Creates a new instance PointParticleEmitter
  16362. */
  16363. constructor();
  16364. /**
  16365. * Called by the particle System when the direction is computed for the created particle.
  16366. * @param worldMatrix is the world matrix of the particle system
  16367. * @param directionToUpdate is the direction vector to update with the result
  16368. * @param particle is the particle we are computed the direction for
  16369. */
  16370. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16371. /**
  16372. * Called by the particle System when the position is computed for the created particle.
  16373. * @param worldMatrix is the world matrix of the particle system
  16374. * @param positionToUpdate is the position vector to update with the result
  16375. * @param particle is the particle we are computed the position for
  16376. */
  16377. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16378. /**
  16379. * Clones the current emitter and returns a copy of it
  16380. * @returns the new emitter
  16381. */
  16382. clone(): PointParticleEmitter;
  16383. /**
  16384. * Called by the GPUParticleSystem to setup the update shader
  16385. * @param effect defines the update shader
  16386. */
  16387. applyToShader(effect: Effect): void;
  16388. /**
  16389. * Returns a string to use to update the GPU particles update shader
  16390. * @returns a string containng the defines string
  16391. */
  16392. getEffectDefines(): string;
  16393. /**
  16394. * Returns the string "PointParticleEmitter"
  16395. * @returns a string containing the class name
  16396. */
  16397. getClassName(): string;
  16398. /**
  16399. * Serializes the particle system to a JSON object.
  16400. * @returns the JSON object
  16401. */
  16402. serialize(): any;
  16403. /**
  16404. * Parse properties from a JSON object
  16405. * @param serializationObject defines the JSON object
  16406. */
  16407. parse(serializationObject: any): void;
  16408. }
  16409. }
  16410. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16411. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16412. import { Effect } from "babylonjs/Materials/effect";
  16413. import { Particle } from "babylonjs/Particles/particle";
  16414. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16415. /**
  16416. * Particle emitter emitting particles from the inside of a sphere.
  16417. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16418. */
  16419. export class SphereParticleEmitter implements IParticleEmitterType {
  16420. /**
  16421. * The radius of the emission sphere.
  16422. */
  16423. radius: number;
  16424. /**
  16425. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16426. */
  16427. radiusRange: number;
  16428. /**
  16429. * How much to randomize the particle direction [0-1].
  16430. */
  16431. directionRandomizer: number;
  16432. /**
  16433. * Creates a new instance SphereParticleEmitter
  16434. * @param radius the radius of the emission sphere (1 by default)
  16435. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16436. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16437. */
  16438. constructor(
  16439. /**
  16440. * The radius of the emission sphere.
  16441. */
  16442. radius?: number,
  16443. /**
  16444. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16445. */
  16446. radiusRange?: number,
  16447. /**
  16448. * How much to randomize the particle direction [0-1].
  16449. */
  16450. directionRandomizer?: number);
  16451. /**
  16452. * Called by the particle System when the direction is computed for the created particle.
  16453. * @param worldMatrix is the world matrix of the particle system
  16454. * @param directionToUpdate is the direction vector to update with the result
  16455. * @param particle is the particle we are computed the direction for
  16456. */
  16457. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16458. /**
  16459. * Called by the particle System when the position is computed for the created particle.
  16460. * @param worldMatrix is the world matrix of the particle system
  16461. * @param positionToUpdate is the position vector to update with the result
  16462. * @param particle is the particle we are computed the position for
  16463. */
  16464. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16465. /**
  16466. * Clones the current emitter and returns a copy of it
  16467. * @returns the new emitter
  16468. */
  16469. clone(): SphereParticleEmitter;
  16470. /**
  16471. * Called by the GPUParticleSystem to setup the update shader
  16472. * @param effect defines the update shader
  16473. */
  16474. applyToShader(effect: Effect): void;
  16475. /**
  16476. * Returns a string to use to update the GPU particles update shader
  16477. * @returns a string containng the defines string
  16478. */
  16479. getEffectDefines(): string;
  16480. /**
  16481. * Returns the string "SphereParticleEmitter"
  16482. * @returns a string containing the class name
  16483. */
  16484. getClassName(): string;
  16485. /**
  16486. * Serializes the particle system to a JSON object.
  16487. * @returns the JSON object
  16488. */
  16489. serialize(): any;
  16490. /**
  16491. * Parse properties from a JSON object
  16492. * @param serializationObject defines the JSON object
  16493. */
  16494. parse(serializationObject: any): void;
  16495. }
  16496. /**
  16497. * Particle emitter emitting particles from the inside of a sphere.
  16498. * It emits the particles randomly between two vectors.
  16499. */
  16500. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16501. /**
  16502. * The min limit of the emission direction.
  16503. */
  16504. direction1: Vector3;
  16505. /**
  16506. * The max limit of the emission direction.
  16507. */
  16508. direction2: Vector3;
  16509. /**
  16510. * Creates a new instance SphereDirectedParticleEmitter
  16511. * @param radius the radius of the emission sphere (1 by default)
  16512. * @param direction1 the min limit of the emission direction (up vector by default)
  16513. * @param direction2 the max limit of the emission direction (up vector by default)
  16514. */
  16515. constructor(radius?: number,
  16516. /**
  16517. * The min limit of the emission direction.
  16518. */
  16519. direction1?: Vector3,
  16520. /**
  16521. * The max limit of the emission direction.
  16522. */
  16523. direction2?: Vector3);
  16524. /**
  16525. * Called by the particle System when the direction is computed for the created particle.
  16526. * @param worldMatrix is the world matrix of the particle system
  16527. * @param directionToUpdate is the direction vector to update with the result
  16528. * @param particle is the particle we are computed the direction for
  16529. */
  16530. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16531. /**
  16532. * Clones the current emitter and returns a copy of it
  16533. * @returns the new emitter
  16534. */
  16535. clone(): SphereDirectedParticleEmitter;
  16536. /**
  16537. * Called by the GPUParticleSystem to setup the update shader
  16538. * @param effect defines the update shader
  16539. */
  16540. applyToShader(effect: Effect): void;
  16541. /**
  16542. * Returns a string to use to update the GPU particles update shader
  16543. * @returns a string containng the defines string
  16544. */
  16545. getEffectDefines(): string;
  16546. /**
  16547. * Returns the string "SphereDirectedParticleEmitter"
  16548. * @returns a string containing the class name
  16549. */
  16550. getClassName(): string;
  16551. /**
  16552. * Serializes the particle system to a JSON object.
  16553. * @returns the JSON object
  16554. */
  16555. serialize(): any;
  16556. /**
  16557. * Parse properties from a JSON object
  16558. * @param serializationObject defines the JSON object
  16559. */
  16560. parse(serializationObject: any): void;
  16561. }
  16562. }
  16563. declare module "babylonjs/Particles/EmitterTypes/index" {
  16564. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16565. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16566. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16567. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16568. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16569. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16570. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16571. }
  16572. declare module "babylonjs/Particles/IParticleSystem" {
  16573. import { Nullable } from "babylonjs/types";
  16574. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16576. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16577. import { Texture } from "babylonjs/Materials/Textures/texture";
  16578. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16579. import { Scene } from "babylonjs/scene";
  16580. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16581. import { Animation } from "babylonjs/Animations/animation";
  16582. /**
  16583. * Interface representing a particle system in Babylon.js.
  16584. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16585. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16586. */
  16587. export interface IParticleSystem {
  16588. /**
  16589. * List of animations used by the particle system.
  16590. */
  16591. animations: Animation[];
  16592. /**
  16593. * The id of the Particle system.
  16594. */
  16595. id: string;
  16596. /**
  16597. * The name of the Particle system.
  16598. */
  16599. name: string;
  16600. /**
  16601. * The emitter represents the Mesh or position we are attaching the particle system to.
  16602. */
  16603. emitter: Nullable<AbstractMesh | Vector3>;
  16604. /**
  16605. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16606. */
  16607. isBillboardBased: boolean;
  16608. /**
  16609. * The rendering group used by the Particle system to chose when to render.
  16610. */
  16611. renderingGroupId: number;
  16612. /**
  16613. * The layer mask we are rendering the particles through.
  16614. */
  16615. layerMask: number;
  16616. /**
  16617. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16618. */
  16619. updateSpeed: number;
  16620. /**
  16621. * The amount of time the particle system is running (depends of the overall update speed).
  16622. */
  16623. targetStopDuration: number;
  16624. /**
  16625. * The texture used to render each particle. (this can be a spritesheet)
  16626. */
  16627. particleTexture: Nullable<Texture>;
  16628. /**
  16629. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16630. */
  16631. blendMode: number;
  16632. /**
  16633. * Minimum life time of emitting particles.
  16634. */
  16635. minLifeTime: number;
  16636. /**
  16637. * Maximum life time of emitting particles.
  16638. */
  16639. maxLifeTime: number;
  16640. /**
  16641. * Minimum Size of emitting particles.
  16642. */
  16643. minSize: number;
  16644. /**
  16645. * Maximum Size of emitting particles.
  16646. */
  16647. maxSize: number;
  16648. /**
  16649. * Minimum scale of emitting particles on X axis.
  16650. */
  16651. minScaleX: number;
  16652. /**
  16653. * Maximum scale of emitting particles on X axis.
  16654. */
  16655. maxScaleX: number;
  16656. /**
  16657. * Minimum scale of emitting particles on Y axis.
  16658. */
  16659. minScaleY: number;
  16660. /**
  16661. * Maximum scale of emitting particles on Y axis.
  16662. */
  16663. maxScaleY: number;
  16664. /**
  16665. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16666. */
  16667. color1: Color4;
  16668. /**
  16669. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16670. */
  16671. color2: Color4;
  16672. /**
  16673. * Color the particle will have at the end of its lifetime.
  16674. */
  16675. colorDead: Color4;
  16676. /**
  16677. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16678. */
  16679. emitRate: number;
  16680. /**
  16681. * You can use gravity if you want to give an orientation to your particles.
  16682. */
  16683. gravity: Vector3;
  16684. /**
  16685. * Minimum power of emitting particles.
  16686. */
  16687. minEmitPower: number;
  16688. /**
  16689. * Maximum power of emitting particles.
  16690. */
  16691. maxEmitPower: number;
  16692. /**
  16693. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16694. */
  16695. minAngularSpeed: number;
  16696. /**
  16697. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16698. */
  16699. maxAngularSpeed: number;
  16700. /**
  16701. * Gets or sets the minimal initial rotation in radians.
  16702. */
  16703. minInitialRotation: number;
  16704. /**
  16705. * Gets or sets the maximal initial rotation in radians.
  16706. */
  16707. maxInitialRotation: number;
  16708. /**
  16709. * The particle emitter type defines the emitter used by the particle system.
  16710. * It can be for example box, sphere, or cone...
  16711. */
  16712. particleEmitterType: Nullable<IParticleEmitterType>;
  16713. /**
  16714. * Defines the delay in milliseconds before starting the system (0 by default)
  16715. */
  16716. startDelay: number;
  16717. /**
  16718. * 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
  16719. */
  16720. preWarmCycles: number;
  16721. /**
  16722. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16723. */
  16724. preWarmStepOffset: number;
  16725. /**
  16726. * 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)
  16727. */
  16728. spriteCellChangeSpeed: number;
  16729. /**
  16730. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16731. */
  16732. startSpriteCellID: number;
  16733. /**
  16734. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16735. */
  16736. endSpriteCellID: number;
  16737. /**
  16738. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16739. */
  16740. spriteCellWidth: number;
  16741. /**
  16742. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16743. */
  16744. spriteCellHeight: number;
  16745. /**
  16746. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16747. */
  16748. spriteRandomStartCell: boolean;
  16749. /**
  16750. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16751. */
  16752. isAnimationSheetEnabled: boolean;
  16753. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16754. translationPivot: Vector2;
  16755. /**
  16756. * Gets or sets a texture used to add random noise to particle positions
  16757. */
  16758. noiseTexture: Nullable<BaseTexture>;
  16759. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16760. noiseStrength: Vector3;
  16761. /**
  16762. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16763. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16764. */
  16765. billboardMode: number;
  16766. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16767. limitVelocityDamping: number;
  16768. /**
  16769. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16770. */
  16771. beginAnimationOnStart: boolean;
  16772. /**
  16773. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16774. */
  16775. beginAnimationFrom: number;
  16776. /**
  16777. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16778. */
  16779. beginAnimationTo: number;
  16780. /**
  16781. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16782. */
  16783. beginAnimationLoop: boolean;
  16784. /**
  16785. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16786. */
  16787. disposeOnStop: boolean;
  16788. /**
  16789. * Gets the maximum number of particles active at the same time.
  16790. * @returns The max number of active particles.
  16791. */
  16792. getCapacity(): number;
  16793. /**
  16794. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16795. * @returns True if it has been started, otherwise false.
  16796. */
  16797. isStarted(): boolean;
  16798. /**
  16799. * Animates the particle system for this frame.
  16800. */
  16801. animate(): void;
  16802. /**
  16803. * Renders the particle system in its current state.
  16804. * @returns the current number of particles
  16805. */
  16806. render(): number;
  16807. /**
  16808. * Dispose the particle system and frees its associated resources.
  16809. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16810. */
  16811. dispose(disposeTexture?: boolean): void;
  16812. /**
  16813. * Clones the particle system.
  16814. * @param name The name of the cloned object
  16815. * @param newEmitter The new emitter to use
  16816. * @returns the cloned particle system
  16817. */
  16818. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16819. /**
  16820. * Serializes the particle system to a JSON object.
  16821. * @returns the JSON object
  16822. */
  16823. serialize(): any;
  16824. /**
  16825. * Rebuild the particle system
  16826. */
  16827. rebuild(): void;
  16828. /**
  16829. * Starts the particle system and begins to emit
  16830. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16831. */
  16832. start(delay?: number): void;
  16833. /**
  16834. * Stops the particle system.
  16835. */
  16836. stop(): void;
  16837. /**
  16838. * Remove all active particles
  16839. */
  16840. reset(): void;
  16841. /**
  16842. * Is this system ready to be used/rendered
  16843. * @return true if the system is ready
  16844. */
  16845. isReady(): boolean;
  16846. /**
  16847. * Adds a new color gradient
  16848. * @param gradient defines the gradient to use (between 0 and 1)
  16849. * @param color1 defines the color to affect to the specified gradient
  16850. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16851. * @returns the current particle system
  16852. */
  16853. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16854. /**
  16855. * Remove a specific color gradient
  16856. * @param gradient defines the gradient to remove
  16857. * @returns the current particle system
  16858. */
  16859. removeColorGradient(gradient: number): IParticleSystem;
  16860. /**
  16861. * Adds a new size gradient
  16862. * @param gradient defines the gradient to use (between 0 and 1)
  16863. * @param factor defines the size factor to affect to the specified gradient
  16864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16865. * @returns the current particle system
  16866. */
  16867. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16868. /**
  16869. * Remove a specific size gradient
  16870. * @param gradient defines the gradient to remove
  16871. * @returns the current particle system
  16872. */
  16873. removeSizeGradient(gradient: number): IParticleSystem;
  16874. /**
  16875. * Gets the current list of color gradients.
  16876. * You must use addColorGradient and removeColorGradient to udpate this list
  16877. * @returns the list of color gradients
  16878. */
  16879. getColorGradients(): Nullable<Array<ColorGradient>>;
  16880. /**
  16881. * Gets the current list of size gradients.
  16882. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16883. * @returns the list of size gradients
  16884. */
  16885. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16886. /**
  16887. * Gets the current list of angular speed gradients.
  16888. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16889. * @returns the list of angular speed gradients
  16890. */
  16891. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16892. /**
  16893. * Adds a new angular speed gradient
  16894. * @param gradient defines the gradient to use (between 0 and 1)
  16895. * @param factor defines the angular speed to affect to the specified gradient
  16896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16897. * @returns the current particle system
  16898. */
  16899. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16900. /**
  16901. * Remove a specific angular speed gradient
  16902. * @param gradient defines the gradient to remove
  16903. * @returns the current particle system
  16904. */
  16905. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16906. /**
  16907. * Gets the current list of velocity gradients.
  16908. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16909. * @returns the list of velocity gradients
  16910. */
  16911. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16912. /**
  16913. * Adds a new velocity gradient
  16914. * @param gradient defines the gradient to use (between 0 and 1)
  16915. * @param factor defines the velocity to affect to the specified gradient
  16916. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16917. * @returns the current particle system
  16918. */
  16919. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16920. /**
  16921. * Remove a specific velocity gradient
  16922. * @param gradient defines the gradient to remove
  16923. * @returns the current particle system
  16924. */
  16925. removeVelocityGradient(gradient: number): IParticleSystem;
  16926. /**
  16927. * Gets the current list of limit velocity gradients.
  16928. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16929. * @returns the list of limit velocity gradients
  16930. */
  16931. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16932. /**
  16933. * Adds a new limit velocity gradient
  16934. * @param gradient defines the gradient to use (between 0 and 1)
  16935. * @param factor defines the limit velocity to affect to the specified gradient
  16936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16937. * @returns the current particle system
  16938. */
  16939. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16940. /**
  16941. * Remove a specific limit velocity gradient
  16942. * @param gradient defines the gradient to remove
  16943. * @returns the current particle system
  16944. */
  16945. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16946. /**
  16947. * Adds a new drag gradient
  16948. * @param gradient defines the gradient to use (between 0 and 1)
  16949. * @param factor defines the drag to affect to the specified gradient
  16950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16951. * @returns the current particle system
  16952. */
  16953. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16954. /**
  16955. * Remove a specific drag gradient
  16956. * @param gradient defines the gradient to remove
  16957. * @returns the current particle system
  16958. */
  16959. removeDragGradient(gradient: number): IParticleSystem;
  16960. /**
  16961. * Gets the current list of drag gradients.
  16962. * You must use addDragGradient and removeDragGradient to udpate this list
  16963. * @returns the list of drag gradients
  16964. */
  16965. getDragGradients(): Nullable<Array<FactorGradient>>;
  16966. /**
  16967. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16968. * @param gradient defines the gradient to use (between 0 and 1)
  16969. * @param factor defines the emit rate to affect to the specified gradient
  16970. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16971. * @returns the current particle system
  16972. */
  16973. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16974. /**
  16975. * Remove a specific emit rate gradient
  16976. * @param gradient defines the gradient to remove
  16977. * @returns the current particle system
  16978. */
  16979. removeEmitRateGradient(gradient: number): IParticleSystem;
  16980. /**
  16981. * Gets the current list of emit rate gradients.
  16982. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16983. * @returns the list of emit rate gradients
  16984. */
  16985. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16986. /**
  16987. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16988. * @param gradient defines the gradient to use (between 0 and 1)
  16989. * @param factor defines the start size to affect to the specified gradient
  16990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16991. * @returns the current particle system
  16992. */
  16993. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16994. /**
  16995. * Remove a specific start size gradient
  16996. * @param gradient defines the gradient to remove
  16997. * @returns the current particle system
  16998. */
  16999. removeStartSizeGradient(gradient: number): IParticleSystem;
  17000. /**
  17001. * Gets the current list of start size gradients.
  17002. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17003. * @returns the list of start size gradients
  17004. */
  17005. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17006. /**
  17007. * Adds a new life time gradient
  17008. * @param gradient defines the gradient to use (between 0 and 1)
  17009. * @param factor defines the life time factor to affect to the specified gradient
  17010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17011. * @returns the current particle system
  17012. */
  17013. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17014. /**
  17015. * Remove a specific life time gradient
  17016. * @param gradient defines the gradient to remove
  17017. * @returns the current particle system
  17018. */
  17019. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17020. /**
  17021. * Gets the current list of life time gradients.
  17022. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17023. * @returns the list of life time gradients
  17024. */
  17025. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17026. /**
  17027. * Gets the current list of color gradients.
  17028. * You must use addColorGradient and removeColorGradient to udpate this list
  17029. * @returns the list of color gradients
  17030. */
  17031. getColorGradients(): Nullable<Array<ColorGradient>>;
  17032. /**
  17033. * Adds a new ramp gradient used to remap particle colors
  17034. * @param gradient defines the gradient to use (between 0 and 1)
  17035. * @param color defines the color to affect to the specified gradient
  17036. * @returns the current particle system
  17037. */
  17038. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17039. /**
  17040. * Gets the current list of ramp gradients.
  17041. * You must use addRampGradient and removeRampGradient to udpate this list
  17042. * @returns the list of ramp gradients
  17043. */
  17044. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17045. /** Gets or sets a boolean indicating that ramp gradients must be used
  17046. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17047. */
  17048. useRampGradients: boolean;
  17049. /**
  17050. * Adds a new color remap gradient
  17051. * @param gradient defines the gradient to use (between 0 and 1)
  17052. * @param min defines the color remap minimal range
  17053. * @param max defines the color remap maximal range
  17054. * @returns the current particle system
  17055. */
  17056. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17057. /**
  17058. * Gets the current list of color remap gradients.
  17059. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17060. * @returns the list of color remap gradients
  17061. */
  17062. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17063. /**
  17064. * Adds a new alpha remap gradient
  17065. * @param gradient defines the gradient to use (between 0 and 1)
  17066. * @param min defines the alpha remap minimal range
  17067. * @param max defines the alpha remap maximal range
  17068. * @returns the current particle system
  17069. */
  17070. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17071. /**
  17072. * Gets the current list of alpha remap gradients.
  17073. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17074. * @returns the list of alpha remap gradients
  17075. */
  17076. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17077. /**
  17078. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17079. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17080. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17081. * @returns the emitter
  17082. */
  17083. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17084. /**
  17085. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17086. * @param radius The radius of the hemisphere to emit from
  17087. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17088. * @returns the emitter
  17089. */
  17090. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17091. /**
  17092. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17093. * @param radius The radius of the sphere to emit from
  17094. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17095. * @returns the emitter
  17096. */
  17097. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17098. /**
  17099. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17100. * @param radius The radius of the sphere to emit from
  17101. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17102. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17103. * @returns the emitter
  17104. */
  17105. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17106. /**
  17107. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17108. * @param radius The radius of the emission cylinder
  17109. * @param height The height of the emission cylinder
  17110. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17111. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17112. * @returns the emitter
  17113. */
  17114. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17115. /**
  17116. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17117. * @param radius The radius of the cylinder to emit from
  17118. * @param height The height of the emission cylinder
  17119. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17120. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17121. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17122. * @returns the emitter
  17123. */
  17124. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17125. /**
  17126. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17127. * @param radius The radius of the cone to emit from
  17128. * @param angle The base angle of the cone
  17129. * @returns the emitter
  17130. */
  17131. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17132. /**
  17133. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17134. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17135. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17136. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17137. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17138. * @returns the emitter
  17139. */
  17140. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17141. /**
  17142. * Get hosting scene
  17143. * @returns the scene
  17144. */
  17145. getScene(): Scene;
  17146. }
  17147. }
  17148. declare module "babylonjs/Meshes/instancedMesh" {
  17149. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17150. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17151. import { Camera } from "babylonjs/Cameras/camera";
  17152. import { Node } from "babylonjs/node";
  17153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17154. import { Mesh } from "babylonjs/Meshes/mesh";
  17155. import { Material } from "babylonjs/Materials/material";
  17156. import { Skeleton } from "babylonjs/Bones/skeleton";
  17157. import { Light } from "babylonjs/Lights/light";
  17158. /**
  17159. * Creates an instance based on a source mesh.
  17160. */
  17161. export class InstancedMesh extends AbstractMesh {
  17162. private _sourceMesh;
  17163. private _currentLOD;
  17164. /** @hidden */
  17165. _indexInSourceMeshInstanceArray: number;
  17166. constructor(name: string, source: Mesh);
  17167. /**
  17168. * Returns the string "InstancedMesh".
  17169. */
  17170. getClassName(): string;
  17171. /** Gets the list of lights affecting that mesh */
  17172. readonly lightSources: Light[];
  17173. _resyncLightSources(): void;
  17174. _resyncLighSource(light: Light): void;
  17175. _removeLightSource(light: Light): void;
  17176. /**
  17177. * If the source mesh receives shadows
  17178. */
  17179. readonly receiveShadows: boolean;
  17180. /**
  17181. * The material of the source mesh
  17182. */
  17183. readonly material: Nullable<Material>;
  17184. /**
  17185. * Visibility of the source mesh
  17186. */
  17187. readonly visibility: number;
  17188. /**
  17189. * Skeleton of the source mesh
  17190. */
  17191. readonly skeleton: Nullable<Skeleton>;
  17192. /**
  17193. * Rendering ground id of the source mesh
  17194. */
  17195. renderingGroupId: number;
  17196. /**
  17197. * Returns the total number of vertices (integer).
  17198. */
  17199. getTotalVertices(): number;
  17200. /**
  17201. * Returns a positive integer : the total number of indices in this mesh geometry.
  17202. * @returns the numner of indices or zero if the mesh has no geometry.
  17203. */
  17204. getTotalIndices(): number;
  17205. /**
  17206. * The source mesh of the instance
  17207. */
  17208. readonly sourceMesh: Mesh;
  17209. /**
  17210. * Is this node ready to be used/rendered
  17211. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17212. * @return {boolean} is it ready
  17213. */
  17214. isReady(completeCheck?: boolean): boolean;
  17215. /**
  17216. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17217. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17218. * @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.
  17219. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17220. */
  17221. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17222. /**
  17223. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17224. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17225. * The `data` are either a numeric array either a Float32Array.
  17226. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17227. * 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).
  17228. * Note that a new underlying VertexBuffer object is created each call.
  17229. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17230. *
  17231. * Possible `kind` values :
  17232. * - VertexBuffer.PositionKind
  17233. * - VertexBuffer.UVKind
  17234. * - VertexBuffer.UV2Kind
  17235. * - VertexBuffer.UV3Kind
  17236. * - VertexBuffer.UV4Kind
  17237. * - VertexBuffer.UV5Kind
  17238. * - VertexBuffer.UV6Kind
  17239. * - VertexBuffer.ColorKind
  17240. * - VertexBuffer.MatricesIndicesKind
  17241. * - VertexBuffer.MatricesIndicesExtraKind
  17242. * - VertexBuffer.MatricesWeightsKind
  17243. * - VertexBuffer.MatricesWeightsExtraKind
  17244. *
  17245. * Returns the Mesh.
  17246. */
  17247. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17248. /**
  17249. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17250. * If the mesh has no geometry, it is simply returned as it is.
  17251. * The `data` are either a numeric array either a Float32Array.
  17252. * No new underlying VertexBuffer object is created.
  17253. * 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.
  17254. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17255. *
  17256. * Possible `kind` values :
  17257. * - VertexBuffer.PositionKind
  17258. * - VertexBuffer.UVKind
  17259. * - VertexBuffer.UV2Kind
  17260. * - VertexBuffer.UV3Kind
  17261. * - VertexBuffer.UV4Kind
  17262. * - VertexBuffer.UV5Kind
  17263. * - VertexBuffer.UV6Kind
  17264. * - VertexBuffer.ColorKind
  17265. * - VertexBuffer.MatricesIndicesKind
  17266. * - VertexBuffer.MatricesIndicesExtraKind
  17267. * - VertexBuffer.MatricesWeightsKind
  17268. * - VertexBuffer.MatricesWeightsExtraKind
  17269. *
  17270. * Returns the Mesh.
  17271. */
  17272. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17273. /**
  17274. * Sets the mesh indices.
  17275. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17276. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17277. * This method creates a new index buffer each call.
  17278. * Returns the Mesh.
  17279. */
  17280. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17281. /**
  17282. * Boolean : True if the mesh owns the requested kind of data.
  17283. */
  17284. isVerticesDataPresent(kind: string): boolean;
  17285. /**
  17286. * Returns an array of indices (IndicesArray).
  17287. */
  17288. getIndices(): Nullable<IndicesArray>;
  17289. readonly _positions: Nullable<Vector3[]>;
  17290. /**
  17291. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17292. * This means the mesh underlying bounding box and sphere are recomputed.
  17293. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17294. * @returns the current mesh
  17295. */
  17296. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17297. /** @hidden */
  17298. _preActivate(): InstancedMesh;
  17299. /** @hidden */
  17300. _activate(renderId: number): boolean;
  17301. /** @hidden */
  17302. _postActivate(): void;
  17303. getWorldMatrix(): Matrix;
  17304. readonly isAnInstance: boolean;
  17305. /**
  17306. * Returns the current associated LOD AbstractMesh.
  17307. */
  17308. getLOD(camera: Camera): AbstractMesh;
  17309. /** @hidden */
  17310. _syncSubMeshes(): InstancedMesh;
  17311. /** @hidden */
  17312. _generatePointsArray(): boolean;
  17313. /**
  17314. * Creates a new InstancedMesh from the current mesh.
  17315. * - name (string) : the cloned mesh name
  17316. * - newParent (optional Node) : the optional Node to parent the clone to.
  17317. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17318. *
  17319. * Returns the clone.
  17320. */
  17321. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17322. /**
  17323. * Disposes the InstancedMesh.
  17324. * Returns nothing.
  17325. */
  17326. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17327. }
  17328. }
  17329. declare module "babylonjs/Materials/shaderMaterial" {
  17330. import { Scene } from "babylonjs/scene";
  17331. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17333. import { Mesh } from "babylonjs/Meshes/mesh";
  17334. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17335. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17336. import { Texture } from "babylonjs/Materials/Textures/texture";
  17337. import { Material } from "babylonjs/Materials/material";
  17338. /**
  17339. * Defines the options associated with the creation of a shader material.
  17340. */
  17341. export interface IShaderMaterialOptions {
  17342. /**
  17343. * Does the material work in alpha blend mode
  17344. */
  17345. needAlphaBlending: boolean;
  17346. /**
  17347. * Does the material work in alpha test mode
  17348. */
  17349. needAlphaTesting: boolean;
  17350. /**
  17351. * The list of attribute names used in the shader
  17352. */
  17353. attributes: string[];
  17354. /**
  17355. * The list of unifrom names used in the shader
  17356. */
  17357. uniforms: string[];
  17358. /**
  17359. * The list of UBO names used in the shader
  17360. */
  17361. uniformBuffers: string[];
  17362. /**
  17363. * The list of sampler names used in the shader
  17364. */
  17365. samplers: string[];
  17366. /**
  17367. * The list of defines used in the shader
  17368. */
  17369. defines: string[];
  17370. }
  17371. /**
  17372. * 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.
  17373. *
  17374. * This returned material effects how the mesh will look based on the code in the shaders.
  17375. *
  17376. * @see http://doc.babylonjs.com/how_to/shader_material
  17377. */
  17378. export class ShaderMaterial extends Material {
  17379. private _shaderPath;
  17380. private _options;
  17381. private _textures;
  17382. private _textureArrays;
  17383. private _floats;
  17384. private _ints;
  17385. private _floatsArrays;
  17386. private _colors3;
  17387. private _colors3Arrays;
  17388. private _colors4;
  17389. private _vectors2;
  17390. private _vectors3;
  17391. private _vectors4;
  17392. private _matrices;
  17393. private _matrices3x3;
  17394. private _matrices2x2;
  17395. private _vectors2Arrays;
  17396. private _vectors3Arrays;
  17397. private _cachedWorldViewMatrix;
  17398. private _renderId;
  17399. /**
  17400. * Instantiate a new shader material.
  17401. * 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.
  17402. * This returned material effects how the mesh will look based on the code in the shaders.
  17403. * @see http://doc.babylonjs.com/how_to/shader_material
  17404. * @param name Define the name of the material in the scene
  17405. * @param scene Define the scene the material belongs to
  17406. * @param shaderPath Defines the route to the shader code in one of three ways:
  17407. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17408. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17409. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17410. * @param options Define the options used to create the shader
  17411. */
  17412. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17413. /**
  17414. * Gets the options used to compile the shader.
  17415. * They can be modified to trigger a new compilation
  17416. */
  17417. readonly options: IShaderMaterialOptions;
  17418. /**
  17419. * Gets the current class name of the material e.g. "ShaderMaterial"
  17420. * Mainly use in serialization.
  17421. * @returns the class name
  17422. */
  17423. getClassName(): string;
  17424. /**
  17425. * Specifies if the material will require alpha blending
  17426. * @returns a boolean specifying if alpha blending is needed
  17427. */
  17428. needAlphaBlending(): boolean;
  17429. /**
  17430. * Specifies if this material should be rendered in alpha test mode
  17431. * @returns a boolean specifying if an alpha test is needed.
  17432. */
  17433. needAlphaTesting(): boolean;
  17434. private _checkUniform;
  17435. /**
  17436. * Set a texture in the shader.
  17437. * @param name Define the name of the uniform samplers as defined in the shader
  17438. * @param texture Define the texture to bind to this sampler
  17439. * @return the material itself allowing "fluent" like uniform updates
  17440. */
  17441. setTexture(name: string, texture: Texture): ShaderMaterial;
  17442. /**
  17443. * Set a texture array in the shader.
  17444. * @param name Define the name of the uniform sampler array as defined in the shader
  17445. * @param textures Define the list of textures to bind to this sampler
  17446. * @return the material itself allowing "fluent" like uniform updates
  17447. */
  17448. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17449. /**
  17450. * Set a float in the shader.
  17451. * @param name Define the name of the uniform as defined in the shader
  17452. * @param value Define the value to give to the uniform
  17453. * @return the material itself allowing "fluent" like uniform updates
  17454. */
  17455. setFloat(name: string, value: number): ShaderMaterial;
  17456. /**
  17457. * Set a int in the shader.
  17458. * @param name Define the name of the uniform as defined in the shader
  17459. * @param value Define the value to give to the uniform
  17460. * @return the material itself allowing "fluent" like uniform updates
  17461. */
  17462. setInt(name: string, value: number): ShaderMaterial;
  17463. /**
  17464. * Set an array of floats in the shader.
  17465. * @param name Define the name of the uniform as defined in the shader
  17466. * @param value Define the value to give to the uniform
  17467. * @return the material itself allowing "fluent" like uniform updates
  17468. */
  17469. setFloats(name: string, value: number[]): ShaderMaterial;
  17470. /**
  17471. * Set a vec3 in the shader from a Color3.
  17472. * @param name Define the name of the uniform as defined in the shader
  17473. * @param value Define the value to give to the uniform
  17474. * @return the material itself allowing "fluent" like uniform updates
  17475. */
  17476. setColor3(name: string, value: Color3): ShaderMaterial;
  17477. /**
  17478. * Set a vec3 array in the shader from a Color3 array.
  17479. * @param name Define the name of the uniform as defined in the shader
  17480. * @param value Define the value to give to the uniform
  17481. * @return the material itself allowing "fluent" like uniform updates
  17482. */
  17483. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17484. /**
  17485. * Set a vec4 in the shader from a Color4.
  17486. * @param name Define the name of the uniform as defined in the shader
  17487. * @param value Define the value to give to the uniform
  17488. * @return the material itself allowing "fluent" like uniform updates
  17489. */
  17490. setColor4(name: string, value: Color4): ShaderMaterial;
  17491. /**
  17492. * Set a vec2 in the shader from a Vector2.
  17493. * @param name Define the name of the uniform as defined in the shader
  17494. * @param value Define the value to give to the uniform
  17495. * @return the material itself allowing "fluent" like uniform updates
  17496. */
  17497. setVector2(name: string, value: Vector2): ShaderMaterial;
  17498. /**
  17499. * Set a vec3 in the shader from a Vector3.
  17500. * @param name Define the name of the uniform as defined in the shader
  17501. * @param value Define the value to give to the uniform
  17502. * @return the material itself allowing "fluent" like uniform updates
  17503. */
  17504. setVector3(name: string, value: Vector3): ShaderMaterial;
  17505. /**
  17506. * Set a vec4 in the shader from a Vector4.
  17507. * @param name Define the name of the uniform as defined in the shader
  17508. * @param value Define the value to give to the uniform
  17509. * @return the material itself allowing "fluent" like uniform updates
  17510. */
  17511. setVector4(name: string, value: Vector4): ShaderMaterial;
  17512. /**
  17513. * Set a mat4 in the shader from a Matrix.
  17514. * @param name Define the name of the uniform as defined in the shader
  17515. * @param value Define the value to give to the uniform
  17516. * @return the material itself allowing "fluent" like uniform updates
  17517. */
  17518. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17519. /**
  17520. * Set a mat3 in the shader from a Float32Array.
  17521. * @param name Define the name of the uniform as defined in the shader
  17522. * @param value Define the value to give to the uniform
  17523. * @return the material itself allowing "fluent" like uniform updates
  17524. */
  17525. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17526. /**
  17527. * Set a mat2 in the shader from a Float32Array.
  17528. * @param name Define the name of the uniform as defined in the shader
  17529. * @param value Define the value to give to the uniform
  17530. * @return the material itself allowing "fluent" like uniform updates
  17531. */
  17532. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17533. /**
  17534. * Set a vec2 array in the shader from a number array.
  17535. * @param name Define the name of the uniform as defined in the shader
  17536. * @param value Define the value to give to the uniform
  17537. * @return the material itself allowing "fluent" like uniform updates
  17538. */
  17539. setArray2(name: string, value: number[]): ShaderMaterial;
  17540. /**
  17541. * Set a vec3 array in the shader from a number array.
  17542. * @param name Define the name of the uniform as defined in the shader
  17543. * @param value Define the value to give to the uniform
  17544. * @return the material itself allowing "fluent" like uniform updates
  17545. */
  17546. setArray3(name: string, value: number[]): ShaderMaterial;
  17547. private _checkCache;
  17548. /**
  17549. * Specifies that the submesh is ready to be used
  17550. * @param mesh defines the mesh to check
  17551. * @param subMesh defines which submesh to check
  17552. * @param useInstances specifies that instances should be used
  17553. * @returns a boolean indicating that the submesh is ready or not
  17554. */
  17555. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17556. /**
  17557. * Checks if the material is ready to render the requested mesh
  17558. * @param mesh Define the mesh to render
  17559. * @param useInstances Define whether or not the material is used with instances
  17560. * @returns true if ready, otherwise false
  17561. */
  17562. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17563. /**
  17564. * Binds the world matrix to the material
  17565. * @param world defines the world transformation matrix
  17566. */
  17567. bindOnlyWorldMatrix(world: Matrix): void;
  17568. /**
  17569. * Binds the material to the mesh
  17570. * @param world defines the world transformation matrix
  17571. * @param mesh defines the mesh to bind the material to
  17572. */
  17573. bind(world: Matrix, mesh?: Mesh): void;
  17574. /**
  17575. * Gets the active textures from the material
  17576. * @returns an array of textures
  17577. */
  17578. getActiveTextures(): BaseTexture[];
  17579. /**
  17580. * Specifies if the material uses a texture
  17581. * @param texture defines the texture to check against the material
  17582. * @returns a boolean specifying if the material uses the texture
  17583. */
  17584. hasTexture(texture: BaseTexture): boolean;
  17585. /**
  17586. * Makes a duplicate of the material, and gives it a new name
  17587. * @param name defines the new name for the duplicated material
  17588. * @returns the cloned material
  17589. */
  17590. clone(name: string): ShaderMaterial;
  17591. /**
  17592. * Disposes the material
  17593. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17594. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17595. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17596. */
  17597. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17598. /**
  17599. * Serializes this material in a JSON representation
  17600. * @returns the serialized material object
  17601. */
  17602. serialize(): any;
  17603. /**
  17604. * Creates a shader material from parsed shader material data
  17605. * @param source defines the JSON represnetation of the material
  17606. * @param scene defines the hosting scene
  17607. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17608. * @returns a new material
  17609. */
  17610. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17611. }
  17612. }
  17613. declare module "babylonjs/Shaders/color.fragment" {
  17614. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17615. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17616. /** @hidden */
  17617. export var colorPixelShader: {
  17618. name: string;
  17619. shader: string;
  17620. };
  17621. }
  17622. declare module "babylonjs/Shaders/color.vertex" {
  17623. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17624. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17625. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17626. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17627. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17628. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17629. /** @hidden */
  17630. export var colorVertexShader: {
  17631. name: string;
  17632. shader: string;
  17633. };
  17634. }
  17635. declare module "babylonjs/Meshes/linesMesh" {
  17636. import { Nullable } from "babylonjs/types";
  17637. import { Scene } from "babylonjs/scene";
  17638. import { Color3 } from "babylonjs/Maths/math";
  17639. import { Node } from "babylonjs/node";
  17640. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17641. import { Mesh } from "babylonjs/Meshes/mesh";
  17642. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17643. import { Effect } from "babylonjs/Materials/effect";
  17644. import { Material } from "babylonjs/Materials/material";
  17645. import "babylonjs/Shaders/color.fragment";
  17646. import "babylonjs/Shaders/color.vertex";
  17647. /**
  17648. * Line mesh
  17649. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17650. */
  17651. export class LinesMesh extends Mesh {
  17652. /**
  17653. * If vertex color should be applied to the mesh
  17654. */
  17655. useVertexColor?: boolean | undefined;
  17656. /**
  17657. * If vertex alpha should be applied to the mesh
  17658. */
  17659. useVertexAlpha?: boolean | undefined;
  17660. /**
  17661. * Color of the line (Default: White)
  17662. */
  17663. color: Color3;
  17664. /**
  17665. * Alpha of the line (Default: 1)
  17666. */
  17667. alpha: number;
  17668. /**
  17669. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17670. * This margin is expressed in world space coordinates, so its value may vary.
  17671. * Default value is 0.1
  17672. */
  17673. intersectionThreshold: number;
  17674. private _colorShader;
  17675. /**
  17676. * Creates a new LinesMesh
  17677. * @param name defines the name
  17678. * @param scene defines the hosting scene
  17679. * @param parent defines the parent mesh if any
  17680. * @param source defines the optional source LinesMesh used to clone data from
  17681. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17682. * When false, achieved by calling a clone(), also passing False.
  17683. * This will make creation of children, recursive.
  17684. * @param useVertexColor defines if this LinesMesh supports vertex color
  17685. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17686. */
  17687. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17688. /**
  17689. * If vertex color should be applied to the mesh
  17690. */
  17691. useVertexColor?: boolean | undefined,
  17692. /**
  17693. * If vertex alpha should be applied to the mesh
  17694. */
  17695. useVertexAlpha?: boolean | undefined);
  17696. private _addClipPlaneDefine;
  17697. private _removeClipPlaneDefine;
  17698. isReady(): boolean;
  17699. /**
  17700. * Returns the string "LineMesh"
  17701. */
  17702. getClassName(): string;
  17703. /**
  17704. * @hidden
  17705. */
  17706. /**
  17707. * @hidden
  17708. */
  17709. material: Material;
  17710. /**
  17711. * @hidden
  17712. */
  17713. readonly checkCollisions: boolean;
  17714. /** @hidden */
  17715. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17716. /** @hidden */
  17717. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17718. /**
  17719. * Disposes of the line mesh
  17720. * @param doNotRecurse If children should be disposed
  17721. */
  17722. dispose(doNotRecurse?: boolean): void;
  17723. /**
  17724. * Returns a new LineMesh object cloned from the current one.
  17725. */
  17726. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17727. /**
  17728. * Creates a new InstancedLinesMesh object from the mesh model.
  17729. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17730. * @param name defines the name of the new instance
  17731. * @returns a new InstancedLinesMesh
  17732. */
  17733. createInstance(name: string): InstancedLinesMesh;
  17734. }
  17735. /**
  17736. * Creates an instance based on a source LinesMesh
  17737. */
  17738. export class InstancedLinesMesh extends InstancedMesh {
  17739. /**
  17740. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17741. * This margin is expressed in world space coordinates, so its value may vary.
  17742. * Initilized with the intersectionThreshold value of the source LinesMesh
  17743. */
  17744. intersectionThreshold: number;
  17745. constructor(name: string, source: LinesMesh);
  17746. /**
  17747. * Returns the string "InstancedLinesMesh".
  17748. */
  17749. getClassName(): string;
  17750. }
  17751. }
  17752. declare module "babylonjs/Shaders/line.fragment" {
  17753. /** @hidden */
  17754. export var linePixelShader: {
  17755. name: string;
  17756. shader: string;
  17757. };
  17758. }
  17759. declare module "babylonjs/Shaders/line.vertex" {
  17760. /** @hidden */
  17761. export var lineVertexShader: {
  17762. name: string;
  17763. shader: string;
  17764. };
  17765. }
  17766. declare module "babylonjs/Rendering/edgesRenderer" {
  17767. import { Nullable } from "babylonjs/types";
  17768. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17770. import { Vector3 } from "babylonjs/Maths/math";
  17771. import { IDisposable } from "babylonjs/scene";
  17772. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17773. import "babylonjs/Shaders/line.fragment";
  17774. import "babylonjs/Shaders/line.vertex";
  17775. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17776. module "babylonjs/Meshes/abstractMesh" {
  17777. interface AbstractMesh {
  17778. /**
  17779. * Disables the mesh edge rendering mode
  17780. * @returns the currentAbstractMesh
  17781. */
  17782. disableEdgesRendering(): AbstractMesh;
  17783. /**
  17784. * Enables the edge rendering mode on the mesh.
  17785. * This mode makes the mesh edges visible
  17786. * @param epsilon defines the maximal distance between two angles to detect a face
  17787. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17788. * @returns the currentAbstractMesh
  17789. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17790. */
  17791. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17792. /**
  17793. * Gets the edgesRenderer associated with the mesh
  17794. */
  17795. edgesRenderer: Nullable<EdgesRenderer>;
  17796. }
  17797. }
  17798. module "babylonjs/Meshes/linesMesh" {
  17799. interface LinesMesh {
  17800. /**
  17801. * Enables the edge rendering mode on the mesh.
  17802. * This mode makes the mesh edges visible
  17803. * @param epsilon defines the maximal distance between two angles to detect a face
  17804. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17805. * @returns the currentAbstractMesh
  17806. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17807. */
  17808. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17809. }
  17810. }
  17811. module "babylonjs/Meshes/linesMesh" {
  17812. interface InstancedLinesMesh {
  17813. /**
  17814. * Enables the edge rendering mode on the mesh.
  17815. * This mode makes the mesh edges visible
  17816. * @param epsilon defines the maximal distance between two angles to detect a face
  17817. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17818. * @returns the current InstancedLinesMesh
  17819. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17820. */
  17821. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17822. }
  17823. }
  17824. /**
  17825. * Defines the minimum contract an Edges renderer should follow.
  17826. */
  17827. export interface IEdgesRenderer extends IDisposable {
  17828. /**
  17829. * Gets or sets a boolean indicating if the edgesRenderer is active
  17830. */
  17831. isEnabled: boolean;
  17832. /**
  17833. * Renders the edges of the attached mesh,
  17834. */
  17835. render(): void;
  17836. /**
  17837. * Checks wether or not the edges renderer is ready to render.
  17838. * @return true if ready, otherwise false.
  17839. */
  17840. isReady(): boolean;
  17841. }
  17842. /**
  17843. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17844. */
  17845. export class EdgesRenderer implements IEdgesRenderer {
  17846. /**
  17847. * Define the size of the edges with an orthographic camera
  17848. */
  17849. edgesWidthScalerForOrthographic: number;
  17850. /**
  17851. * Define the size of the edges with a perspective camera
  17852. */
  17853. edgesWidthScalerForPerspective: number;
  17854. protected _source: AbstractMesh;
  17855. protected _linesPositions: number[];
  17856. protected _linesNormals: number[];
  17857. protected _linesIndices: number[];
  17858. protected _epsilon: number;
  17859. protected _indicesCount: number;
  17860. protected _lineShader: ShaderMaterial;
  17861. protected _ib: DataBuffer;
  17862. protected _buffers: {
  17863. [key: string]: Nullable<VertexBuffer>;
  17864. };
  17865. protected _checkVerticesInsteadOfIndices: boolean;
  17866. private _meshRebuildObserver;
  17867. private _meshDisposeObserver;
  17868. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17869. isEnabled: boolean;
  17870. /**
  17871. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17872. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17873. * @param source Mesh used to create edges
  17874. * @param epsilon sum of angles in adjacency to check for edge
  17875. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17876. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17877. */
  17878. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17879. protected _prepareRessources(): void;
  17880. /** @hidden */
  17881. _rebuild(): void;
  17882. /**
  17883. * Releases the required resources for the edges renderer
  17884. */
  17885. dispose(): void;
  17886. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17887. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17888. /**
  17889. * Checks if the pair of p0 and p1 is en edge
  17890. * @param faceIndex
  17891. * @param edge
  17892. * @param faceNormals
  17893. * @param p0
  17894. * @param p1
  17895. * @private
  17896. */
  17897. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17898. /**
  17899. * push line into the position, normal and index buffer
  17900. * @protected
  17901. */
  17902. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17903. /**
  17904. * Generates lines edges from adjacencjes
  17905. * @private
  17906. */
  17907. _generateEdgesLines(): void;
  17908. /**
  17909. * Checks wether or not the edges renderer is ready to render.
  17910. * @return true if ready, otherwise false.
  17911. */
  17912. isReady(): boolean;
  17913. /**
  17914. * Renders the edges of the attached mesh,
  17915. */
  17916. render(): void;
  17917. }
  17918. /**
  17919. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17920. */
  17921. export class LineEdgesRenderer extends EdgesRenderer {
  17922. /**
  17923. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17924. * @param source LineMesh used to generate edges
  17925. * @param epsilon not important (specified angle for edge detection)
  17926. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17927. */
  17928. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17929. /**
  17930. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17931. */
  17932. _generateEdgesLines(): void;
  17933. }
  17934. }
  17935. declare module "babylonjs/Rendering/renderingGroup" {
  17936. import { SmartArray } from "babylonjs/Misc/smartArray";
  17937. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17939. import { Nullable } from "babylonjs/types";
  17940. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17941. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17942. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17943. import { Material } from "babylonjs/Materials/material";
  17944. import { Scene } from "babylonjs/scene";
  17945. /**
  17946. * This represents the object necessary to create a rendering group.
  17947. * This is exclusively used and created by the rendering manager.
  17948. * To modify the behavior, you use the available helpers in your scene or meshes.
  17949. * @hidden
  17950. */
  17951. export class RenderingGroup {
  17952. index: number;
  17953. private _scene;
  17954. private _opaqueSubMeshes;
  17955. private _transparentSubMeshes;
  17956. private _alphaTestSubMeshes;
  17957. private _depthOnlySubMeshes;
  17958. private _particleSystems;
  17959. private _spriteManagers;
  17960. private _opaqueSortCompareFn;
  17961. private _alphaTestSortCompareFn;
  17962. private _transparentSortCompareFn;
  17963. private _renderOpaque;
  17964. private _renderAlphaTest;
  17965. private _renderTransparent;
  17966. /** @hidden */
  17967. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17968. onBeforeTransparentRendering: () => void;
  17969. /**
  17970. * Set the opaque sort comparison function.
  17971. * If null the sub meshes will be render in the order they were created
  17972. */
  17973. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17974. /**
  17975. * Set the alpha test sort comparison function.
  17976. * If null the sub meshes will be render in the order they were created
  17977. */
  17978. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17979. /**
  17980. * Set the transparent sort comparison function.
  17981. * If null the sub meshes will be render in the order they were created
  17982. */
  17983. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17984. /**
  17985. * Creates a new rendering group.
  17986. * @param index The rendering group index
  17987. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17988. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17989. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17990. */
  17991. 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>);
  17992. /**
  17993. * Render all the sub meshes contained in the group.
  17994. * @param customRenderFunction Used to override the default render behaviour of the group.
  17995. * @returns true if rendered some submeshes.
  17996. */
  17997. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17998. /**
  17999. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  18000. * @param subMeshes The submeshes to render
  18001. */
  18002. private renderOpaqueSorted;
  18003. /**
  18004. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  18005. * @param subMeshes The submeshes to render
  18006. */
  18007. private renderAlphaTestSorted;
  18008. /**
  18009. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  18010. * @param subMeshes The submeshes to render
  18011. */
  18012. private renderTransparentSorted;
  18013. /**
  18014. * Renders the submeshes in a specified order.
  18015. * @param subMeshes The submeshes to sort before render
  18016. * @param sortCompareFn The comparison function use to sort
  18017. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  18018. * @param transparent Specifies to activate blending if true
  18019. */
  18020. private static renderSorted;
  18021. /**
  18022. * Renders the submeshes in the order they were dispatched (no sort applied).
  18023. * @param subMeshes The submeshes to render
  18024. */
  18025. private static renderUnsorted;
  18026. /**
  18027. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18028. * are rendered back to front if in the same alpha index.
  18029. *
  18030. * @param a The first submesh
  18031. * @param b The second submesh
  18032. * @returns The result of the comparison
  18033. */
  18034. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  18035. /**
  18036. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18037. * are rendered back to front.
  18038. *
  18039. * @param a The first submesh
  18040. * @param b The second submesh
  18041. * @returns The result of the comparison
  18042. */
  18043. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  18044. /**
  18045. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18046. * are rendered front to back (prevent overdraw).
  18047. *
  18048. * @param a The first submesh
  18049. * @param b The second submesh
  18050. * @returns The result of the comparison
  18051. */
  18052. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  18053. /**
  18054. * Resets the different lists of submeshes to prepare a new frame.
  18055. */
  18056. prepare(): void;
  18057. dispose(): void;
  18058. /**
  18059. * Inserts the submesh in its correct queue depending on its material.
  18060. * @param subMesh The submesh to dispatch
  18061. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18062. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18063. */
  18064. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18065. dispatchSprites(spriteManager: ISpriteManager): void;
  18066. dispatchParticles(particleSystem: IParticleSystem): void;
  18067. private _renderParticles;
  18068. private _renderSprites;
  18069. }
  18070. }
  18071. declare module "babylonjs/Rendering/renderingManager" {
  18072. import { Nullable } from "babylonjs/types";
  18073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18074. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18075. import { SmartArray } from "babylonjs/Misc/smartArray";
  18076. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18077. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18078. import { Material } from "babylonjs/Materials/material";
  18079. import { Scene } from "babylonjs/scene";
  18080. import { Camera } from "babylonjs/Cameras/camera";
  18081. /**
  18082. * Interface describing the different options available in the rendering manager
  18083. * regarding Auto Clear between groups.
  18084. */
  18085. export interface IRenderingManagerAutoClearSetup {
  18086. /**
  18087. * Defines whether or not autoclear is enable.
  18088. */
  18089. autoClear: boolean;
  18090. /**
  18091. * Defines whether or not to autoclear the depth buffer.
  18092. */
  18093. depth: boolean;
  18094. /**
  18095. * Defines whether or not to autoclear the stencil buffer.
  18096. */
  18097. stencil: boolean;
  18098. }
  18099. /**
  18100. * This class is used by the onRenderingGroupObservable
  18101. */
  18102. export class RenderingGroupInfo {
  18103. /**
  18104. * The Scene that being rendered
  18105. */
  18106. scene: Scene;
  18107. /**
  18108. * The camera currently used for the rendering pass
  18109. */
  18110. camera: Nullable<Camera>;
  18111. /**
  18112. * The ID of the renderingGroup being processed
  18113. */
  18114. renderingGroupId: number;
  18115. }
  18116. /**
  18117. * This is the manager responsible of all the rendering for meshes sprites and particles.
  18118. * It is enable to manage the different groups as well as the different necessary sort functions.
  18119. * This should not be used directly aside of the few static configurations
  18120. */
  18121. export class RenderingManager {
  18122. /**
  18123. * The max id used for rendering groups (not included)
  18124. */
  18125. static MAX_RENDERINGGROUPS: number;
  18126. /**
  18127. * The min id used for rendering groups (included)
  18128. */
  18129. static MIN_RENDERINGGROUPS: number;
  18130. /**
  18131. * Used to globally prevent autoclearing scenes.
  18132. */
  18133. static AUTOCLEAR: boolean;
  18134. /**
  18135. * @hidden
  18136. */
  18137. _useSceneAutoClearSetup: boolean;
  18138. private _scene;
  18139. private _renderingGroups;
  18140. private _depthStencilBufferAlreadyCleaned;
  18141. private _autoClearDepthStencil;
  18142. private _customOpaqueSortCompareFn;
  18143. private _customAlphaTestSortCompareFn;
  18144. private _customTransparentSortCompareFn;
  18145. private _renderingGroupInfo;
  18146. /**
  18147. * Instantiates a new rendering group for a particular scene
  18148. * @param scene Defines the scene the groups belongs to
  18149. */
  18150. constructor(scene: Scene);
  18151. private _clearDepthStencilBuffer;
  18152. /**
  18153. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18154. * @hidden
  18155. */
  18156. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18157. /**
  18158. * Resets the different information of the group to prepare a new frame
  18159. * @hidden
  18160. */
  18161. reset(): void;
  18162. /**
  18163. * Dispose and release the group and its associated resources.
  18164. * @hidden
  18165. */
  18166. dispose(): void;
  18167. /**
  18168. * Clear the info related to rendering groups preventing retention points during dispose.
  18169. */
  18170. freeRenderingGroups(): void;
  18171. private _prepareRenderingGroup;
  18172. /**
  18173. * Add a sprite manager to the rendering manager in order to render it this frame.
  18174. * @param spriteManager Define the sprite manager to render
  18175. */
  18176. dispatchSprites(spriteManager: ISpriteManager): void;
  18177. /**
  18178. * Add a particle system to the rendering manager in order to render it this frame.
  18179. * @param particleSystem Define the particle system to render
  18180. */
  18181. dispatchParticles(particleSystem: IParticleSystem): void;
  18182. /**
  18183. * Add a submesh to the manager in order to render it this frame
  18184. * @param subMesh The submesh to dispatch
  18185. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18186. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18187. */
  18188. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18189. /**
  18190. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18191. * This allowed control for front to back rendering or reversly depending of the special needs.
  18192. *
  18193. * @param renderingGroupId The rendering group id corresponding to its index
  18194. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18195. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18196. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18197. */
  18198. 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;
  18199. /**
  18200. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18201. *
  18202. * @param renderingGroupId The rendering group id corresponding to its index
  18203. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18204. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18205. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18206. */
  18207. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18208. /**
  18209. * Gets the current auto clear configuration for one rendering group of the rendering
  18210. * manager.
  18211. * @param index the rendering group index to get the information for
  18212. * @returns The auto clear setup for the requested rendering group
  18213. */
  18214. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18215. }
  18216. }
  18217. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18218. import { Observable } from "babylonjs/Misc/observable";
  18219. import { SmartArray } from "babylonjs/Misc/smartArray";
  18220. import { Nullable } from "babylonjs/types";
  18221. import { Camera } from "babylonjs/Cameras/camera";
  18222. import { Scene } from "babylonjs/scene";
  18223. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18224. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18226. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18227. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18228. import { Texture } from "babylonjs/Materials/Textures/texture";
  18229. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18230. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18231. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18232. import { Engine } from "babylonjs/Engines/engine";
  18233. /**
  18234. * This Helps creating a texture that will be created from a camera in your scene.
  18235. * It is basically a dynamic texture that could be used to create special effects for instance.
  18236. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18237. */
  18238. export class RenderTargetTexture extends Texture {
  18239. isCube: boolean;
  18240. /**
  18241. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18242. */
  18243. static readonly REFRESHRATE_RENDER_ONCE: number;
  18244. /**
  18245. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18246. */
  18247. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18248. /**
  18249. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18250. * the central point of your effect and can save a lot of performances.
  18251. */
  18252. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18253. /**
  18254. * Use this predicate to dynamically define the list of mesh you want to render.
  18255. * If set, the renderList property will be overwritten.
  18256. */
  18257. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18258. private _renderList;
  18259. /**
  18260. * Use this list to define the list of mesh you want to render.
  18261. */
  18262. renderList: Nullable<Array<AbstractMesh>>;
  18263. private _hookArray;
  18264. /**
  18265. * Define if particles should be rendered in your texture.
  18266. */
  18267. renderParticles: boolean;
  18268. /**
  18269. * Define if sprites should be rendered in your texture.
  18270. */
  18271. renderSprites: boolean;
  18272. /**
  18273. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18274. */
  18275. coordinatesMode: number;
  18276. /**
  18277. * Define the camera used to render the texture.
  18278. */
  18279. activeCamera: Nullable<Camera>;
  18280. /**
  18281. * Override the render function of the texture with your own one.
  18282. */
  18283. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18284. /**
  18285. * Define if camera post processes should be use while rendering the texture.
  18286. */
  18287. useCameraPostProcesses: boolean;
  18288. /**
  18289. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18290. */
  18291. ignoreCameraViewport: boolean;
  18292. private _postProcessManager;
  18293. private _postProcesses;
  18294. private _resizeObserver;
  18295. /**
  18296. * An event triggered when the texture is unbind.
  18297. */
  18298. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18299. /**
  18300. * An event triggered when the texture is unbind.
  18301. */
  18302. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18303. private _onAfterUnbindObserver;
  18304. /**
  18305. * Set a after unbind callback in the texture.
  18306. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18307. */
  18308. onAfterUnbind: () => void;
  18309. /**
  18310. * An event triggered before rendering the texture
  18311. */
  18312. onBeforeRenderObservable: Observable<number>;
  18313. private _onBeforeRenderObserver;
  18314. /**
  18315. * Set a before render callback in the texture.
  18316. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18317. */
  18318. onBeforeRender: (faceIndex: number) => void;
  18319. /**
  18320. * An event triggered after rendering the texture
  18321. */
  18322. onAfterRenderObservable: Observable<number>;
  18323. private _onAfterRenderObserver;
  18324. /**
  18325. * Set a after render callback in the texture.
  18326. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18327. */
  18328. onAfterRender: (faceIndex: number) => void;
  18329. /**
  18330. * An event triggered after the texture clear
  18331. */
  18332. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18333. private _onClearObserver;
  18334. /**
  18335. * Set a clear callback in the texture.
  18336. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18337. */
  18338. onClear: (Engine: Engine) => void;
  18339. /**
  18340. * Define the clear color of the Render Target if it should be different from the scene.
  18341. */
  18342. clearColor: Color4;
  18343. protected _size: number | {
  18344. width: number;
  18345. height: number;
  18346. };
  18347. protected _initialSizeParameter: number | {
  18348. width: number;
  18349. height: number;
  18350. } | {
  18351. ratio: number;
  18352. };
  18353. protected _sizeRatio: Nullable<number>;
  18354. /** @hidden */
  18355. _generateMipMaps: boolean;
  18356. protected _renderingManager: RenderingManager;
  18357. /** @hidden */
  18358. _waitingRenderList: string[];
  18359. protected _doNotChangeAspectRatio: boolean;
  18360. protected _currentRefreshId: number;
  18361. protected _refreshRate: number;
  18362. protected _textureMatrix: Matrix;
  18363. protected _samples: number;
  18364. protected _renderTargetOptions: RenderTargetCreationOptions;
  18365. /**
  18366. * Gets render target creation options that were used.
  18367. */
  18368. readonly renderTargetOptions: RenderTargetCreationOptions;
  18369. protected _engine: Engine;
  18370. protected _onRatioRescale(): void;
  18371. /**
  18372. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18373. * It must define where the camera used to render the texture is set
  18374. */
  18375. boundingBoxPosition: Vector3;
  18376. private _boundingBoxSize;
  18377. /**
  18378. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18379. * When defined, the cubemap will switch to local mode
  18380. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18381. * @example https://www.babylonjs-playground.com/#RNASML
  18382. */
  18383. boundingBoxSize: Vector3;
  18384. /**
  18385. * In case the RTT has been created with a depth texture, get the associated
  18386. * depth texture.
  18387. * Otherwise, return null.
  18388. */
  18389. depthStencilTexture: Nullable<InternalTexture>;
  18390. /**
  18391. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18392. * or used a shadow, depth texture...
  18393. * @param name The friendly name of the texture
  18394. * @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)
  18395. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18396. * @param generateMipMaps True if mip maps need to be generated after render.
  18397. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18398. * @param type The type of the buffer in the RTT (int, half float, float...)
  18399. * @param isCube True if a cube texture needs to be created
  18400. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18401. * @param generateDepthBuffer True to generate a depth buffer
  18402. * @param generateStencilBuffer True to generate a stencil buffer
  18403. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18404. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18405. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18406. */
  18407. constructor(name: string, size: number | {
  18408. width: number;
  18409. height: number;
  18410. } | {
  18411. ratio: number;
  18412. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18413. /**
  18414. * Creates a depth stencil texture.
  18415. * This is only available in WebGL 2 or with the depth texture extension available.
  18416. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18417. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18418. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18419. */
  18420. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18421. private _processSizeParameter;
  18422. /**
  18423. * Define the number of samples to use in case of MSAA.
  18424. * It defaults to one meaning no MSAA has been enabled.
  18425. */
  18426. samples: number;
  18427. /**
  18428. * Resets the refresh counter of the texture and start bak from scratch.
  18429. * Could be useful to regenerate the texture if it is setup to render only once.
  18430. */
  18431. resetRefreshCounter(): void;
  18432. /**
  18433. * Define the refresh rate of the texture or the rendering frequency.
  18434. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18435. */
  18436. refreshRate: number;
  18437. /**
  18438. * Adds a post process to the render target rendering passes.
  18439. * @param postProcess define the post process to add
  18440. */
  18441. addPostProcess(postProcess: PostProcess): void;
  18442. /**
  18443. * Clear all the post processes attached to the render target
  18444. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18445. */
  18446. clearPostProcesses(dispose?: boolean): void;
  18447. /**
  18448. * Remove one of the post process from the list of attached post processes to the texture
  18449. * @param postProcess define the post process to remove from the list
  18450. */
  18451. removePostProcess(postProcess: PostProcess): void;
  18452. /** @hidden */
  18453. _shouldRender(): boolean;
  18454. /**
  18455. * Gets the actual render size of the texture.
  18456. * @returns the width of the render size
  18457. */
  18458. getRenderSize(): number;
  18459. /**
  18460. * Gets the actual render width of the texture.
  18461. * @returns the width of the render size
  18462. */
  18463. getRenderWidth(): number;
  18464. /**
  18465. * Gets the actual render height of the texture.
  18466. * @returns the height of the render size
  18467. */
  18468. getRenderHeight(): number;
  18469. /**
  18470. * Get if the texture can be rescaled or not.
  18471. */
  18472. readonly canRescale: boolean;
  18473. /**
  18474. * Resize the texture using a ratio.
  18475. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18476. */
  18477. scale(ratio: number): void;
  18478. /**
  18479. * Get the texture reflection matrix used to rotate/transform the reflection.
  18480. * @returns the reflection matrix
  18481. */
  18482. getReflectionTextureMatrix(): Matrix;
  18483. /**
  18484. * Resize the texture to a new desired size.
  18485. * Be carrefull as it will recreate all the data in the new texture.
  18486. * @param size Define the new size. It can be:
  18487. * - a number for squared texture,
  18488. * - an object containing { width: number, height: number }
  18489. * - or an object containing a ratio { ratio: number }
  18490. */
  18491. resize(size: number | {
  18492. width: number;
  18493. height: number;
  18494. } | {
  18495. ratio: number;
  18496. }): void;
  18497. /**
  18498. * Renders all the objects from the render list into the texture.
  18499. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18500. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18501. */
  18502. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18503. private _bestReflectionRenderTargetDimension;
  18504. /**
  18505. * @hidden
  18506. * @param faceIndex face index to bind to if this is a cubetexture
  18507. */
  18508. _bindFrameBuffer(faceIndex?: number): void;
  18509. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18510. private renderToTarget;
  18511. /**
  18512. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18513. * This allowed control for front to back rendering or reversly depending of the special needs.
  18514. *
  18515. * @param renderingGroupId The rendering group id corresponding to its index
  18516. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18517. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18518. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18519. */
  18520. 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;
  18521. /**
  18522. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18523. *
  18524. * @param renderingGroupId The rendering group id corresponding to its index
  18525. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18526. */
  18527. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18528. /**
  18529. * Clones the texture.
  18530. * @returns the cloned texture
  18531. */
  18532. clone(): RenderTargetTexture;
  18533. /**
  18534. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18535. * @returns The JSON representation of the texture
  18536. */
  18537. serialize(): any;
  18538. /**
  18539. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18540. */
  18541. disposeFramebufferObjects(): void;
  18542. /**
  18543. * Dispose the texture and release its associated resources.
  18544. */
  18545. dispose(): void;
  18546. /** @hidden */
  18547. _rebuild(): void;
  18548. /**
  18549. * Clear the info related to rendering groups preventing retention point in material dispose.
  18550. */
  18551. freeRenderingGroups(): void;
  18552. /**
  18553. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18554. * @returns the view count
  18555. */
  18556. getViewCount(): number;
  18557. }
  18558. }
  18559. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18560. import { Scene } from "babylonjs/scene";
  18561. import { Plane } from "babylonjs/Maths/math";
  18562. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18563. /**
  18564. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18565. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18566. * You can then easily use it as a reflectionTexture on a flat surface.
  18567. * In case the surface is not a plane, please consider relying on reflection probes.
  18568. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18569. */
  18570. export class MirrorTexture extends RenderTargetTexture {
  18571. private scene;
  18572. /**
  18573. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18574. * 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.
  18575. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18576. */
  18577. mirrorPlane: Plane;
  18578. /**
  18579. * Define the blur ratio used to blur the reflection if needed.
  18580. */
  18581. blurRatio: number;
  18582. /**
  18583. * Define the adaptive blur kernel used to blur the reflection if needed.
  18584. * This will autocompute the closest best match for the `blurKernel`
  18585. */
  18586. adaptiveBlurKernel: number;
  18587. /**
  18588. * Define the blur kernel used to blur the reflection if needed.
  18589. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18590. */
  18591. blurKernel: number;
  18592. /**
  18593. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18594. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18595. */
  18596. blurKernelX: number;
  18597. /**
  18598. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18599. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18600. */
  18601. blurKernelY: number;
  18602. private _autoComputeBlurKernel;
  18603. protected _onRatioRescale(): void;
  18604. private _updateGammaSpace;
  18605. private _imageProcessingConfigChangeObserver;
  18606. private _transformMatrix;
  18607. private _mirrorMatrix;
  18608. private _savedViewMatrix;
  18609. private _blurX;
  18610. private _blurY;
  18611. private _adaptiveBlurKernel;
  18612. private _blurKernelX;
  18613. private _blurKernelY;
  18614. private _blurRatio;
  18615. /**
  18616. * Instantiates a Mirror Texture.
  18617. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18618. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18619. * You can then easily use it as a reflectionTexture on a flat surface.
  18620. * In case the surface is not a plane, please consider relying on reflection probes.
  18621. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18622. * @param name
  18623. * @param size
  18624. * @param scene
  18625. * @param generateMipMaps
  18626. * @param type
  18627. * @param samplingMode
  18628. * @param generateDepthBuffer
  18629. */
  18630. constructor(name: string, size: number | {
  18631. width: number;
  18632. height: number;
  18633. } | {
  18634. ratio: number;
  18635. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18636. private _preparePostProcesses;
  18637. /**
  18638. * Clone the mirror texture.
  18639. * @returns the cloned texture
  18640. */
  18641. clone(): MirrorTexture;
  18642. /**
  18643. * Serialize the texture to a JSON representation you could use in Parse later on
  18644. * @returns the serialized JSON representation
  18645. */
  18646. serialize(): any;
  18647. /**
  18648. * Dispose the texture and release its associated resources.
  18649. */
  18650. dispose(): void;
  18651. }
  18652. }
  18653. declare module "babylonjs/Materials/Textures/texture" {
  18654. import { Observable } from "babylonjs/Misc/observable";
  18655. import { Nullable } from "babylonjs/types";
  18656. import { Scene } from "babylonjs/scene";
  18657. import { Matrix } from "babylonjs/Maths/math";
  18658. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18659. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18660. /**
  18661. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18662. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18663. */
  18664. export class Texture extends BaseTexture {
  18665. /** @hidden */
  18666. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18667. /** @hidden */
  18668. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18669. /** @hidden */
  18670. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18671. /** nearest is mag = nearest and min = nearest and mip = linear */
  18672. static readonly NEAREST_SAMPLINGMODE: number;
  18673. /** nearest is mag = nearest and min = nearest and mip = linear */
  18674. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18675. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18676. static readonly BILINEAR_SAMPLINGMODE: number;
  18677. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18678. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18679. /** Trilinear is mag = linear and min = linear and mip = linear */
  18680. static readonly TRILINEAR_SAMPLINGMODE: number;
  18681. /** Trilinear is mag = linear and min = linear and mip = linear */
  18682. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18683. /** mag = nearest and min = nearest and mip = nearest */
  18684. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18685. /** mag = nearest and min = linear and mip = nearest */
  18686. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18687. /** mag = nearest and min = linear and mip = linear */
  18688. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18689. /** mag = nearest and min = linear and mip = none */
  18690. static readonly NEAREST_LINEAR: number;
  18691. /** mag = nearest and min = nearest and mip = none */
  18692. static readonly NEAREST_NEAREST: number;
  18693. /** mag = linear and min = nearest and mip = nearest */
  18694. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18695. /** mag = linear and min = nearest and mip = linear */
  18696. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18697. /** mag = linear and min = linear and mip = none */
  18698. static readonly LINEAR_LINEAR: number;
  18699. /** mag = linear and min = nearest and mip = none */
  18700. static readonly LINEAR_NEAREST: number;
  18701. /** Explicit coordinates mode */
  18702. static readonly EXPLICIT_MODE: number;
  18703. /** Spherical coordinates mode */
  18704. static readonly SPHERICAL_MODE: number;
  18705. /** Planar coordinates mode */
  18706. static readonly PLANAR_MODE: number;
  18707. /** Cubic coordinates mode */
  18708. static readonly CUBIC_MODE: number;
  18709. /** Projection coordinates mode */
  18710. static readonly PROJECTION_MODE: number;
  18711. /** Inverse Cubic coordinates mode */
  18712. static readonly SKYBOX_MODE: number;
  18713. /** Inverse Cubic coordinates mode */
  18714. static readonly INVCUBIC_MODE: number;
  18715. /** Equirectangular coordinates mode */
  18716. static readonly EQUIRECTANGULAR_MODE: number;
  18717. /** Equirectangular Fixed coordinates mode */
  18718. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18719. /** Equirectangular Fixed Mirrored coordinates mode */
  18720. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18721. /** Texture is not repeating outside of 0..1 UVs */
  18722. static readonly CLAMP_ADDRESSMODE: number;
  18723. /** Texture is repeating outside of 0..1 UVs */
  18724. static readonly WRAP_ADDRESSMODE: number;
  18725. /** Texture is repeating and mirrored */
  18726. static readonly MIRROR_ADDRESSMODE: number;
  18727. /**
  18728. * 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
  18729. */
  18730. static UseSerializedUrlIfAny: boolean;
  18731. /**
  18732. * Define the url of the texture.
  18733. */
  18734. url: Nullable<string>;
  18735. /**
  18736. * Define an offset on the texture to offset the u coordinates of the UVs
  18737. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18738. */
  18739. uOffset: number;
  18740. /**
  18741. * Define an offset on the texture to offset the v coordinates of the UVs
  18742. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18743. */
  18744. vOffset: number;
  18745. /**
  18746. * Define an offset on the texture to scale the u coordinates of the UVs
  18747. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18748. */
  18749. uScale: number;
  18750. /**
  18751. * Define an offset on the texture to scale the v coordinates of the UVs
  18752. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18753. */
  18754. vScale: number;
  18755. /**
  18756. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18757. * @see http://doc.babylonjs.com/how_to/more_materials
  18758. */
  18759. uAng: number;
  18760. /**
  18761. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18762. * @see http://doc.babylonjs.com/how_to/more_materials
  18763. */
  18764. vAng: number;
  18765. /**
  18766. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18767. * @see http://doc.babylonjs.com/how_to/more_materials
  18768. */
  18769. wAng: number;
  18770. /**
  18771. * Defines the center of rotation (U)
  18772. */
  18773. uRotationCenter: number;
  18774. /**
  18775. * Defines the center of rotation (V)
  18776. */
  18777. vRotationCenter: number;
  18778. /**
  18779. * Defines the center of rotation (W)
  18780. */
  18781. wRotationCenter: number;
  18782. /**
  18783. * Are mip maps generated for this texture or not.
  18784. */
  18785. readonly noMipmap: boolean;
  18786. /**
  18787. * List of inspectable custom properties (used by the Inspector)
  18788. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18789. */
  18790. inspectableCustomProperties: Nullable<IInspectable[]>;
  18791. private _noMipmap;
  18792. /** @hidden */
  18793. _invertY: boolean;
  18794. private _rowGenerationMatrix;
  18795. private _cachedTextureMatrix;
  18796. private _projectionModeMatrix;
  18797. private _t0;
  18798. private _t1;
  18799. private _t2;
  18800. private _cachedUOffset;
  18801. private _cachedVOffset;
  18802. private _cachedUScale;
  18803. private _cachedVScale;
  18804. private _cachedUAng;
  18805. private _cachedVAng;
  18806. private _cachedWAng;
  18807. private _cachedProjectionMatrixId;
  18808. private _cachedCoordinatesMode;
  18809. /** @hidden */
  18810. protected _initialSamplingMode: number;
  18811. /** @hidden */
  18812. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18813. private _deleteBuffer;
  18814. protected _format: Nullable<number>;
  18815. private _delayedOnLoad;
  18816. private _delayedOnError;
  18817. /**
  18818. * Observable triggered once the texture has been loaded.
  18819. */
  18820. onLoadObservable: Observable<Texture>;
  18821. protected _isBlocking: boolean;
  18822. /**
  18823. * Is the texture preventing material to render while loading.
  18824. * If false, a default texture will be used instead of the loading one during the preparation step.
  18825. */
  18826. isBlocking: boolean;
  18827. /**
  18828. * Get the current sampling mode associated with the texture.
  18829. */
  18830. readonly samplingMode: number;
  18831. /**
  18832. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18833. */
  18834. readonly invertY: boolean;
  18835. /**
  18836. * Instantiates a new texture.
  18837. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18838. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18839. * @param url define the url of the picture to load as a texture
  18840. * @param scene define the scene the texture will belong to
  18841. * @param noMipmap define if the texture will require mip maps or not
  18842. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18843. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18844. * @param onLoad define a callback triggered when the texture has been loaded
  18845. * @param onError define a callback triggered when an error occurred during the loading session
  18846. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18847. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18848. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18849. */
  18850. 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);
  18851. /**
  18852. * Update the url (and optional buffer) of this texture if url was null during construction.
  18853. * @param url the url of the texture
  18854. * @param buffer the buffer of the texture (defaults to null)
  18855. * @param onLoad callback called when the texture is loaded (defaults to null)
  18856. */
  18857. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18858. /**
  18859. * Finish the loading sequence of a texture flagged as delayed load.
  18860. * @hidden
  18861. */
  18862. delayLoad(): void;
  18863. private _prepareRowForTextureGeneration;
  18864. /**
  18865. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18866. * @returns the transform matrix of the texture.
  18867. */
  18868. getTextureMatrix(): Matrix;
  18869. /**
  18870. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18871. * @returns The reflection texture transform
  18872. */
  18873. getReflectionTextureMatrix(): Matrix;
  18874. /**
  18875. * Clones the texture.
  18876. * @returns the cloned texture
  18877. */
  18878. clone(): Texture;
  18879. /**
  18880. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18881. * @returns The JSON representation of the texture
  18882. */
  18883. serialize(): any;
  18884. /**
  18885. * Get the current class name of the texture useful for serialization or dynamic coding.
  18886. * @returns "Texture"
  18887. */
  18888. getClassName(): string;
  18889. /**
  18890. * Dispose the texture and release its associated resources.
  18891. */
  18892. dispose(): void;
  18893. /**
  18894. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18895. * @param parsedTexture Define the JSON representation of the texture
  18896. * @param scene Define the scene the parsed texture should be instantiated in
  18897. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18898. * @returns The parsed texture if successful
  18899. */
  18900. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18901. /**
  18902. * Creates a texture from its base 64 representation.
  18903. * @param data Define the base64 payload without the data: prefix
  18904. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18905. * @param scene Define the scene the texture should belong to
  18906. * @param noMipmap Forces the texture to not create mip map information if true
  18907. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18908. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18909. * @param onLoad define a callback triggered when the texture has been loaded
  18910. * @param onError define a callback triggered when an error occurred during the loading session
  18911. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18912. * @returns the created texture
  18913. */
  18914. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18915. /**
  18916. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18917. * @param data Define the base64 payload without the data: prefix
  18918. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18919. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18920. * @param scene Define the scene the texture should belong to
  18921. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18922. * @param noMipmap Forces the texture to not create mip map information if true
  18923. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18924. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18925. * @param onLoad define a callback triggered when the texture has been loaded
  18926. * @param onError define a callback triggered when an error occurred during the loading session
  18927. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18928. * @returns the created texture
  18929. */
  18930. 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;
  18931. }
  18932. }
  18933. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18934. import { Nullable } from "babylonjs/types";
  18935. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18936. import { Scene } from "babylonjs/scene";
  18937. module "babylonjs/Engines/engine" {
  18938. interface Engine {
  18939. /**
  18940. * Creates a raw texture
  18941. * @param data defines the data to store in the texture
  18942. * @param width defines the width of the texture
  18943. * @param height defines the height of the texture
  18944. * @param format defines the format of the data
  18945. * @param generateMipMaps defines if the engine should generate the mip levels
  18946. * @param invertY defines if data must be stored with Y axis inverted
  18947. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18948. * @param compression defines the compression used (null by default)
  18949. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18950. * @returns the raw texture inside an InternalTexture
  18951. */
  18952. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18953. /**
  18954. * Update a raw texture
  18955. * @param texture defines the texture to update
  18956. * @param data defines the data to store in the texture
  18957. * @param format defines the format of the data
  18958. * @param invertY defines if data must be stored with Y axis inverted
  18959. */
  18960. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18961. /**
  18962. * Update a raw texture
  18963. * @param texture defines the texture to update
  18964. * @param data defines the data to store in the texture
  18965. * @param format defines the format of the data
  18966. * @param invertY defines if data must be stored with Y axis inverted
  18967. * @param compression defines the compression used (null by default)
  18968. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18969. */
  18970. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18971. /**
  18972. * Creates a new raw cube texture
  18973. * @param data defines the array of data to use to create each face
  18974. * @param size defines the size of the textures
  18975. * @param format defines the format of the data
  18976. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18977. * @param generateMipMaps defines if the engine should generate the mip levels
  18978. * @param invertY defines if data must be stored with Y axis inverted
  18979. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18980. * @param compression defines the compression used (null by default)
  18981. * @returns the cube texture as an InternalTexture
  18982. */
  18983. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18984. /**
  18985. * Update a raw cube texture
  18986. * @param texture defines the texture to udpdate
  18987. * @param data defines the data to store
  18988. * @param format defines the data format
  18989. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18990. * @param invertY defines if data must be stored with Y axis inverted
  18991. */
  18992. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18993. /**
  18994. * Update a raw cube texture
  18995. * @param texture defines the texture to udpdate
  18996. * @param data defines the data to store
  18997. * @param format defines the data format
  18998. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18999. * @param invertY defines if data must be stored with Y axis inverted
  19000. * @param compression defines the compression used (null by default)
  19001. */
  19002. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  19003. /**
  19004. * Update a raw cube texture
  19005. * @param texture defines the texture to udpdate
  19006. * @param data defines the data to store
  19007. * @param format defines the data format
  19008. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19009. * @param invertY defines if data must be stored with Y axis inverted
  19010. * @param compression defines the compression used (null by default)
  19011. * @param level defines which level of the texture to update
  19012. */
  19013. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  19014. /**
  19015. * Creates a new raw cube texture from a specified url
  19016. * @param url defines the url where the data is located
  19017. * @param scene defines the current scene
  19018. * @param size defines the size of the textures
  19019. * @param format defines the format of the data
  19020. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19021. * @param noMipmap defines if the engine should avoid generating the mip levels
  19022. * @param callback defines a callback used to extract texture data from loaded data
  19023. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19024. * @param onLoad defines a callback called when texture is loaded
  19025. * @param onError defines a callback called if there is an error
  19026. * @returns the cube texture as an InternalTexture
  19027. */
  19028. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  19029. /**
  19030. * Creates a new raw cube texture from a specified url
  19031. * @param url defines the url where the data is located
  19032. * @param scene defines the current scene
  19033. * @param size defines the size of the textures
  19034. * @param format defines the format of the data
  19035. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19036. * @param noMipmap defines if the engine should avoid generating the mip levels
  19037. * @param callback defines a callback used to extract texture data from loaded data
  19038. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19039. * @param onLoad defines a callback called when texture is loaded
  19040. * @param onError defines a callback called if there is an error
  19041. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19042. * @param invertY defines if data must be stored with Y axis inverted
  19043. * @returns the cube texture as an InternalTexture
  19044. */
  19045. 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;
  19046. /**
  19047. * Creates a new raw 3D texture
  19048. * @param data defines the data used to create the texture
  19049. * @param width defines the width of the texture
  19050. * @param height defines the height of the texture
  19051. * @param depth defines the depth of the texture
  19052. * @param format defines the format of the texture
  19053. * @param generateMipMaps defines if the engine must generate mip levels
  19054. * @param invertY defines if data must be stored with Y axis inverted
  19055. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19056. * @param compression defines the compressed used (can be null)
  19057. * @param textureType defines the compressed used (can be null)
  19058. * @returns a new raw 3D texture (stored in an InternalTexture)
  19059. */
  19060. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  19061. /**
  19062. * Update a raw 3D texture
  19063. * @param texture defines the texture to update
  19064. * @param data defines the data to store
  19065. * @param format defines the data format
  19066. * @param invertY defines if data must be stored with Y axis inverted
  19067. */
  19068. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  19069. /**
  19070. * Update a raw 3D texture
  19071. * @param texture defines the texture to update
  19072. * @param data defines the data to store
  19073. * @param format defines the data format
  19074. * @param invertY defines if data must be stored with Y axis inverted
  19075. * @param compression defines the used compression (can be null)
  19076. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  19077. */
  19078. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  19079. }
  19080. }
  19081. }
  19082. declare module "babylonjs/Materials/Textures/rawTexture" {
  19083. import { Scene } from "babylonjs/scene";
  19084. import { Texture } from "babylonjs/Materials/Textures/texture";
  19085. import "babylonjs/Engines/Extensions/engine.rawTexture";
  19086. /**
  19087. * Raw texture can help creating a texture directly from an array of data.
  19088. * This can be super useful if you either get the data from an uncompressed source or
  19089. * if you wish to create your texture pixel by pixel.
  19090. */
  19091. export class RawTexture extends Texture {
  19092. /**
  19093. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19094. */
  19095. format: number;
  19096. private _engine;
  19097. /**
  19098. * Instantiates a new RawTexture.
  19099. * Raw texture can help creating a texture directly from an array of data.
  19100. * This can be super useful if you either get the data from an uncompressed source or
  19101. * if you wish to create your texture pixel by pixel.
  19102. * @param data define the array of data to use to create the texture
  19103. * @param width define the width of the texture
  19104. * @param height define the height of the texture
  19105. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19106. * @param scene define the scene the texture belongs to
  19107. * @param generateMipMaps define whether mip maps should be generated or not
  19108. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19109. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19110. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19111. */
  19112. constructor(data: ArrayBufferView, width: number, height: number,
  19113. /**
  19114. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19115. */
  19116. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  19117. /**
  19118. * Updates the texture underlying data.
  19119. * @param data Define the new data of the texture
  19120. */
  19121. update(data: ArrayBufferView): void;
  19122. /**
  19123. * Creates a luminance texture from some data.
  19124. * @param data Define the texture data
  19125. * @param width Define the width of the texture
  19126. * @param height Define the height of the texture
  19127. * @param scene Define the scene the texture belongs to
  19128. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19129. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19130. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19131. * @returns the luminance texture
  19132. */
  19133. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19134. /**
  19135. * Creates a luminance alpha texture from some data.
  19136. * @param data Define the texture data
  19137. * @param width Define the width of the texture
  19138. * @param height Define the height of the texture
  19139. * @param scene Define the scene the texture belongs to
  19140. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19141. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19142. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19143. * @returns the luminance alpha texture
  19144. */
  19145. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19146. /**
  19147. * Creates an alpha texture from some data.
  19148. * @param data Define the texture data
  19149. * @param width Define the width of the texture
  19150. * @param height Define the height of the texture
  19151. * @param scene Define the scene the texture belongs to
  19152. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19153. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19154. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19155. * @returns the alpha texture
  19156. */
  19157. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19158. /**
  19159. * Creates a RGB texture from some data.
  19160. * @param data Define the texture data
  19161. * @param width Define the width of the texture
  19162. * @param height Define the height of the texture
  19163. * @param scene Define the scene the texture belongs to
  19164. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19165. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19166. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19167. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19168. * @returns the RGB alpha texture
  19169. */
  19170. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19171. /**
  19172. * Creates a RGBA texture from some data.
  19173. * @param data Define the texture data
  19174. * @param width Define the width of the texture
  19175. * @param height Define the height of the texture
  19176. * @param scene Define the scene the texture belongs to
  19177. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19178. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19179. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19180. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19181. * @returns the RGBA texture
  19182. */
  19183. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19184. /**
  19185. * Creates a R texture from some data.
  19186. * @param data Define the texture data
  19187. * @param width Define the width of the texture
  19188. * @param height Define the height of the texture
  19189. * @param scene Define the scene the texture belongs to
  19190. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19191. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19192. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19193. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19194. * @returns the R texture
  19195. */
  19196. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19197. }
  19198. }
  19199. declare module "babylonjs/Animations/runtimeAnimation" {
  19200. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19201. import { Animatable } from "babylonjs/Animations/animatable";
  19202. import { Scene } from "babylonjs/scene";
  19203. /**
  19204. * Defines a runtime animation
  19205. */
  19206. export class RuntimeAnimation {
  19207. private _events;
  19208. /**
  19209. * The current frame of the runtime animation
  19210. */
  19211. private _currentFrame;
  19212. /**
  19213. * The animation used by the runtime animation
  19214. */
  19215. private _animation;
  19216. /**
  19217. * The target of the runtime animation
  19218. */
  19219. private _target;
  19220. /**
  19221. * The initiating animatable
  19222. */
  19223. private _host;
  19224. /**
  19225. * The original value of the runtime animation
  19226. */
  19227. private _originalValue;
  19228. /**
  19229. * The original blend value of the runtime animation
  19230. */
  19231. private _originalBlendValue;
  19232. /**
  19233. * The offsets cache of the runtime animation
  19234. */
  19235. private _offsetsCache;
  19236. /**
  19237. * The high limits cache of the runtime animation
  19238. */
  19239. private _highLimitsCache;
  19240. /**
  19241. * Specifies if the runtime animation has been stopped
  19242. */
  19243. private _stopped;
  19244. /**
  19245. * The blending factor of the runtime animation
  19246. */
  19247. private _blendingFactor;
  19248. /**
  19249. * The BabylonJS scene
  19250. */
  19251. private _scene;
  19252. /**
  19253. * The current value of the runtime animation
  19254. */
  19255. private _currentValue;
  19256. /** @hidden */
  19257. _animationState: _IAnimationState;
  19258. /**
  19259. * The active target of the runtime animation
  19260. */
  19261. private _activeTargets;
  19262. private _currentActiveTarget;
  19263. private _directTarget;
  19264. /**
  19265. * The target path of the runtime animation
  19266. */
  19267. private _targetPath;
  19268. /**
  19269. * The weight of the runtime animation
  19270. */
  19271. private _weight;
  19272. /**
  19273. * The ratio offset of the runtime animation
  19274. */
  19275. private _ratioOffset;
  19276. /**
  19277. * The previous delay of the runtime animation
  19278. */
  19279. private _previousDelay;
  19280. /**
  19281. * The previous ratio of the runtime animation
  19282. */
  19283. private _previousRatio;
  19284. private _enableBlending;
  19285. private _keys;
  19286. private _minFrame;
  19287. private _maxFrame;
  19288. private _minValue;
  19289. private _maxValue;
  19290. private _targetIsArray;
  19291. /**
  19292. * Gets the current frame of the runtime animation
  19293. */
  19294. readonly currentFrame: number;
  19295. /**
  19296. * Gets the weight of the runtime animation
  19297. */
  19298. readonly weight: number;
  19299. /**
  19300. * Gets the current value of the runtime animation
  19301. */
  19302. readonly currentValue: any;
  19303. /**
  19304. * Gets the target path of the runtime animation
  19305. */
  19306. readonly targetPath: string;
  19307. /**
  19308. * Gets the actual target of the runtime animation
  19309. */
  19310. readonly target: any;
  19311. /** @hidden */
  19312. _onLoop: () => void;
  19313. /**
  19314. * Create a new RuntimeAnimation object
  19315. * @param target defines the target of the animation
  19316. * @param animation defines the source animation object
  19317. * @param scene defines the hosting scene
  19318. * @param host defines the initiating Animatable
  19319. */
  19320. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19321. private _preparePath;
  19322. /**
  19323. * Gets the animation from the runtime animation
  19324. */
  19325. readonly animation: Animation;
  19326. /**
  19327. * Resets the runtime animation to the beginning
  19328. * @param restoreOriginal defines whether to restore the target property to the original value
  19329. */
  19330. reset(restoreOriginal?: boolean): void;
  19331. /**
  19332. * Specifies if the runtime animation is stopped
  19333. * @returns Boolean specifying if the runtime animation is stopped
  19334. */
  19335. isStopped(): boolean;
  19336. /**
  19337. * Disposes of the runtime animation
  19338. */
  19339. dispose(): void;
  19340. /**
  19341. * Apply the interpolated value to the target
  19342. * @param currentValue defines the value computed by the animation
  19343. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19344. */
  19345. setValue(currentValue: any, weight: number): void;
  19346. private _getOriginalValues;
  19347. private _setValue;
  19348. /**
  19349. * Gets the loop pmode of the runtime animation
  19350. * @returns Loop Mode
  19351. */
  19352. private _getCorrectLoopMode;
  19353. /**
  19354. * Move the current animation to a given frame
  19355. * @param frame defines the frame to move to
  19356. */
  19357. goToFrame(frame: number): void;
  19358. /**
  19359. * @hidden Internal use only
  19360. */
  19361. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19362. /**
  19363. * Execute the current animation
  19364. * @param delay defines the delay to add to the current frame
  19365. * @param from defines the lower bound of the animation range
  19366. * @param to defines the upper bound of the animation range
  19367. * @param loop defines if the current animation must loop
  19368. * @param speedRatio defines the current speed ratio
  19369. * @param weight defines the weight of the animation (default is -1 so no weight)
  19370. * @param onLoop optional callback called when animation loops
  19371. * @returns a boolean indicating if the animation is running
  19372. */
  19373. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19374. }
  19375. }
  19376. declare module "babylonjs/Animations/animatable" {
  19377. import { Animation } from "babylonjs/Animations/animation";
  19378. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19379. import { Nullable } from "babylonjs/types";
  19380. import { Observable } from "babylonjs/Misc/observable";
  19381. import { Scene } from "babylonjs/scene";
  19382. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19383. import { Node } from "babylonjs/node";
  19384. /**
  19385. * Class used to store an actual running animation
  19386. */
  19387. export class Animatable {
  19388. /** defines the target object */
  19389. target: any;
  19390. /** defines the starting frame number (default is 0) */
  19391. fromFrame: number;
  19392. /** defines the ending frame number (default is 100) */
  19393. toFrame: number;
  19394. /** defines if the animation must loop (default is false) */
  19395. loopAnimation: boolean;
  19396. /** defines a callback to call when animation ends if it is not looping */
  19397. onAnimationEnd?: (() => void) | null | undefined;
  19398. /** defines a callback to call when animation loops */
  19399. onAnimationLoop?: (() => void) | null | undefined;
  19400. private _localDelayOffset;
  19401. private _pausedDelay;
  19402. private _runtimeAnimations;
  19403. private _paused;
  19404. private _scene;
  19405. private _speedRatio;
  19406. private _weight;
  19407. private _syncRoot;
  19408. /**
  19409. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19410. * This will only apply for non looping animation (default is true)
  19411. */
  19412. disposeOnEnd: boolean;
  19413. /**
  19414. * Gets a boolean indicating if the animation has started
  19415. */
  19416. animationStarted: boolean;
  19417. /**
  19418. * Observer raised when the animation ends
  19419. */
  19420. onAnimationEndObservable: Observable<Animatable>;
  19421. /**
  19422. * Observer raised when the animation loops
  19423. */
  19424. onAnimationLoopObservable: Observable<Animatable>;
  19425. /**
  19426. * Gets the root Animatable used to synchronize and normalize animations
  19427. */
  19428. readonly syncRoot: Nullable<Animatable>;
  19429. /**
  19430. * Gets the current frame of the first RuntimeAnimation
  19431. * Used to synchronize Animatables
  19432. */
  19433. readonly masterFrame: number;
  19434. /**
  19435. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19436. */
  19437. weight: number;
  19438. /**
  19439. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19440. */
  19441. speedRatio: number;
  19442. /**
  19443. * Creates a new Animatable
  19444. * @param scene defines the hosting scene
  19445. * @param target defines the target object
  19446. * @param fromFrame defines the starting frame number (default is 0)
  19447. * @param toFrame defines the ending frame number (default is 100)
  19448. * @param loopAnimation defines if the animation must loop (default is false)
  19449. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19450. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19451. * @param animations defines a group of animation to add to the new Animatable
  19452. * @param onAnimationLoop defines a callback to call when animation loops
  19453. */
  19454. constructor(scene: Scene,
  19455. /** defines the target object */
  19456. target: any,
  19457. /** defines the starting frame number (default is 0) */
  19458. fromFrame?: number,
  19459. /** defines the ending frame number (default is 100) */
  19460. toFrame?: number,
  19461. /** defines if the animation must loop (default is false) */
  19462. loopAnimation?: boolean, speedRatio?: number,
  19463. /** defines a callback to call when animation ends if it is not looping */
  19464. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19465. /** defines a callback to call when animation loops */
  19466. onAnimationLoop?: (() => void) | null | undefined);
  19467. /**
  19468. * Synchronize and normalize current Animatable with a source Animatable
  19469. * This is useful when using animation weights and when animations are not of the same length
  19470. * @param root defines the root Animatable to synchronize with
  19471. * @returns the current Animatable
  19472. */
  19473. syncWith(root: Animatable): Animatable;
  19474. /**
  19475. * Gets the list of runtime animations
  19476. * @returns an array of RuntimeAnimation
  19477. */
  19478. getAnimations(): RuntimeAnimation[];
  19479. /**
  19480. * Adds more animations to the current animatable
  19481. * @param target defines the target of the animations
  19482. * @param animations defines the new animations to add
  19483. */
  19484. appendAnimations(target: any, animations: Animation[]): void;
  19485. /**
  19486. * Gets the source animation for a specific property
  19487. * @param property defines the propertyu to look for
  19488. * @returns null or the source animation for the given property
  19489. */
  19490. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19491. /**
  19492. * Gets the runtime animation for a specific property
  19493. * @param property defines the propertyu to look for
  19494. * @returns null or the runtime animation for the given property
  19495. */
  19496. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19497. /**
  19498. * Resets the animatable to its original state
  19499. */
  19500. reset(): void;
  19501. /**
  19502. * Allows the animatable to blend with current running animations
  19503. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19504. * @param blendingSpeed defines the blending speed to use
  19505. */
  19506. enableBlending(blendingSpeed: number): void;
  19507. /**
  19508. * Disable animation blending
  19509. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19510. */
  19511. disableBlending(): void;
  19512. /**
  19513. * Jump directly to a given frame
  19514. * @param frame defines the frame to jump to
  19515. */
  19516. goToFrame(frame: number): void;
  19517. /**
  19518. * Pause the animation
  19519. */
  19520. pause(): void;
  19521. /**
  19522. * Restart the animation
  19523. */
  19524. restart(): void;
  19525. private _raiseOnAnimationEnd;
  19526. /**
  19527. * Stop and delete the current animation
  19528. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19529. * @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)
  19530. */
  19531. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19532. /**
  19533. * Wait asynchronously for the animation to end
  19534. * @returns a promise which will be fullfilled when the animation ends
  19535. */
  19536. waitAsync(): Promise<Animatable>;
  19537. /** @hidden */
  19538. _animate(delay: number): boolean;
  19539. }
  19540. module "babylonjs/scene" {
  19541. interface Scene {
  19542. /** @hidden */
  19543. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19544. /** @hidden */
  19545. _processLateAnimationBindingsForMatrices(holder: {
  19546. totalWeight: number;
  19547. animations: RuntimeAnimation[];
  19548. originalValue: Matrix;
  19549. }): any;
  19550. /** @hidden */
  19551. _processLateAnimationBindingsForQuaternions(holder: {
  19552. totalWeight: number;
  19553. animations: RuntimeAnimation[];
  19554. originalValue: Quaternion;
  19555. }, refQuaternion: Quaternion): Quaternion;
  19556. /** @hidden */
  19557. _processLateAnimationBindings(): void;
  19558. /**
  19559. * Will start the animation sequence of a given target
  19560. * @param target defines the target
  19561. * @param from defines from which frame should animation start
  19562. * @param to defines until which frame should animation run.
  19563. * @param weight defines the weight to apply to the animation (1.0 by default)
  19564. * @param loop defines if the animation loops
  19565. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19566. * @param onAnimationEnd defines the function to be executed when the animation ends
  19567. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19568. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19569. * @param onAnimationLoop defines the callback to call when an animation loops
  19570. * @returns the animatable object created for this animation
  19571. */
  19572. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19573. /**
  19574. * Will start the animation sequence of a given target
  19575. * @param target defines the target
  19576. * @param from defines from which frame should animation start
  19577. * @param to defines until which frame should animation run.
  19578. * @param loop defines if the animation loops
  19579. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19580. * @param onAnimationEnd defines the function to be executed when the animation ends
  19581. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19582. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19583. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19584. * @param onAnimationLoop defines the callback to call when an animation loops
  19585. * @returns the animatable object created for this animation
  19586. */
  19587. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19588. /**
  19589. * Will start the animation sequence of a given target and its hierarchy
  19590. * @param target defines the target
  19591. * @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.
  19592. * @param from defines from which frame should animation start
  19593. * @param to defines until which frame should animation run.
  19594. * @param loop defines if the animation loops
  19595. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19596. * @param onAnimationEnd defines the function to be executed when the animation ends
  19597. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19598. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19599. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19600. * @param onAnimationLoop defines the callback to call when an animation loops
  19601. * @returns the list of created animatables
  19602. */
  19603. 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[];
  19604. /**
  19605. * Begin a new animation on a given node
  19606. * @param target defines the target where the animation will take place
  19607. * @param animations defines the list of animations to start
  19608. * @param from defines the initial value
  19609. * @param to defines the final value
  19610. * @param loop defines if you want animation to loop (off by default)
  19611. * @param speedRatio defines the speed ratio to apply to all animations
  19612. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19613. * @param onAnimationLoop defines the callback to call when an animation loops
  19614. * @returns the list of created animatables
  19615. */
  19616. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19617. /**
  19618. * Begin a new animation on a given node and its hierarchy
  19619. * @param target defines the root node where the animation will take place
  19620. * @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.
  19621. * @param animations defines the list of animations to start
  19622. * @param from defines the initial value
  19623. * @param to defines the final value
  19624. * @param loop defines if you want animation to loop (off by default)
  19625. * @param speedRatio defines the speed ratio to apply to all animations
  19626. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19627. * @param onAnimationLoop defines the callback to call when an animation loops
  19628. * @returns the list of animatables created for all nodes
  19629. */
  19630. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19631. /**
  19632. * Gets the animatable associated with a specific target
  19633. * @param target defines the target of the animatable
  19634. * @returns the required animatable if found
  19635. */
  19636. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19637. /**
  19638. * Gets all animatables associated with a given target
  19639. * @param target defines the target to look animatables for
  19640. * @returns an array of Animatables
  19641. */
  19642. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19643. /**
  19644. * Stops and removes all animations that have been applied to the scene
  19645. */
  19646. stopAllAnimations(): void;
  19647. }
  19648. }
  19649. module "babylonjs/Bones/bone" {
  19650. interface Bone {
  19651. /**
  19652. * Copy an animation range from another bone
  19653. * @param source defines the source bone
  19654. * @param rangeName defines the range name to copy
  19655. * @param frameOffset defines the frame offset
  19656. * @param rescaleAsRequired defines if rescaling must be applied if required
  19657. * @param skelDimensionsRatio defines the scaling ratio
  19658. * @returns true if operation was successful
  19659. */
  19660. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19661. }
  19662. }
  19663. }
  19664. declare module "babylonjs/Bones/skeleton" {
  19665. import { Bone } from "babylonjs/Bones/bone";
  19666. import { IAnimatable } from "babylonjs/Misc/tools";
  19667. import { Observable } from "babylonjs/Misc/observable";
  19668. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19669. import { Scene } from "babylonjs/scene";
  19670. import { Nullable } from "babylonjs/types";
  19671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19672. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19673. import { Animatable } from "babylonjs/Animations/animatable";
  19674. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19675. import { Animation } from "babylonjs/Animations/animation";
  19676. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19677. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19678. /**
  19679. * Class used to handle skinning animations
  19680. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19681. */
  19682. export class Skeleton implements IAnimatable {
  19683. /** defines the skeleton name */
  19684. name: string;
  19685. /** defines the skeleton Id */
  19686. id: string;
  19687. /**
  19688. * Defines the list of child bones
  19689. */
  19690. bones: Bone[];
  19691. /**
  19692. * Defines an estimate of the dimension of the skeleton at rest
  19693. */
  19694. dimensionsAtRest: Vector3;
  19695. /**
  19696. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19697. */
  19698. needInitialSkinMatrix: boolean;
  19699. /**
  19700. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19701. */
  19702. overrideMesh: Nullable<AbstractMesh>;
  19703. /**
  19704. * Gets the list of animations attached to this skeleton
  19705. */
  19706. animations: Array<Animation>;
  19707. private _scene;
  19708. private _isDirty;
  19709. private _transformMatrices;
  19710. private _transformMatrixTexture;
  19711. private _meshesWithPoseMatrix;
  19712. private _animatables;
  19713. private _identity;
  19714. private _synchronizedWithMesh;
  19715. private _ranges;
  19716. private _lastAbsoluteTransformsUpdateId;
  19717. private _canUseTextureForBones;
  19718. private _uniqueId;
  19719. /** @hidden */
  19720. _numBonesWithLinkedTransformNode: number;
  19721. /**
  19722. * Specifies if the skeleton should be serialized
  19723. */
  19724. doNotSerialize: boolean;
  19725. private _useTextureToStoreBoneMatrices;
  19726. /**
  19727. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19728. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19729. */
  19730. useTextureToStoreBoneMatrices: boolean;
  19731. private _animationPropertiesOverride;
  19732. /**
  19733. * Gets or sets the animation properties override
  19734. */
  19735. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19736. /**
  19737. * List of inspectable custom properties (used by the Inspector)
  19738. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19739. */
  19740. inspectableCustomProperties: IInspectable[];
  19741. /**
  19742. * An observable triggered before computing the skeleton's matrices
  19743. */
  19744. onBeforeComputeObservable: Observable<Skeleton>;
  19745. /**
  19746. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19747. */
  19748. readonly isUsingTextureForMatrices: boolean;
  19749. /**
  19750. * Gets the unique ID of this skeleton
  19751. */
  19752. readonly uniqueId: number;
  19753. /**
  19754. * Creates a new skeleton
  19755. * @param name defines the skeleton name
  19756. * @param id defines the skeleton Id
  19757. * @param scene defines the hosting scene
  19758. */
  19759. constructor(
  19760. /** defines the skeleton name */
  19761. name: string,
  19762. /** defines the skeleton Id */
  19763. id: string, scene: Scene);
  19764. /**
  19765. * Gets the current object class name.
  19766. * @return the class name
  19767. */
  19768. getClassName(): string;
  19769. /**
  19770. * Returns an array containing the root bones
  19771. * @returns an array containing the root bones
  19772. */
  19773. getChildren(): Array<Bone>;
  19774. /**
  19775. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19776. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19777. * @returns a Float32Array containing matrices data
  19778. */
  19779. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19780. /**
  19781. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19782. * @returns a raw texture containing the data
  19783. */
  19784. getTransformMatrixTexture(): Nullable<RawTexture>;
  19785. /**
  19786. * Gets the current hosting scene
  19787. * @returns a scene object
  19788. */
  19789. getScene(): Scene;
  19790. /**
  19791. * Gets a string representing the current skeleton data
  19792. * @param fullDetails defines a boolean indicating if we want a verbose version
  19793. * @returns a string representing the current skeleton data
  19794. */
  19795. toString(fullDetails?: boolean): string;
  19796. /**
  19797. * Get bone's index searching by name
  19798. * @param name defines bone's name to search for
  19799. * @return the indice of the bone. Returns -1 if not found
  19800. */
  19801. getBoneIndexByName(name: string): number;
  19802. /**
  19803. * Creater a new animation range
  19804. * @param name defines the name of the range
  19805. * @param from defines the start key
  19806. * @param to defines the end key
  19807. */
  19808. createAnimationRange(name: string, from: number, to: number): void;
  19809. /**
  19810. * Delete a specific animation range
  19811. * @param name defines the name of the range
  19812. * @param deleteFrames defines if frames must be removed as well
  19813. */
  19814. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19815. /**
  19816. * Gets a specific animation range
  19817. * @param name defines the name of the range to look for
  19818. * @returns the requested animation range or null if not found
  19819. */
  19820. getAnimationRange(name: string): Nullable<AnimationRange>;
  19821. /**
  19822. * Gets the list of all animation ranges defined on this skeleton
  19823. * @returns an array
  19824. */
  19825. getAnimationRanges(): Nullable<AnimationRange>[];
  19826. /**
  19827. * Copy animation range from a source skeleton.
  19828. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19829. * @param source defines the source skeleton
  19830. * @param name defines the name of the range to copy
  19831. * @param rescaleAsRequired defines if rescaling must be applied if required
  19832. * @returns true if operation was successful
  19833. */
  19834. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19835. /**
  19836. * Forces the skeleton to go to rest pose
  19837. */
  19838. returnToRest(): void;
  19839. private _getHighestAnimationFrame;
  19840. /**
  19841. * Begin a specific animation range
  19842. * @param name defines the name of the range to start
  19843. * @param loop defines if looping must be turned on (false by default)
  19844. * @param speedRatio defines the speed ratio to apply (1 by default)
  19845. * @param onAnimationEnd defines a callback which will be called when animation will end
  19846. * @returns a new animatable
  19847. */
  19848. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19849. /** @hidden */
  19850. _markAsDirty(): void;
  19851. /** @hidden */
  19852. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19853. /** @hidden */
  19854. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19855. private _computeTransformMatrices;
  19856. /**
  19857. * Build all resources required to render a skeleton
  19858. */
  19859. prepare(): void;
  19860. /**
  19861. * Gets the list of animatables currently running for this skeleton
  19862. * @returns an array of animatables
  19863. */
  19864. getAnimatables(): IAnimatable[];
  19865. /**
  19866. * Clone the current skeleton
  19867. * @param name defines the name of the new skeleton
  19868. * @param id defines the id of the new skeleton
  19869. * @returns the new skeleton
  19870. */
  19871. clone(name: string, id: string): Skeleton;
  19872. /**
  19873. * Enable animation blending for this skeleton
  19874. * @param blendingSpeed defines the blending speed to apply
  19875. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19876. */
  19877. enableBlending(blendingSpeed?: number): void;
  19878. /**
  19879. * Releases all resources associated with the current skeleton
  19880. */
  19881. dispose(): void;
  19882. /**
  19883. * Serialize the skeleton in a JSON object
  19884. * @returns a JSON object
  19885. */
  19886. serialize(): any;
  19887. /**
  19888. * Creates a new skeleton from serialized data
  19889. * @param parsedSkeleton defines the serialized data
  19890. * @param scene defines the hosting scene
  19891. * @returns a new skeleton
  19892. */
  19893. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19894. /**
  19895. * Compute all node absolute transforms
  19896. * @param forceUpdate defines if computation must be done even if cache is up to date
  19897. */
  19898. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19899. /**
  19900. * Gets the root pose matrix
  19901. * @returns a matrix
  19902. */
  19903. getPoseMatrix(): Nullable<Matrix>;
  19904. /**
  19905. * Sorts bones per internal index
  19906. */
  19907. sortBones(): void;
  19908. private _sortBones;
  19909. }
  19910. }
  19911. declare module "babylonjs/Morph/morphTarget" {
  19912. import { IAnimatable } from "babylonjs/Misc/tools";
  19913. import { Observable } from "babylonjs/Misc/observable";
  19914. import { Nullable, FloatArray } from "babylonjs/types";
  19915. import { Scene } from "babylonjs/scene";
  19916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19917. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19918. /**
  19919. * Defines a target to use with MorphTargetManager
  19920. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19921. */
  19922. export class MorphTarget implements IAnimatable {
  19923. /** defines the name of the target */
  19924. name: string;
  19925. /**
  19926. * Gets or sets the list of animations
  19927. */
  19928. animations: import("babylonjs/Animations/animation").Animation[];
  19929. private _scene;
  19930. private _positions;
  19931. private _normals;
  19932. private _tangents;
  19933. private _influence;
  19934. /**
  19935. * Observable raised when the influence changes
  19936. */
  19937. onInfluenceChanged: Observable<boolean>;
  19938. /** @hidden */
  19939. _onDataLayoutChanged: Observable<void>;
  19940. /**
  19941. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19942. */
  19943. influence: number;
  19944. /**
  19945. * Gets or sets the id of the morph Target
  19946. */
  19947. id: string;
  19948. private _animationPropertiesOverride;
  19949. /**
  19950. * Gets or sets the animation properties override
  19951. */
  19952. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19953. /**
  19954. * Creates a new MorphTarget
  19955. * @param name defines the name of the target
  19956. * @param influence defines the influence to use
  19957. * @param scene defines the scene the morphtarget belongs to
  19958. */
  19959. constructor(
  19960. /** defines the name of the target */
  19961. name: string, influence?: number, scene?: Nullable<Scene>);
  19962. /**
  19963. * Gets a boolean defining if the target contains position data
  19964. */
  19965. readonly hasPositions: boolean;
  19966. /**
  19967. * Gets a boolean defining if the target contains normal data
  19968. */
  19969. readonly hasNormals: boolean;
  19970. /**
  19971. * Gets a boolean defining if the target contains tangent data
  19972. */
  19973. readonly hasTangents: boolean;
  19974. /**
  19975. * Affects position data to this target
  19976. * @param data defines the position data to use
  19977. */
  19978. setPositions(data: Nullable<FloatArray>): void;
  19979. /**
  19980. * Gets the position data stored in this target
  19981. * @returns a FloatArray containing the position data (or null if not present)
  19982. */
  19983. getPositions(): Nullable<FloatArray>;
  19984. /**
  19985. * Affects normal data to this target
  19986. * @param data defines the normal data to use
  19987. */
  19988. setNormals(data: Nullable<FloatArray>): void;
  19989. /**
  19990. * Gets the normal data stored in this target
  19991. * @returns a FloatArray containing the normal data (or null if not present)
  19992. */
  19993. getNormals(): Nullable<FloatArray>;
  19994. /**
  19995. * Affects tangent data to this target
  19996. * @param data defines the tangent data to use
  19997. */
  19998. setTangents(data: Nullable<FloatArray>): void;
  19999. /**
  20000. * Gets the tangent data stored in this target
  20001. * @returns a FloatArray containing the tangent data (or null if not present)
  20002. */
  20003. getTangents(): Nullable<FloatArray>;
  20004. /**
  20005. * Serializes the current target into a Serialization object
  20006. * @returns the serialized object
  20007. */
  20008. serialize(): any;
  20009. /**
  20010. * Returns the string "MorphTarget"
  20011. * @returns "MorphTarget"
  20012. */
  20013. getClassName(): string;
  20014. /**
  20015. * Creates a new target from serialized data
  20016. * @param serializationObject defines the serialized data to use
  20017. * @returns a new MorphTarget
  20018. */
  20019. static Parse(serializationObject: any): MorphTarget;
  20020. /**
  20021. * Creates a MorphTarget from mesh data
  20022. * @param mesh defines the source mesh
  20023. * @param name defines the name to use for the new target
  20024. * @param influence defines the influence to attach to the target
  20025. * @returns a new MorphTarget
  20026. */
  20027. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  20028. }
  20029. }
  20030. declare module "babylonjs/Morph/morphTargetManager" {
  20031. import { Nullable } from "babylonjs/types";
  20032. import { Scene } from "babylonjs/scene";
  20033. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  20034. /**
  20035. * This class is used to deform meshes using morphing between different targets
  20036. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20037. */
  20038. export class MorphTargetManager {
  20039. private _targets;
  20040. private _targetInfluenceChangedObservers;
  20041. private _targetDataLayoutChangedObservers;
  20042. private _activeTargets;
  20043. private _scene;
  20044. private _influences;
  20045. private _supportsNormals;
  20046. private _supportsTangents;
  20047. private _vertexCount;
  20048. private _uniqueId;
  20049. private _tempInfluences;
  20050. /**
  20051. * Creates a new MorphTargetManager
  20052. * @param scene defines the current scene
  20053. */
  20054. constructor(scene?: Nullable<Scene>);
  20055. /**
  20056. * Gets the unique ID of this manager
  20057. */
  20058. readonly uniqueId: number;
  20059. /**
  20060. * Gets the number of vertices handled by this manager
  20061. */
  20062. readonly vertexCount: number;
  20063. /**
  20064. * Gets a boolean indicating if this manager supports morphing of normals
  20065. */
  20066. readonly supportsNormals: boolean;
  20067. /**
  20068. * Gets a boolean indicating if this manager supports morphing of tangents
  20069. */
  20070. readonly supportsTangents: boolean;
  20071. /**
  20072. * Gets the number of targets stored in this manager
  20073. */
  20074. readonly numTargets: number;
  20075. /**
  20076. * Gets the number of influencers (ie. the number of targets with influences > 0)
  20077. */
  20078. readonly numInfluencers: number;
  20079. /**
  20080. * Gets the list of influences (one per target)
  20081. */
  20082. readonly influences: Float32Array;
  20083. /**
  20084. * Gets the active target at specified index. An active target is a target with an influence > 0
  20085. * @param index defines the index to check
  20086. * @returns the requested target
  20087. */
  20088. getActiveTarget(index: number): MorphTarget;
  20089. /**
  20090. * Gets the target at specified index
  20091. * @param index defines the index to check
  20092. * @returns the requested target
  20093. */
  20094. getTarget(index: number): MorphTarget;
  20095. /**
  20096. * Add a new target to this manager
  20097. * @param target defines the target to add
  20098. */
  20099. addTarget(target: MorphTarget): void;
  20100. /**
  20101. * Removes a target from the manager
  20102. * @param target defines the target to remove
  20103. */
  20104. removeTarget(target: MorphTarget): void;
  20105. /**
  20106. * Serializes the current manager into a Serialization object
  20107. * @returns the serialized object
  20108. */
  20109. serialize(): any;
  20110. private _syncActiveTargets;
  20111. /**
  20112. * Syncrhonize the targets with all the meshes using this morph target manager
  20113. */
  20114. synchronize(): void;
  20115. /**
  20116. * Creates a new MorphTargetManager from serialized data
  20117. * @param serializationObject defines the serialized data
  20118. * @param scene defines the hosting scene
  20119. * @returns the new MorphTargetManager
  20120. */
  20121. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  20122. }
  20123. }
  20124. declare module "babylonjs/Meshes/meshLODLevel" {
  20125. import { Mesh } from "babylonjs/Meshes/mesh";
  20126. import { Nullable } from "babylonjs/types";
  20127. /**
  20128. * Class used to represent a specific level of detail of a mesh
  20129. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20130. */
  20131. export class MeshLODLevel {
  20132. /** Defines the distance where this level should star being displayed */
  20133. distance: number;
  20134. /** Defines the mesh to use to render this level */
  20135. mesh: Nullable<Mesh>;
  20136. /**
  20137. * Creates a new LOD level
  20138. * @param distance defines the distance where this level should star being displayed
  20139. * @param mesh defines the mesh to use to render this level
  20140. */
  20141. constructor(
  20142. /** Defines the distance where this level should star being displayed */
  20143. distance: number,
  20144. /** Defines the mesh to use to render this level */
  20145. mesh: Nullable<Mesh>);
  20146. }
  20147. }
  20148. declare module "babylonjs/Meshes/groundMesh" {
  20149. import { Scene } from "babylonjs/scene";
  20150. import { Vector3 } from "babylonjs/Maths/math";
  20151. import { Mesh } from "babylonjs/Meshes/mesh";
  20152. /**
  20153. * Mesh representing the gorund
  20154. */
  20155. export class GroundMesh extends Mesh {
  20156. /** If octree should be generated */
  20157. generateOctree: boolean;
  20158. private _heightQuads;
  20159. /** @hidden */
  20160. _subdivisionsX: number;
  20161. /** @hidden */
  20162. _subdivisionsY: number;
  20163. /** @hidden */
  20164. _width: number;
  20165. /** @hidden */
  20166. _height: number;
  20167. /** @hidden */
  20168. _minX: number;
  20169. /** @hidden */
  20170. _maxX: number;
  20171. /** @hidden */
  20172. _minZ: number;
  20173. /** @hidden */
  20174. _maxZ: number;
  20175. constructor(name: string, scene: Scene);
  20176. /**
  20177. * "GroundMesh"
  20178. * @returns "GroundMesh"
  20179. */
  20180. getClassName(): string;
  20181. /**
  20182. * The minimum of x and y subdivisions
  20183. */
  20184. readonly subdivisions: number;
  20185. /**
  20186. * X subdivisions
  20187. */
  20188. readonly subdivisionsX: number;
  20189. /**
  20190. * Y subdivisions
  20191. */
  20192. readonly subdivisionsY: number;
  20193. /**
  20194. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20195. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20196. * @param chunksCount the number of subdivisions for x and y
  20197. * @param octreeBlocksSize (Default: 32)
  20198. */
  20199. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20200. /**
  20201. * Returns a height (y) value in the Worl system :
  20202. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20203. * @param x x coordinate
  20204. * @param z z coordinate
  20205. * @returns the ground y position if (x, z) are outside the ground surface.
  20206. */
  20207. getHeightAtCoordinates(x: number, z: number): number;
  20208. /**
  20209. * Returns a normalized vector (Vector3) orthogonal to the ground
  20210. * at the ground coordinates (x, z) expressed in the World system.
  20211. * @param x x coordinate
  20212. * @param z z coordinate
  20213. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20214. */
  20215. getNormalAtCoordinates(x: number, z: number): Vector3;
  20216. /**
  20217. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20218. * at the ground coordinates (x, z) expressed in the World system.
  20219. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20220. * @param x x coordinate
  20221. * @param z z coordinate
  20222. * @param ref vector to store the result
  20223. * @returns the GroundMesh.
  20224. */
  20225. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20226. /**
  20227. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20228. * if the ground has been updated.
  20229. * This can be used in the render loop.
  20230. * @returns the GroundMesh.
  20231. */
  20232. updateCoordinateHeights(): GroundMesh;
  20233. private _getFacetAt;
  20234. private _initHeightQuads;
  20235. private _computeHeightQuads;
  20236. /**
  20237. * Serializes this ground mesh
  20238. * @param serializationObject object to write serialization to
  20239. */
  20240. serialize(serializationObject: any): void;
  20241. /**
  20242. * Parses a serialized ground mesh
  20243. * @param parsedMesh the serialized mesh
  20244. * @param scene the scene to create the ground mesh in
  20245. * @returns the created ground mesh
  20246. */
  20247. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20248. }
  20249. }
  20250. declare module "babylonjs/Physics/physicsJoint" {
  20251. import { Vector3 } from "babylonjs/Maths/math";
  20252. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20253. /**
  20254. * Interface for Physics-Joint data
  20255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20256. */
  20257. export interface PhysicsJointData {
  20258. /**
  20259. * The main pivot of the joint
  20260. */
  20261. mainPivot?: Vector3;
  20262. /**
  20263. * The connected pivot of the joint
  20264. */
  20265. connectedPivot?: Vector3;
  20266. /**
  20267. * The main axis of the joint
  20268. */
  20269. mainAxis?: Vector3;
  20270. /**
  20271. * The connected axis of the joint
  20272. */
  20273. connectedAxis?: Vector3;
  20274. /**
  20275. * The collision of the joint
  20276. */
  20277. collision?: boolean;
  20278. /**
  20279. * Native Oimo/Cannon/Energy data
  20280. */
  20281. nativeParams?: any;
  20282. }
  20283. /**
  20284. * This is a holder class for the physics joint created by the physics plugin
  20285. * It holds a set of functions to control the underlying joint
  20286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20287. */
  20288. export class PhysicsJoint {
  20289. /**
  20290. * The type of the physics joint
  20291. */
  20292. type: number;
  20293. /**
  20294. * The data for the physics joint
  20295. */
  20296. jointData: PhysicsJointData;
  20297. private _physicsJoint;
  20298. protected _physicsPlugin: IPhysicsEnginePlugin;
  20299. /**
  20300. * Initializes the physics joint
  20301. * @param type The type of the physics joint
  20302. * @param jointData The data for the physics joint
  20303. */
  20304. constructor(
  20305. /**
  20306. * The type of the physics joint
  20307. */
  20308. type: number,
  20309. /**
  20310. * The data for the physics joint
  20311. */
  20312. jointData: PhysicsJointData);
  20313. /**
  20314. * Gets the physics joint
  20315. */
  20316. /**
  20317. * Sets the physics joint
  20318. */
  20319. physicsJoint: any;
  20320. /**
  20321. * Sets the physics plugin
  20322. */
  20323. physicsPlugin: IPhysicsEnginePlugin;
  20324. /**
  20325. * Execute a function that is physics-plugin specific.
  20326. * @param {Function} func the function that will be executed.
  20327. * It accepts two parameters: the physics world and the physics joint
  20328. */
  20329. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20330. /**
  20331. * Distance-Joint type
  20332. */
  20333. static DistanceJoint: number;
  20334. /**
  20335. * Hinge-Joint type
  20336. */
  20337. static HingeJoint: number;
  20338. /**
  20339. * Ball-and-Socket joint type
  20340. */
  20341. static BallAndSocketJoint: number;
  20342. /**
  20343. * Wheel-Joint type
  20344. */
  20345. static WheelJoint: number;
  20346. /**
  20347. * Slider-Joint type
  20348. */
  20349. static SliderJoint: number;
  20350. /**
  20351. * Prismatic-Joint type
  20352. */
  20353. static PrismaticJoint: number;
  20354. /**
  20355. * Universal-Joint type
  20356. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20357. */
  20358. static UniversalJoint: number;
  20359. /**
  20360. * Hinge-Joint 2 type
  20361. */
  20362. static Hinge2Joint: number;
  20363. /**
  20364. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20365. */
  20366. static PointToPointJoint: number;
  20367. /**
  20368. * Spring-Joint type
  20369. */
  20370. static SpringJoint: number;
  20371. /**
  20372. * Lock-Joint type
  20373. */
  20374. static LockJoint: number;
  20375. }
  20376. /**
  20377. * A class representing a physics distance joint
  20378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20379. */
  20380. export class DistanceJoint extends PhysicsJoint {
  20381. /**
  20382. *
  20383. * @param jointData The data for the Distance-Joint
  20384. */
  20385. constructor(jointData: DistanceJointData);
  20386. /**
  20387. * Update the predefined distance.
  20388. * @param maxDistance The maximum preferred distance
  20389. * @param minDistance The minimum preferred distance
  20390. */
  20391. updateDistance(maxDistance: number, minDistance?: number): void;
  20392. }
  20393. /**
  20394. * Represents a Motor-Enabled Joint
  20395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20396. */
  20397. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20398. /**
  20399. * Initializes the Motor-Enabled Joint
  20400. * @param type The type of the joint
  20401. * @param jointData The physica joint data for the joint
  20402. */
  20403. constructor(type: number, jointData: PhysicsJointData);
  20404. /**
  20405. * Set the motor values.
  20406. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20407. * @param force the force to apply
  20408. * @param maxForce max force for this motor.
  20409. */
  20410. setMotor(force?: number, maxForce?: number): void;
  20411. /**
  20412. * Set the motor's limits.
  20413. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20414. * @param upperLimit The upper limit of the motor
  20415. * @param lowerLimit The lower limit of the motor
  20416. */
  20417. setLimit(upperLimit: number, lowerLimit?: number): void;
  20418. }
  20419. /**
  20420. * This class represents a single physics Hinge-Joint
  20421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20422. */
  20423. export class HingeJoint extends MotorEnabledJoint {
  20424. /**
  20425. * Initializes the Hinge-Joint
  20426. * @param jointData The joint data for the Hinge-Joint
  20427. */
  20428. constructor(jointData: PhysicsJointData);
  20429. /**
  20430. * Set the motor values.
  20431. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20432. * @param {number} force the force to apply
  20433. * @param {number} maxForce max force for this motor.
  20434. */
  20435. setMotor(force?: number, maxForce?: number): void;
  20436. /**
  20437. * Set the motor's limits.
  20438. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20439. * @param upperLimit The upper limit of the motor
  20440. * @param lowerLimit The lower limit of the motor
  20441. */
  20442. setLimit(upperLimit: number, lowerLimit?: number): void;
  20443. }
  20444. /**
  20445. * This class represents a dual hinge physics joint (same as wheel joint)
  20446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20447. */
  20448. export class Hinge2Joint extends MotorEnabledJoint {
  20449. /**
  20450. * Initializes the Hinge2-Joint
  20451. * @param jointData The joint data for the Hinge2-Joint
  20452. */
  20453. constructor(jointData: PhysicsJointData);
  20454. /**
  20455. * Set the motor values.
  20456. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20457. * @param {number} targetSpeed the speed the motor is to reach
  20458. * @param {number} maxForce max force for this motor.
  20459. * @param {motorIndex} the motor's index, 0 or 1.
  20460. */
  20461. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20462. /**
  20463. * Set the motor limits.
  20464. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20465. * @param {number} upperLimit the upper limit
  20466. * @param {number} lowerLimit lower limit
  20467. * @param {motorIndex} the motor's index, 0 or 1.
  20468. */
  20469. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20470. }
  20471. /**
  20472. * Interface for a motor enabled joint
  20473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20474. */
  20475. export interface IMotorEnabledJoint {
  20476. /**
  20477. * Physics joint
  20478. */
  20479. physicsJoint: any;
  20480. /**
  20481. * Sets the motor of the motor-enabled joint
  20482. * @param force The force of the motor
  20483. * @param maxForce The maximum force of the motor
  20484. * @param motorIndex The index of the motor
  20485. */
  20486. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20487. /**
  20488. * Sets the limit of the motor
  20489. * @param upperLimit The upper limit of the motor
  20490. * @param lowerLimit The lower limit of the motor
  20491. * @param motorIndex The index of the motor
  20492. */
  20493. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20494. }
  20495. /**
  20496. * Joint data for a Distance-Joint
  20497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20498. */
  20499. export interface DistanceJointData extends PhysicsJointData {
  20500. /**
  20501. * Max distance the 2 joint objects can be apart
  20502. */
  20503. maxDistance: number;
  20504. }
  20505. /**
  20506. * Joint data from a spring joint
  20507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20508. */
  20509. export interface SpringJointData extends PhysicsJointData {
  20510. /**
  20511. * Length of the spring
  20512. */
  20513. length: number;
  20514. /**
  20515. * Stiffness of the spring
  20516. */
  20517. stiffness: number;
  20518. /**
  20519. * Damping of the spring
  20520. */
  20521. damping: number;
  20522. /** this callback will be called when applying the force to the impostors. */
  20523. forceApplicationCallback: () => void;
  20524. }
  20525. }
  20526. declare module "babylonjs/Physics/physicsRaycastResult" {
  20527. import { Vector3 } from "babylonjs/Maths/math";
  20528. /**
  20529. * Holds the data for the raycast result
  20530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20531. */
  20532. export class PhysicsRaycastResult {
  20533. private _hasHit;
  20534. private _hitDistance;
  20535. private _hitNormalWorld;
  20536. private _hitPointWorld;
  20537. private _rayFromWorld;
  20538. private _rayToWorld;
  20539. /**
  20540. * Gets if there was a hit
  20541. */
  20542. readonly hasHit: boolean;
  20543. /**
  20544. * Gets the distance from the hit
  20545. */
  20546. readonly hitDistance: number;
  20547. /**
  20548. * Gets the hit normal/direction in the world
  20549. */
  20550. readonly hitNormalWorld: Vector3;
  20551. /**
  20552. * Gets the hit point in the world
  20553. */
  20554. readonly hitPointWorld: Vector3;
  20555. /**
  20556. * Gets the ray "start point" of the ray in the world
  20557. */
  20558. readonly rayFromWorld: Vector3;
  20559. /**
  20560. * Gets the ray "end point" of the ray in the world
  20561. */
  20562. readonly rayToWorld: Vector3;
  20563. /**
  20564. * Sets the hit data (normal & point in world space)
  20565. * @param hitNormalWorld defines the normal in world space
  20566. * @param hitPointWorld defines the point in world space
  20567. */
  20568. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20569. /**
  20570. * Sets the distance from the start point to the hit point
  20571. * @param distance
  20572. */
  20573. setHitDistance(distance: number): void;
  20574. /**
  20575. * Calculates the distance manually
  20576. */
  20577. calculateHitDistance(): void;
  20578. /**
  20579. * Resets all the values to default
  20580. * @param from The from point on world space
  20581. * @param to The to point on world space
  20582. */
  20583. reset(from?: Vector3, to?: Vector3): void;
  20584. }
  20585. /**
  20586. * Interface for the size containing width and height
  20587. */
  20588. interface IXYZ {
  20589. /**
  20590. * X
  20591. */
  20592. x: number;
  20593. /**
  20594. * Y
  20595. */
  20596. y: number;
  20597. /**
  20598. * Z
  20599. */
  20600. z: number;
  20601. }
  20602. }
  20603. declare module "babylonjs/Physics/IPhysicsEngine" {
  20604. import { Nullable } from "babylonjs/types";
  20605. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20607. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20608. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20609. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20610. /**
  20611. * Interface used to describe a physics joint
  20612. */
  20613. export interface PhysicsImpostorJoint {
  20614. /** Defines the main impostor to which the joint is linked */
  20615. mainImpostor: PhysicsImpostor;
  20616. /** Defines the impostor that is connected to the main impostor using this joint */
  20617. connectedImpostor: PhysicsImpostor;
  20618. /** Defines the joint itself */
  20619. joint: PhysicsJoint;
  20620. }
  20621. /** @hidden */
  20622. export interface IPhysicsEnginePlugin {
  20623. world: any;
  20624. name: string;
  20625. setGravity(gravity: Vector3): void;
  20626. setTimeStep(timeStep: number): void;
  20627. getTimeStep(): number;
  20628. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20629. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20630. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20631. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20632. removePhysicsBody(impostor: PhysicsImpostor): void;
  20633. generateJoint(joint: PhysicsImpostorJoint): void;
  20634. removeJoint(joint: PhysicsImpostorJoint): void;
  20635. isSupported(): boolean;
  20636. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20637. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20638. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20639. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20640. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20641. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20642. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20643. getBodyMass(impostor: PhysicsImpostor): number;
  20644. getBodyFriction(impostor: PhysicsImpostor): number;
  20645. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20646. getBodyRestitution(impostor: PhysicsImpostor): number;
  20647. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20648. getBodyPressure?(impostor: PhysicsImpostor): number;
  20649. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20650. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20651. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20652. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20653. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20654. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20655. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20656. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20657. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20658. sleepBody(impostor: PhysicsImpostor): void;
  20659. wakeUpBody(impostor: PhysicsImpostor): void;
  20660. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20661. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20662. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20663. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20664. getRadius(impostor: PhysicsImpostor): number;
  20665. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20666. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20667. dispose(): void;
  20668. }
  20669. /**
  20670. * Interface used to define a physics engine
  20671. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20672. */
  20673. export interface IPhysicsEngine {
  20674. /**
  20675. * Gets the gravity vector used by the simulation
  20676. */
  20677. gravity: Vector3;
  20678. /**
  20679. * Sets the gravity vector used by the simulation
  20680. * @param gravity defines the gravity vector to use
  20681. */
  20682. setGravity(gravity: Vector3): void;
  20683. /**
  20684. * Set the time step of the physics engine.
  20685. * Default is 1/60.
  20686. * To slow it down, enter 1/600 for example.
  20687. * To speed it up, 1/30
  20688. * @param newTimeStep the new timestep to apply to this world.
  20689. */
  20690. setTimeStep(newTimeStep: number): void;
  20691. /**
  20692. * Get the time step of the physics engine.
  20693. * @returns the current time step
  20694. */
  20695. getTimeStep(): number;
  20696. /**
  20697. * Release all resources
  20698. */
  20699. dispose(): void;
  20700. /**
  20701. * Gets the name of the current physics plugin
  20702. * @returns the name of the plugin
  20703. */
  20704. getPhysicsPluginName(): string;
  20705. /**
  20706. * Adding a new impostor for the impostor tracking.
  20707. * This will be done by the impostor itself.
  20708. * @param impostor the impostor to add
  20709. */
  20710. addImpostor(impostor: PhysicsImpostor): void;
  20711. /**
  20712. * Remove an impostor from the engine.
  20713. * This impostor and its mesh will not longer be updated by the physics engine.
  20714. * @param impostor the impostor to remove
  20715. */
  20716. removeImpostor(impostor: PhysicsImpostor): void;
  20717. /**
  20718. * Add a joint to the physics engine
  20719. * @param mainImpostor defines the main impostor to which the joint is added.
  20720. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20721. * @param joint defines the joint that will connect both impostors.
  20722. */
  20723. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20724. /**
  20725. * Removes a joint from the simulation
  20726. * @param mainImpostor defines the impostor used with the joint
  20727. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20728. * @param joint defines the joint to remove
  20729. */
  20730. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20731. /**
  20732. * Gets the current plugin used to run the simulation
  20733. * @returns current plugin
  20734. */
  20735. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20736. /**
  20737. * Gets the list of physic impostors
  20738. * @returns an array of PhysicsImpostor
  20739. */
  20740. getImpostors(): Array<PhysicsImpostor>;
  20741. /**
  20742. * Gets the impostor for a physics enabled object
  20743. * @param object defines the object impersonated by the impostor
  20744. * @returns the PhysicsImpostor or null if not found
  20745. */
  20746. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20747. /**
  20748. * Gets the impostor for a physics body object
  20749. * @param body defines physics body used by the impostor
  20750. * @returns the PhysicsImpostor or null if not found
  20751. */
  20752. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20753. /**
  20754. * Does a raycast in the physics world
  20755. * @param from when should the ray start?
  20756. * @param to when should the ray end?
  20757. * @returns PhysicsRaycastResult
  20758. */
  20759. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20760. /**
  20761. * Called by the scene. No need to call it.
  20762. * @param delta defines the timespam between frames
  20763. */
  20764. _step(delta: number): void;
  20765. }
  20766. }
  20767. declare module "babylonjs/Physics/physicsImpostor" {
  20768. import { Nullable, IndicesArray } from "babylonjs/types";
  20769. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20770. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20772. import { Scene } from "babylonjs/scene";
  20773. import { Bone } from "babylonjs/Bones/bone";
  20774. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20775. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20776. /**
  20777. * The interface for the physics imposter parameters
  20778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20779. */
  20780. export interface PhysicsImpostorParameters {
  20781. /**
  20782. * The mass of the physics imposter
  20783. */
  20784. mass: number;
  20785. /**
  20786. * The friction of the physics imposter
  20787. */
  20788. friction?: number;
  20789. /**
  20790. * The coefficient of restitution of the physics imposter
  20791. */
  20792. restitution?: number;
  20793. /**
  20794. * The native options of the physics imposter
  20795. */
  20796. nativeOptions?: any;
  20797. /**
  20798. * Specifies if the parent should be ignored
  20799. */
  20800. ignoreParent?: boolean;
  20801. /**
  20802. * Specifies if bi-directional transformations should be disabled
  20803. */
  20804. disableBidirectionalTransformation?: boolean;
  20805. /**
  20806. * The pressure inside the physics imposter, soft object only
  20807. */
  20808. pressure?: number;
  20809. /**
  20810. * The stiffness the physics imposter, soft object only
  20811. */
  20812. stiffness?: number;
  20813. /**
  20814. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20815. */
  20816. velocityIterations?: number;
  20817. /**
  20818. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20819. */
  20820. positionIterations?: number;
  20821. /**
  20822. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20823. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20824. * Add to fix multiple points
  20825. */
  20826. fixedPoints?: number;
  20827. /**
  20828. * The collision margin around a soft object
  20829. */
  20830. margin?: number;
  20831. /**
  20832. * The collision margin around a soft object
  20833. */
  20834. damping?: number;
  20835. /**
  20836. * The path for a rope based on an extrusion
  20837. */
  20838. path?: any;
  20839. /**
  20840. * The shape of an extrusion used for a rope based on an extrusion
  20841. */
  20842. shape?: any;
  20843. }
  20844. /**
  20845. * Interface for a physics-enabled object
  20846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20847. */
  20848. export interface IPhysicsEnabledObject {
  20849. /**
  20850. * The position of the physics-enabled object
  20851. */
  20852. position: Vector3;
  20853. /**
  20854. * The rotation of the physics-enabled object
  20855. */
  20856. rotationQuaternion: Nullable<Quaternion>;
  20857. /**
  20858. * The scale of the physics-enabled object
  20859. */
  20860. scaling: Vector3;
  20861. /**
  20862. * The rotation of the physics-enabled object
  20863. */
  20864. rotation?: Vector3;
  20865. /**
  20866. * The parent of the physics-enabled object
  20867. */
  20868. parent?: any;
  20869. /**
  20870. * The bounding info of the physics-enabled object
  20871. * @returns The bounding info of the physics-enabled object
  20872. */
  20873. getBoundingInfo(): BoundingInfo;
  20874. /**
  20875. * Computes the world matrix
  20876. * @param force Specifies if the world matrix should be computed by force
  20877. * @returns A world matrix
  20878. */
  20879. computeWorldMatrix(force: boolean): Matrix;
  20880. /**
  20881. * Gets the world matrix
  20882. * @returns A world matrix
  20883. */
  20884. getWorldMatrix?(): Matrix;
  20885. /**
  20886. * Gets the child meshes
  20887. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20888. * @returns An array of abstract meshes
  20889. */
  20890. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20891. /**
  20892. * Gets the vertex data
  20893. * @param kind The type of vertex data
  20894. * @returns A nullable array of numbers, or a float32 array
  20895. */
  20896. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20897. /**
  20898. * Gets the indices from the mesh
  20899. * @returns A nullable array of index arrays
  20900. */
  20901. getIndices?(): Nullable<IndicesArray>;
  20902. /**
  20903. * Gets the scene from the mesh
  20904. * @returns the indices array or null
  20905. */
  20906. getScene?(): Scene;
  20907. /**
  20908. * Gets the absolute position from the mesh
  20909. * @returns the absolute position
  20910. */
  20911. getAbsolutePosition(): Vector3;
  20912. /**
  20913. * Gets the absolute pivot point from the mesh
  20914. * @returns the absolute pivot point
  20915. */
  20916. getAbsolutePivotPoint(): Vector3;
  20917. /**
  20918. * Rotates the mesh
  20919. * @param axis The axis of rotation
  20920. * @param amount The amount of rotation
  20921. * @param space The space of the rotation
  20922. * @returns The rotation transform node
  20923. */
  20924. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20925. /**
  20926. * Translates the mesh
  20927. * @param axis The axis of translation
  20928. * @param distance The distance of translation
  20929. * @param space The space of the translation
  20930. * @returns The transform node
  20931. */
  20932. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20933. /**
  20934. * Sets the absolute position of the mesh
  20935. * @param absolutePosition The absolute position of the mesh
  20936. * @returns The transform node
  20937. */
  20938. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20939. /**
  20940. * Gets the class name of the mesh
  20941. * @returns The class name
  20942. */
  20943. getClassName(): string;
  20944. }
  20945. /**
  20946. * Represents a physics imposter
  20947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20948. */
  20949. export class PhysicsImpostor {
  20950. /**
  20951. * The physics-enabled object used as the physics imposter
  20952. */
  20953. object: IPhysicsEnabledObject;
  20954. /**
  20955. * The type of the physics imposter
  20956. */
  20957. type: number;
  20958. private _options;
  20959. private _scene?;
  20960. /**
  20961. * The default object size of the imposter
  20962. */
  20963. static DEFAULT_OBJECT_SIZE: Vector3;
  20964. /**
  20965. * The identity quaternion of the imposter
  20966. */
  20967. static IDENTITY_QUATERNION: Quaternion;
  20968. /** @hidden */
  20969. _pluginData: any;
  20970. private _physicsEngine;
  20971. private _physicsBody;
  20972. private _bodyUpdateRequired;
  20973. private _onBeforePhysicsStepCallbacks;
  20974. private _onAfterPhysicsStepCallbacks;
  20975. /** @hidden */
  20976. _onPhysicsCollideCallbacks: Array<{
  20977. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20978. otherImpostors: Array<PhysicsImpostor>;
  20979. }>;
  20980. private _deltaPosition;
  20981. private _deltaRotation;
  20982. private _deltaRotationConjugated;
  20983. /** hidden */
  20984. _isFromLine: boolean;
  20985. private _parent;
  20986. private _isDisposed;
  20987. private static _tmpVecs;
  20988. private static _tmpQuat;
  20989. /**
  20990. * Specifies if the physics imposter is disposed
  20991. */
  20992. readonly isDisposed: boolean;
  20993. /**
  20994. * Gets the mass of the physics imposter
  20995. */
  20996. mass: number;
  20997. /**
  20998. * Gets the coefficient of friction
  20999. */
  21000. /**
  21001. * Sets the coefficient of friction
  21002. */
  21003. friction: number;
  21004. /**
  21005. * Gets the coefficient of restitution
  21006. */
  21007. /**
  21008. * Sets the coefficient of restitution
  21009. */
  21010. restitution: number;
  21011. /**
  21012. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  21013. */
  21014. /**
  21015. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  21016. */
  21017. pressure: number;
  21018. /**
  21019. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21020. */
  21021. /**
  21022. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21023. */
  21024. stiffness: number;
  21025. /**
  21026. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21027. */
  21028. /**
  21029. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21030. */
  21031. velocityIterations: number;
  21032. /**
  21033. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21034. */
  21035. /**
  21036. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21037. */
  21038. positionIterations: number;
  21039. /**
  21040. * The unique id of the physics imposter
  21041. * set by the physics engine when adding this impostor to the array
  21042. */
  21043. uniqueId: number;
  21044. /**
  21045. * @hidden
  21046. */
  21047. soft: boolean;
  21048. /**
  21049. * @hidden
  21050. */
  21051. segments: number;
  21052. private _joints;
  21053. /**
  21054. * Initializes the physics imposter
  21055. * @param object The physics-enabled object used as the physics imposter
  21056. * @param type The type of the physics imposter
  21057. * @param _options The options for the physics imposter
  21058. * @param _scene The Babylon scene
  21059. */
  21060. constructor(
  21061. /**
  21062. * The physics-enabled object used as the physics imposter
  21063. */
  21064. object: IPhysicsEnabledObject,
  21065. /**
  21066. * The type of the physics imposter
  21067. */
  21068. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  21069. /**
  21070. * This function will completly initialize this impostor.
  21071. * It will create a new body - but only if this mesh has no parent.
  21072. * If it has, this impostor will not be used other than to define the impostor
  21073. * of the child mesh.
  21074. * @hidden
  21075. */
  21076. _init(): void;
  21077. private _getPhysicsParent;
  21078. /**
  21079. * Should a new body be generated.
  21080. * @returns boolean specifying if body initialization is required
  21081. */
  21082. isBodyInitRequired(): boolean;
  21083. /**
  21084. * Sets the updated scaling
  21085. * @param updated Specifies if the scaling is updated
  21086. */
  21087. setScalingUpdated(): void;
  21088. /**
  21089. * Force a regeneration of this or the parent's impostor's body.
  21090. * Use under cautious - This will remove all joints already implemented.
  21091. */
  21092. forceUpdate(): void;
  21093. /**
  21094. * Gets the body that holds this impostor. Either its own, or its parent.
  21095. */
  21096. /**
  21097. * Set the physics body. Used mainly by the physics engine/plugin
  21098. */
  21099. physicsBody: any;
  21100. /**
  21101. * Get the parent of the physics imposter
  21102. * @returns Physics imposter or null
  21103. */
  21104. /**
  21105. * Sets the parent of the physics imposter
  21106. */
  21107. parent: Nullable<PhysicsImpostor>;
  21108. /**
  21109. * Resets the update flags
  21110. */
  21111. resetUpdateFlags(): void;
  21112. /**
  21113. * Gets the object extend size
  21114. * @returns the object extend size
  21115. */
  21116. getObjectExtendSize(): Vector3;
  21117. /**
  21118. * Gets the object center
  21119. * @returns The object center
  21120. */
  21121. getObjectCenter(): Vector3;
  21122. /**
  21123. * Get a specific parametes from the options parameter
  21124. * @param paramName The object parameter name
  21125. * @returns The object parameter
  21126. */
  21127. getParam(paramName: string): any;
  21128. /**
  21129. * Sets a specific parameter in the options given to the physics plugin
  21130. * @param paramName The parameter name
  21131. * @param value The value of the parameter
  21132. */
  21133. setParam(paramName: string, value: number): void;
  21134. /**
  21135. * Specifically change the body's mass option. Won't recreate the physics body object
  21136. * @param mass The mass of the physics imposter
  21137. */
  21138. setMass(mass: number): void;
  21139. /**
  21140. * Gets the linear velocity
  21141. * @returns linear velocity or null
  21142. */
  21143. getLinearVelocity(): Nullable<Vector3>;
  21144. /**
  21145. * Sets the linear velocity
  21146. * @param velocity linear velocity or null
  21147. */
  21148. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21149. /**
  21150. * Gets the angular velocity
  21151. * @returns angular velocity or null
  21152. */
  21153. getAngularVelocity(): Nullable<Vector3>;
  21154. /**
  21155. * Sets the angular velocity
  21156. * @param velocity The velocity or null
  21157. */
  21158. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21159. /**
  21160. * Execute a function with the physics plugin native code
  21161. * Provide a function the will have two variables - the world object and the physics body object
  21162. * @param func The function to execute with the physics plugin native code
  21163. */
  21164. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21165. /**
  21166. * Register a function that will be executed before the physics world is stepping forward
  21167. * @param func The function to execute before the physics world is stepped forward
  21168. */
  21169. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21170. /**
  21171. * Unregister a function that will be executed before the physics world is stepping forward
  21172. * @param func The function to execute before the physics world is stepped forward
  21173. */
  21174. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21175. /**
  21176. * Register a function that will be executed after the physics step
  21177. * @param func The function to execute after physics step
  21178. */
  21179. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21180. /**
  21181. * Unregisters a function that will be executed after the physics step
  21182. * @param func The function to execute after physics step
  21183. */
  21184. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21185. /**
  21186. * register a function that will be executed when this impostor collides against a different body
  21187. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21188. * @param func Callback that is executed on collision
  21189. */
  21190. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21191. /**
  21192. * Unregisters the physics imposter on contact
  21193. * @param collideAgainst The physics object to collide against
  21194. * @param func Callback to execute on collision
  21195. */
  21196. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21197. private _tmpQuat;
  21198. private _tmpQuat2;
  21199. /**
  21200. * Get the parent rotation
  21201. * @returns The parent rotation
  21202. */
  21203. getParentsRotation(): Quaternion;
  21204. /**
  21205. * this function is executed by the physics engine.
  21206. */
  21207. beforeStep: () => void;
  21208. /**
  21209. * this function is executed by the physics engine
  21210. */
  21211. afterStep: () => void;
  21212. /**
  21213. * Legacy collision detection event support
  21214. */
  21215. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21216. /**
  21217. * event and body object due to cannon's event-based architecture.
  21218. */
  21219. onCollide: (e: {
  21220. body: any;
  21221. }) => void;
  21222. /**
  21223. * Apply a force
  21224. * @param force The force to apply
  21225. * @param contactPoint The contact point for the force
  21226. * @returns The physics imposter
  21227. */
  21228. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21229. /**
  21230. * Apply an impulse
  21231. * @param force The impulse force
  21232. * @param contactPoint The contact point for the impulse force
  21233. * @returns The physics imposter
  21234. */
  21235. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21236. /**
  21237. * A help function to create a joint
  21238. * @param otherImpostor A physics imposter used to create a joint
  21239. * @param jointType The type of joint
  21240. * @param jointData The data for the joint
  21241. * @returns The physics imposter
  21242. */
  21243. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21244. /**
  21245. * Add a joint to this impostor with a different impostor
  21246. * @param otherImpostor A physics imposter used to add a joint
  21247. * @param joint The joint to add
  21248. * @returns The physics imposter
  21249. */
  21250. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21251. /**
  21252. * Add an anchor to a cloth impostor
  21253. * @param otherImpostor rigid impostor to anchor to
  21254. * @param width ratio across width from 0 to 1
  21255. * @param height ratio up height from 0 to 1
  21256. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21257. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21258. * @returns impostor the soft imposter
  21259. */
  21260. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21261. /**
  21262. * Add a hook to a rope impostor
  21263. * @param otherImpostor rigid impostor to anchor to
  21264. * @param length ratio across rope from 0 to 1
  21265. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21266. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21267. * @returns impostor the rope imposter
  21268. */
  21269. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21270. /**
  21271. * Will keep this body still, in a sleep mode.
  21272. * @returns the physics imposter
  21273. */
  21274. sleep(): PhysicsImpostor;
  21275. /**
  21276. * Wake the body up.
  21277. * @returns The physics imposter
  21278. */
  21279. wakeUp(): PhysicsImpostor;
  21280. /**
  21281. * Clones the physics imposter
  21282. * @param newObject The physics imposter clones to this physics-enabled object
  21283. * @returns A nullable physics imposter
  21284. */
  21285. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21286. /**
  21287. * Disposes the physics imposter
  21288. */
  21289. dispose(): void;
  21290. /**
  21291. * Sets the delta position
  21292. * @param position The delta position amount
  21293. */
  21294. setDeltaPosition(position: Vector3): void;
  21295. /**
  21296. * Sets the delta rotation
  21297. * @param rotation The delta rotation amount
  21298. */
  21299. setDeltaRotation(rotation: Quaternion): void;
  21300. /**
  21301. * Gets the box size of the physics imposter and stores the result in the input parameter
  21302. * @param result Stores the box size
  21303. * @returns The physics imposter
  21304. */
  21305. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21306. /**
  21307. * Gets the radius of the physics imposter
  21308. * @returns Radius of the physics imposter
  21309. */
  21310. getRadius(): number;
  21311. /**
  21312. * Sync a bone with this impostor
  21313. * @param bone The bone to sync to the impostor.
  21314. * @param boneMesh The mesh that the bone is influencing.
  21315. * @param jointPivot The pivot of the joint / bone in local space.
  21316. * @param distToJoint Optional distance from the impostor to the joint.
  21317. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21318. */
  21319. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21320. /**
  21321. * Sync impostor to a bone
  21322. * @param bone The bone that the impostor will be synced to.
  21323. * @param boneMesh The mesh that the bone is influencing.
  21324. * @param jointPivot The pivot of the joint / bone in local space.
  21325. * @param distToJoint Optional distance from the impostor to the joint.
  21326. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21327. * @param boneAxis Optional vector3 axis the bone is aligned with
  21328. */
  21329. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21330. /**
  21331. * No-Imposter type
  21332. */
  21333. static NoImpostor: number;
  21334. /**
  21335. * Sphere-Imposter type
  21336. */
  21337. static SphereImpostor: number;
  21338. /**
  21339. * Box-Imposter type
  21340. */
  21341. static BoxImpostor: number;
  21342. /**
  21343. * Plane-Imposter type
  21344. */
  21345. static PlaneImpostor: number;
  21346. /**
  21347. * Mesh-imposter type
  21348. */
  21349. static MeshImpostor: number;
  21350. /**
  21351. * Cylinder-Imposter type
  21352. */
  21353. static CylinderImpostor: number;
  21354. /**
  21355. * Particle-Imposter type
  21356. */
  21357. static ParticleImpostor: number;
  21358. /**
  21359. * Heightmap-Imposter type
  21360. */
  21361. static HeightmapImpostor: number;
  21362. /**
  21363. * ConvexHull-Impostor type (Ammo.js plugin only)
  21364. */
  21365. static ConvexHullImpostor: number;
  21366. /**
  21367. * Rope-Imposter type
  21368. */
  21369. static RopeImpostor: number;
  21370. /**
  21371. * Cloth-Imposter type
  21372. */
  21373. static ClothImpostor: number;
  21374. /**
  21375. * Softbody-Imposter type
  21376. */
  21377. static SoftbodyImpostor: number;
  21378. }
  21379. }
  21380. declare module "babylonjs/Meshes/mesh" {
  21381. import { Observable } from "babylonjs/Misc/observable";
  21382. import { IAnimatable } from "babylonjs/Misc/tools";
  21383. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21384. import { Camera } from "babylonjs/Cameras/camera";
  21385. import { Scene } from "babylonjs/scene";
  21386. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21387. import { Engine } from "babylonjs/Engines/engine";
  21388. import { Node } from "babylonjs/node";
  21389. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21390. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21391. import { Buffer } from "babylonjs/Meshes/buffer";
  21392. import { Geometry } from "babylonjs/Meshes/geometry";
  21393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21394. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21395. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21396. import { Effect } from "babylonjs/Materials/effect";
  21397. import { Material } from "babylonjs/Materials/material";
  21398. import { Skeleton } from "babylonjs/Bones/skeleton";
  21399. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21400. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21401. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21402. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21403. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21404. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21405. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21406. /**
  21407. * @hidden
  21408. **/
  21409. export class _CreationDataStorage {
  21410. closePath?: boolean;
  21411. closeArray?: boolean;
  21412. idx: number[];
  21413. dashSize: number;
  21414. gapSize: number;
  21415. path3D: Path3D;
  21416. pathArray: Vector3[][];
  21417. arc: number;
  21418. radius: number;
  21419. cap: number;
  21420. tessellation: number;
  21421. }
  21422. /**
  21423. * @hidden
  21424. **/
  21425. class _InstanceDataStorage {
  21426. visibleInstances: any;
  21427. batchCache: _InstancesBatch;
  21428. instancesBufferSize: number;
  21429. instancesBuffer: Nullable<Buffer>;
  21430. instancesData: Float32Array;
  21431. overridenInstanceCount: number;
  21432. isFrozen: boolean;
  21433. previousBatch: _InstancesBatch;
  21434. hardwareInstancedRendering: boolean;
  21435. sideOrientation: number;
  21436. }
  21437. /**
  21438. * @hidden
  21439. **/
  21440. export class _InstancesBatch {
  21441. mustReturn: boolean;
  21442. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21443. renderSelf: boolean[];
  21444. hardwareInstancedRendering: boolean[];
  21445. }
  21446. /**
  21447. * Class used to represent renderable models
  21448. */
  21449. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21450. /**
  21451. * Mesh side orientation : usually the external or front surface
  21452. */
  21453. static readonly FRONTSIDE: number;
  21454. /**
  21455. * Mesh side orientation : usually the internal or back surface
  21456. */
  21457. static readonly BACKSIDE: number;
  21458. /**
  21459. * Mesh side orientation : both internal and external or front and back surfaces
  21460. */
  21461. static readonly DOUBLESIDE: number;
  21462. /**
  21463. * Mesh side orientation : by default, `FRONTSIDE`
  21464. */
  21465. static readonly DEFAULTSIDE: number;
  21466. /**
  21467. * Mesh cap setting : no cap
  21468. */
  21469. static readonly NO_CAP: number;
  21470. /**
  21471. * Mesh cap setting : one cap at the beginning of the mesh
  21472. */
  21473. static readonly CAP_START: number;
  21474. /**
  21475. * Mesh cap setting : one cap at the end of the mesh
  21476. */
  21477. static readonly CAP_END: number;
  21478. /**
  21479. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21480. */
  21481. static readonly CAP_ALL: number;
  21482. /**
  21483. * Gets the default side orientation.
  21484. * @param orientation the orientation to value to attempt to get
  21485. * @returns the default orientation
  21486. * @hidden
  21487. */
  21488. static _GetDefaultSideOrientation(orientation?: number): number;
  21489. private _onBeforeRenderObservable;
  21490. private _onBeforeBindObservable;
  21491. private _onAfterRenderObservable;
  21492. private _onBeforeDrawObservable;
  21493. /**
  21494. * An event triggered before rendering the mesh
  21495. */
  21496. readonly onBeforeRenderObservable: Observable<Mesh>;
  21497. /**
  21498. * An event triggered before binding the mesh
  21499. */
  21500. readonly onBeforeBindObservable: Observable<Mesh>;
  21501. /**
  21502. * An event triggered after rendering the mesh
  21503. */
  21504. readonly onAfterRenderObservable: Observable<Mesh>;
  21505. /**
  21506. * An event triggered before drawing the mesh
  21507. */
  21508. readonly onBeforeDrawObservable: Observable<Mesh>;
  21509. private _onBeforeDrawObserver;
  21510. /**
  21511. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21512. */
  21513. onBeforeDraw: () => void;
  21514. /**
  21515. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21516. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21517. */
  21518. delayLoadState: number;
  21519. /**
  21520. * Gets the list of instances created from this mesh
  21521. * it is not supposed to be modified manually.
  21522. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21523. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21524. */
  21525. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21526. /**
  21527. * Gets the file containing delay loading data for this mesh
  21528. */
  21529. delayLoadingFile: string;
  21530. /** @hidden */
  21531. _binaryInfo: any;
  21532. private _LODLevels;
  21533. /**
  21534. * User defined function used to change how LOD level selection is done
  21535. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21536. */
  21537. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21538. private _morphTargetManager;
  21539. /**
  21540. * Gets or sets the morph target manager
  21541. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21542. */
  21543. morphTargetManager: Nullable<MorphTargetManager>;
  21544. /** @hidden */
  21545. _creationDataStorage: Nullable<_CreationDataStorage>;
  21546. /** @hidden */
  21547. _geometry: Nullable<Geometry>;
  21548. /** @hidden */
  21549. _delayInfo: Array<string>;
  21550. /** @hidden */
  21551. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21552. /** @hidden */
  21553. _instanceDataStorage: _InstanceDataStorage;
  21554. private _effectiveMaterial;
  21555. /** @hidden */
  21556. _shouldGenerateFlatShading: boolean;
  21557. private _preActivateId;
  21558. /** @hidden */
  21559. _originalBuilderSideOrientation: number;
  21560. /**
  21561. * Use this property to change the original side orientation defined at construction time
  21562. */
  21563. overrideMaterialSideOrientation: Nullable<number>;
  21564. private _areNormalsFrozen;
  21565. private _sourcePositions;
  21566. private _sourceNormals;
  21567. private _source;
  21568. private meshMap;
  21569. /**
  21570. * Gets the source mesh (the one used to clone this one from)
  21571. */
  21572. readonly source: Nullable<Mesh>;
  21573. /**
  21574. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21575. */
  21576. isUnIndexed: boolean;
  21577. /**
  21578. * @constructor
  21579. * @param name The value used by scene.getMeshByName() to do a lookup.
  21580. * @param scene The scene to add this mesh to.
  21581. * @param parent The parent of this mesh, if it has one
  21582. * @param source An optional Mesh from which geometry is shared, cloned.
  21583. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21584. * When false, achieved by calling a clone(), also passing False.
  21585. * This will make creation of children, recursive.
  21586. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21587. */
  21588. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21589. /**
  21590. * Gets the class name
  21591. * @returns the string "Mesh".
  21592. */
  21593. getClassName(): string;
  21594. /** @hidden */
  21595. readonly _isMesh: boolean;
  21596. /**
  21597. * Returns a description of this mesh
  21598. * @param fullDetails define if full details about this mesh must be used
  21599. * @returns a descriptive string representing this mesh
  21600. */
  21601. toString(fullDetails?: boolean): string;
  21602. /** @hidden */
  21603. _unBindEffect(): void;
  21604. /**
  21605. * Gets a boolean indicating if this mesh has LOD
  21606. */
  21607. readonly hasLODLevels: boolean;
  21608. /**
  21609. * Gets the list of MeshLODLevel associated with the current mesh
  21610. * @returns an array of MeshLODLevel
  21611. */
  21612. getLODLevels(): MeshLODLevel[];
  21613. private _sortLODLevels;
  21614. /**
  21615. * Add a mesh as LOD level triggered at the given distance.
  21616. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21617. * @param distance The distance from the center of the object to show this level
  21618. * @param mesh The mesh to be added as LOD level (can be null)
  21619. * @return This mesh (for chaining)
  21620. */
  21621. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21622. /**
  21623. * Returns the LOD level mesh at the passed distance or null if not found.
  21624. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21625. * @param distance The distance from the center of the object to show this level
  21626. * @returns a Mesh or `null`
  21627. */
  21628. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21629. /**
  21630. * Remove a mesh from the LOD array
  21631. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21632. * @param mesh defines the mesh to be removed
  21633. * @return This mesh (for chaining)
  21634. */
  21635. removeLODLevel(mesh: Mesh): Mesh;
  21636. /**
  21637. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21638. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21639. * @param camera defines the camera to use to compute distance
  21640. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21641. * @return This mesh (for chaining)
  21642. */
  21643. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21644. /**
  21645. * Gets the mesh internal Geometry object
  21646. */
  21647. readonly geometry: Nullable<Geometry>;
  21648. /**
  21649. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21650. * @returns the total number of vertices
  21651. */
  21652. getTotalVertices(): number;
  21653. /**
  21654. * Returns the content of an associated vertex buffer
  21655. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21656. * - VertexBuffer.PositionKind
  21657. * - VertexBuffer.UVKind
  21658. * - VertexBuffer.UV2Kind
  21659. * - VertexBuffer.UV3Kind
  21660. * - VertexBuffer.UV4Kind
  21661. * - VertexBuffer.UV5Kind
  21662. * - VertexBuffer.UV6Kind
  21663. * - VertexBuffer.ColorKind
  21664. * - VertexBuffer.MatricesIndicesKind
  21665. * - VertexBuffer.MatricesIndicesExtraKind
  21666. * - VertexBuffer.MatricesWeightsKind
  21667. * - VertexBuffer.MatricesWeightsExtraKind
  21668. * @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
  21669. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21670. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21671. */
  21672. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21673. /**
  21674. * Returns the mesh VertexBuffer object from the requested `kind`
  21675. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21676. * - VertexBuffer.PositionKind
  21677. * - VertexBuffer.UVKind
  21678. * - VertexBuffer.UV2Kind
  21679. * - VertexBuffer.UV3Kind
  21680. * - VertexBuffer.UV4Kind
  21681. * - VertexBuffer.UV5Kind
  21682. * - VertexBuffer.UV6Kind
  21683. * - VertexBuffer.ColorKind
  21684. * - VertexBuffer.MatricesIndicesKind
  21685. * - VertexBuffer.MatricesIndicesExtraKind
  21686. * - VertexBuffer.MatricesWeightsKind
  21687. * - VertexBuffer.MatricesWeightsExtraKind
  21688. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21689. */
  21690. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21691. /**
  21692. * Tests if a specific vertex buffer is associated with this mesh
  21693. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21694. * - VertexBuffer.PositionKind
  21695. * - VertexBuffer.UVKind
  21696. * - VertexBuffer.UV2Kind
  21697. * - VertexBuffer.UV3Kind
  21698. * - VertexBuffer.UV4Kind
  21699. * - VertexBuffer.UV5Kind
  21700. * - VertexBuffer.UV6Kind
  21701. * - VertexBuffer.ColorKind
  21702. * - VertexBuffer.MatricesIndicesKind
  21703. * - VertexBuffer.MatricesIndicesExtraKind
  21704. * - VertexBuffer.MatricesWeightsKind
  21705. * - VertexBuffer.MatricesWeightsExtraKind
  21706. * @returns a boolean
  21707. */
  21708. isVerticesDataPresent(kind: string): boolean;
  21709. /**
  21710. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21711. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21712. * - VertexBuffer.PositionKind
  21713. * - VertexBuffer.UVKind
  21714. * - VertexBuffer.UV2Kind
  21715. * - VertexBuffer.UV3Kind
  21716. * - VertexBuffer.UV4Kind
  21717. * - VertexBuffer.UV5Kind
  21718. * - VertexBuffer.UV6Kind
  21719. * - VertexBuffer.ColorKind
  21720. * - VertexBuffer.MatricesIndicesKind
  21721. * - VertexBuffer.MatricesIndicesExtraKind
  21722. * - VertexBuffer.MatricesWeightsKind
  21723. * - VertexBuffer.MatricesWeightsExtraKind
  21724. * @returns a boolean
  21725. */
  21726. isVertexBufferUpdatable(kind: string): boolean;
  21727. /**
  21728. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21729. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21730. * - VertexBuffer.PositionKind
  21731. * - VertexBuffer.UVKind
  21732. * - VertexBuffer.UV2Kind
  21733. * - VertexBuffer.UV3Kind
  21734. * - VertexBuffer.UV4Kind
  21735. * - VertexBuffer.UV5Kind
  21736. * - VertexBuffer.UV6Kind
  21737. * - VertexBuffer.ColorKind
  21738. * - VertexBuffer.MatricesIndicesKind
  21739. * - VertexBuffer.MatricesIndicesExtraKind
  21740. * - VertexBuffer.MatricesWeightsKind
  21741. * - VertexBuffer.MatricesWeightsExtraKind
  21742. * @returns an array of strings
  21743. */
  21744. getVerticesDataKinds(): string[];
  21745. /**
  21746. * Returns a positive integer : the total number of indices in this mesh geometry.
  21747. * @returns the numner of indices or zero if the mesh has no geometry.
  21748. */
  21749. getTotalIndices(): number;
  21750. /**
  21751. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21752. * @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.
  21753. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21754. * @returns the indices array or an empty array if the mesh has no geometry
  21755. */
  21756. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21757. readonly isBlocked: boolean;
  21758. /**
  21759. * Determine if the current mesh is ready to be rendered
  21760. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21761. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21762. * @returns true if all associated assets are ready (material, textures, shaders)
  21763. */
  21764. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21765. /**
  21766. * 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.
  21767. */
  21768. readonly areNormalsFrozen: boolean;
  21769. /**
  21770. * 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.
  21771. * @returns the current mesh
  21772. */
  21773. freezeNormals(): Mesh;
  21774. /**
  21775. * 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
  21776. * @returns the current mesh
  21777. */
  21778. unfreezeNormals(): Mesh;
  21779. /**
  21780. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21781. */
  21782. overridenInstanceCount: number;
  21783. /** @hidden */
  21784. _preActivate(): Mesh;
  21785. /** @hidden */
  21786. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21787. /** @hidden */
  21788. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21789. /**
  21790. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21791. * This means the mesh underlying bounding box and sphere are recomputed.
  21792. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21793. * @returns the current mesh
  21794. */
  21795. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21796. /** @hidden */
  21797. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21798. /**
  21799. * This function will subdivide the mesh into multiple submeshes
  21800. * @param count defines the expected number of submeshes
  21801. */
  21802. subdivide(count: number): void;
  21803. /**
  21804. * Copy a FloatArray into a specific associated vertex buffer
  21805. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21806. * - VertexBuffer.PositionKind
  21807. * - VertexBuffer.UVKind
  21808. * - VertexBuffer.UV2Kind
  21809. * - VertexBuffer.UV3Kind
  21810. * - VertexBuffer.UV4Kind
  21811. * - VertexBuffer.UV5Kind
  21812. * - VertexBuffer.UV6Kind
  21813. * - VertexBuffer.ColorKind
  21814. * - VertexBuffer.MatricesIndicesKind
  21815. * - VertexBuffer.MatricesIndicesExtraKind
  21816. * - VertexBuffer.MatricesWeightsKind
  21817. * - VertexBuffer.MatricesWeightsExtraKind
  21818. * @param data defines the data source
  21819. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21820. * @param stride defines the data stride size (can be null)
  21821. * @returns the current mesh
  21822. */
  21823. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21824. /**
  21825. * Flags an associated vertex buffer as updatable
  21826. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21827. * - VertexBuffer.PositionKind
  21828. * - VertexBuffer.UVKind
  21829. * - VertexBuffer.UV2Kind
  21830. * - VertexBuffer.UV3Kind
  21831. * - VertexBuffer.UV4Kind
  21832. * - VertexBuffer.UV5Kind
  21833. * - VertexBuffer.UV6Kind
  21834. * - VertexBuffer.ColorKind
  21835. * - VertexBuffer.MatricesIndicesKind
  21836. * - VertexBuffer.MatricesIndicesExtraKind
  21837. * - VertexBuffer.MatricesWeightsKind
  21838. * - VertexBuffer.MatricesWeightsExtraKind
  21839. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21840. */
  21841. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21842. /**
  21843. * Sets the mesh global Vertex Buffer
  21844. * @param buffer defines the buffer to use
  21845. * @returns the current mesh
  21846. */
  21847. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21848. /**
  21849. * Update a specific associated vertex buffer
  21850. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21851. * - VertexBuffer.PositionKind
  21852. * - VertexBuffer.UVKind
  21853. * - VertexBuffer.UV2Kind
  21854. * - VertexBuffer.UV3Kind
  21855. * - VertexBuffer.UV4Kind
  21856. * - VertexBuffer.UV5Kind
  21857. * - VertexBuffer.UV6Kind
  21858. * - VertexBuffer.ColorKind
  21859. * - VertexBuffer.MatricesIndicesKind
  21860. * - VertexBuffer.MatricesIndicesExtraKind
  21861. * - VertexBuffer.MatricesWeightsKind
  21862. * - VertexBuffer.MatricesWeightsExtraKind
  21863. * @param data defines the data source
  21864. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21865. * @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)
  21866. * @returns the current mesh
  21867. */
  21868. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21869. /**
  21870. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21871. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21872. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21873. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21874. * @returns the current mesh
  21875. */
  21876. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21877. /**
  21878. * Creates a un-shared specific occurence of the geometry for the mesh.
  21879. * @returns the current mesh
  21880. */
  21881. makeGeometryUnique(): Mesh;
  21882. /**
  21883. * Set the index buffer of this mesh
  21884. * @param indices defines the source data
  21885. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21886. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21887. * @returns the current mesh
  21888. */
  21889. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21890. /**
  21891. * Update the current index buffer
  21892. * @param indices defines the source data
  21893. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21894. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  21895. * @returns the current mesh
  21896. */
  21897. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21898. /**
  21899. * Invert the geometry to move from a right handed system to a left handed one.
  21900. * @returns the current mesh
  21901. */
  21902. toLeftHanded(): Mesh;
  21903. /** @hidden */
  21904. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21905. /** @hidden */
  21906. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21907. /**
  21908. * Registers for this mesh a javascript function called just before the rendering process
  21909. * @param func defines the function to call before rendering this mesh
  21910. * @returns the current mesh
  21911. */
  21912. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21913. /**
  21914. * Disposes a previously registered javascript function called before the rendering
  21915. * @param func defines the function to remove
  21916. * @returns the current mesh
  21917. */
  21918. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21919. /**
  21920. * Registers for this mesh a javascript function called just after the rendering is complete
  21921. * @param func defines the function to call after rendering this mesh
  21922. * @returns the current mesh
  21923. */
  21924. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21925. /**
  21926. * Disposes a previously registered javascript function called after the rendering.
  21927. * @param func defines the function to remove
  21928. * @returns the current mesh
  21929. */
  21930. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21931. /** @hidden */
  21932. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21933. /** @hidden */
  21934. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21935. /** @hidden */
  21936. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21937. /** @hidden */
  21938. _freeze(): void;
  21939. /** @hidden */
  21940. _unFreeze(): void;
  21941. /**
  21942. * 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
  21943. * @param subMesh defines the subMesh to render
  21944. * @param enableAlphaMode defines if alpha mode can be changed
  21945. * @returns the current mesh
  21946. */
  21947. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21948. private _onBeforeDraw;
  21949. /**
  21950. * Renormalize the mesh and patch it up if there are no weights
  21951. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21952. * However in the case of zero weights then we set just a single influence to 1.
  21953. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21954. */
  21955. cleanMatrixWeights(): void;
  21956. private normalizeSkinFourWeights;
  21957. private normalizeSkinWeightsAndExtra;
  21958. /**
  21959. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21960. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21961. * the user know there was an issue with importing the mesh
  21962. * @returns a validation object with skinned, valid and report string
  21963. */
  21964. validateSkinning(): {
  21965. skinned: boolean;
  21966. valid: boolean;
  21967. report: string;
  21968. };
  21969. /** @hidden */
  21970. _checkDelayState(): Mesh;
  21971. private _queueLoad;
  21972. /**
  21973. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21974. * A mesh is in the frustum if its bounding box intersects the frustum
  21975. * @param frustumPlanes defines the frustum to test
  21976. * @returns true if the mesh is in the frustum planes
  21977. */
  21978. isInFrustum(frustumPlanes: Plane[]): boolean;
  21979. /**
  21980. * Sets the mesh material by the material or multiMaterial `id` property
  21981. * @param id is a string identifying the material or the multiMaterial
  21982. * @returns the current mesh
  21983. */
  21984. setMaterialByID(id: string): Mesh;
  21985. /**
  21986. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21987. * @returns an array of IAnimatable
  21988. */
  21989. getAnimatables(): IAnimatable[];
  21990. /**
  21991. * Modifies the mesh geometry according to the passed transformation matrix.
  21992. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21993. * The mesh normals are modified using the same transformation.
  21994. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21995. * @param transform defines the transform matrix to use
  21996. * @see http://doc.babylonjs.com/resources/baking_transformations
  21997. * @returns the current mesh
  21998. */
  21999. bakeTransformIntoVertices(transform: Matrix): Mesh;
  22000. /**
  22001. * Modifies the mesh geometry according to its own current World Matrix.
  22002. * The mesh World Matrix is then reset.
  22003. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  22004. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22005. * @see http://doc.babylonjs.com/resources/baking_transformations
  22006. * @returns the current mesh
  22007. */
  22008. bakeCurrentTransformIntoVertices(): Mesh;
  22009. /** @hidden */
  22010. readonly _positions: Nullable<Vector3[]>;
  22011. /** @hidden */
  22012. _resetPointsArrayCache(): Mesh;
  22013. /** @hidden */
  22014. _generatePointsArray(): boolean;
  22015. /**
  22016. * Returns a new Mesh object generated from the current mesh properties.
  22017. * This method must not get confused with createInstance()
  22018. * @param name is a string, the name given to the new mesh
  22019. * @param newParent can be any Node object (default `null`)
  22020. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  22021. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  22022. * @returns a new mesh
  22023. */
  22024. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22025. /**
  22026. * Releases resources associated with this mesh.
  22027. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22028. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22029. */
  22030. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22031. /**
  22032. * Modifies the mesh geometry according to a displacement map.
  22033. * 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.
  22034. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22035. * @param url is a string, the URL from the image file is to be downloaded.
  22036. * @param minHeight is the lower limit of the displacement.
  22037. * @param maxHeight is the upper limit of the displacement.
  22038. * @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.
  22039. * @param uvOffset is an optional vector2 used to offset UV.
  22040. * @param uvScale is an optional vector2 used to scale UV.
  22041. * @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.
  22042. * @returns the Mesh.
  22043. */
  22044. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22045. /**
  22046. * Modifies the mesh geometry according to a displacementMap buffer.
  22047. * 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.
  22048. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22049. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22050. * @param heightMapWidth is the width of the buffer image.
  22051. * @param heightMapHeight is the height of the buffer image.
  22052. * @param minHeight is the lower limit of the displacement.
  22053. * @param maxHeight is the upper limit of the displacement.
  22054. * @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.
  22055. * @param uvOffset is an optional vector2 used to offset UV.
  22056. * @param uvScale is an optional vector2 used to scale UV.
  22057. * @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.
  22058. * @returns the Mesh.
  22059. */
  22060. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22061. /**
  22062. * Modify the mesh to get a flat shading rendering.
  22063. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22064. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22065. * @returns current mesh
  22066. */
  22067. convertToFlatShadedMesh(): Mesh;
  22068. /**
  22069. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22070. * In other words, more vertices, no more indices and a single bigger VBO.
  22071. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22072. * @returns current mesh
  22073. */
  22074. convertToUnIndexedMesh(): Mesh;
  22075. /**
  22076. * Inverses facet orientations.
  22077. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22078. * @param flipNormals will also inverts the normals
  22079. * @returns current mesh
  22080. */
  22081. flipFaces(flipNormals?: boolean): Mesh;
  22082. /**
  22083. * Increase the number of facets and hence vertices in a mesh
  22084. * Vertex normals are interpolated from existing vertex normals
  22085. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22086. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  22087. */
  22088. increaseVertices(numberPerEdge: number): void;
  22089. /**
  22090. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  22091. * This will undo any application of covertToFlatShadedMesh
  22092. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22093. */
  22094. forceSharedVertices(): void;
  22095. /** @hidden */
  22096. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  22097. /** @hidden */
  22098. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  22099. /**
  22100. * Creates a new InstancedMesh object from the mesh model.
  22101. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22102. * @param name defines the name of the new instance
  22103. * @returns a new InstancedMesh
  22104. */
  22105. createInstance(name: string): InstancedMesh;
  22106. /**
  22107. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22108. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22109. * @returns the current mesh
  22110. */
  22111. synchronizeInstances(): Mesh;
  22112. /**
  22113. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22114. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22115. * This should be used together with the simplification to avoid disappearing triangles.
  22116. * @param successCallback an optional success callback to be called after the optimization finished.
  22117. * @returns the current mesh
  22118. */
  22119. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22120. /**
  22121. * Serialize current mesh
  22122. * @param serializationObject defines the object which will receive the serialization data
  22123. */
  22124. serialize(serializationObject: any): void;
  22125. /** @hidden */
  22126. _syncGeometryWithMorphTargetManager(): void;
  22127. /** @hidden */
  22128. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22129. /**
  22130. * Returns a new Mesh object parsed from the source provided.
  22131. * @param parsedMesh is the source
  22132. * @param scene defines the hosting scene
  22133. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22134. * @returns a new Mesh
  22135. */
  22136. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22137. /**
  22138. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22139. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22140. * @param name defines the name of the mesh to create
  22141. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22142. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22143. * @param closePath creates a seam between the first and the last points of each path of the path array
  22144. * @param offset is taken in account only if the `pathArray` is containing a single path
  22145. * @param scene defines the hosting scene
  22146. * @param updatable defines if the mesh must be flagged as updatable
  22147. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22148. * @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)
  22149. * @returns a new Mesh
  22150. */
  22151. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22152. /**
  22153. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22154. * @param name defines the name of the mesh to create
  22155. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22156. * @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
  22157. * @param scene defines the hosting scene
  22158. * @param updatable defines if the mesh must be flagged as updatable
  22159. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22160. * @returns a new Mesh
  22161. */
  22162. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22163. /**
  22164. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22165. * @param name defines the name of the mesh to create
  22166. * @param size sets the size (float) of each box side (default 1)
  22167. * @param scene defines the hosting scene
  22168. * @param updatable defines if the mesh must be flagged as updatable
  22169. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22170. * @returns a new Mesh
  22171. */
  22172. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22173. /**
  22174. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22175. * @param name defines the name of the mesh to create
  22176. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22177. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22178. * @param scene defines the hosting scene
  22179. * @param updatable defines if the mesh must be flagged as updatable
  22180. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22181. * @returns a new Mesh
  22182. */
  22183. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22184. /**
  22185. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22186. * @param name defines the name of the mesh to create
  22187. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22188. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22189. * @param scene defines the hosting scene
  22190. * @returns a new Mesh
  22191. */
  22192. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22193. /**
  22194. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22195. * @param name defines the name of the mesh to create
  22196. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22197. * @param diameterTop set the top cap diameter (floats, default 1)
  22198. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22199. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22200. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22201. * @param scene defines the hosting scene
  22202. * @param updatable defines if the mesh must be flagged as updatable
  22203. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22204. * @returns a new Mesh
  22205. */
  22206. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22207. /**
  22208. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22209. * @param name defines the name of the mesh to create
  22210. * @param diameter sets the diameter size (float) of the torus (default 1)
  22211. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22212. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22213. * @param scene defines the hosting scene
  22214. * @param updatable defines if the mesh must be flagged as updatable
  22215. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22216. * @returns a new Mesh
  22217. */
  22218. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22219. /**
  22220. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22221. * @param name defines the name of the mesh to create
  22222. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22223. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22224. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22225. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22226. * @param p the number of windings on X axis (positive integers, default 2)
  22227. * @param q the number of windings on Y axis (positive integers, default 3)
  22228. * @param scene defines the hosting scene
  22229. * @param updatable defines if the mesh must be flagged as updatable
  22230. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22231. * @returns a new Mesh
  22232. */
  22233. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22234. /**
  22235. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22236. * @param name defines the name of the mesh to create
  22237. * @param points is an array successive Vector3
  22238. * @param scene defines the hosting scene
  22239. * @param updatable defines if the mesh must be flagged as updatable
  22240. * @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).
  22241. * @returns a new Mesh
  22242. */
  22243. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22244. /**
  22245. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22246. * @param name defines the name of the mesh to create
  22247. * @param points is an array successive Vector3
  22248. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22249. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22250. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22251. * @param scene defines the hosting scene
  22252. * @param updatable defines if the mesh must be flagged as updatable
  22253. * @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)
  22254. * @returns a new Mesh
  22255. */
  22256. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22257. /**
  22258. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22259. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22260. * 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.
  22261. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22262. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22263. * Remember you can only change the shape positions, not their number when updating a polygon.
  22264. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22265. * @param name defines the name of the mesh to create
  22266. * @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
  22267. * @param scene defines the hosting scene
  22268. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22269. * @param updatable defines if the mesh must be flagged as updatable
  22270. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22271. * @param earcutInjection can be used to inject your own earcut reference
  22272. * @returns a new Mesh
  22273. */
  22274. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22275. /**
  22276. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22277. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22278. * @param name defines the name of the mesh to create
  22279. * @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
  22280. * @param depth defines the height of extrusion
  22281. * @param scene defines the hosting scene
  22282. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22283. * @param updatable defines if the mesh must be flagged as updatable
  22284. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22285. * @param earcutInjection can be used to inject your own earcut reference
  22286. * @returns a new Mesh
  22287. */
  22288. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22289. /**
  22290. * Creates an extruded shape mesh.
  22291. * 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
  22292. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22293. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22294. * @param name defines the name of the mesh to create
  22295. * @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
  22296. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22297. * @param scale is the value to scale the shape
  22298. * @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
  22299. * @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
  22300. * @param scene defines the hosting scene
  22301. * @param updatable defines if the mesh must be flagged as updatable
  22302. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22303. * @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)
  22304. * @returns a new Mesh
  22305. */
  22306. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22307. /**
  22308. * Creates an custom extruded shape mesh.
  22309. * The custom extrusion is a parametric shape.
  22310. * It has no predefined shape. Its final shape will depend on the input parameters.
  22311. * Please consider using the same method from the MeshBuilder class instead
  22312. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22313. * @param name defines the name of the mesh to create
  22314. * @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
  22315. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22316. * @param scaleFunction is a custom Javascript function called on each path point
  22317. * @param rotationFunction is a custom Javascript function called on each path point
  22318. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22319. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22320. * @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
  22321. * @param scene defines the hosting scene
  22322. * @param updatable defines if the mesh must be flagged as updatable
  22323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22324. * @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)
  22325. * @returns a new Mesh
  22326. */
  22327. 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;
  22328. /**
  22329. * Creates lathe mesh.
  22330. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22331. * Please consider using the same method from the MeshBuilder class instead
  22332. * @param name defines the name of the mesh to create
  22333. * @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
  22334. * @param radius is the radius value of the lathe
  22335. * @param tessellation is the side number of the lathe.
  22336. * @param scene defines the hosting scene
  22337. * @param updatable defines if the mesh must be flagged as updatable
  22338. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22339. * @returns a new Mesh
  22340. */
  22341. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22342. /**
  22343. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22344. * @param name defines the name of the mesh to create
  22345. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22346. * @param scene defines the hosting scene
  22347. * @param updatable defines if the mesh must be flagged as updatable
  22348. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22349. * @returns a new Mesh
  22350. */
  22351. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22352. /**
  22353. * Creates a ground mesh.
  22354. * Please consider using the same method from the MeshBuilder class instead
  22355. * @param name defines the name of the mesh to create
  22356. * @param width set the width of the ground
  22357. * @param height set the height of the ground
  22358. * @param subdivisions sets the number of subdivisions per side
  22359. * @param scene defines the hosting scene
  22360. * @param updatable defines if the mesh must be flagged as updatable
  22361. * @returns a new Mesh
  22362. */
  22363. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22364. /**
  22365. * Creates a tiled ground mesh.
  22366. * Please consider using the same method from the MeshBuilder class instead
  22367. * @param name defines the name of the mesh to create
  22368. * @param xmin set the ground minimum X coordinate
  22369. * @param zmin set the ground minimum Y coordinate
  22370. * @param xmax set the ground maximum X coordinate
  22371. * @param zmax set the ground maximum Z coordinate
  22372. * @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
  22373. * @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
  22374. * @param scene defines the hosting scene
  22375. * @param updatable defines if the mesh must be flagged as updatable
  22376. * @returns a new Mesh
  22377. */
  22378. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22379. w: number;
  22380. h: number;
  22381. }, precision: {
  22382. w: number;
  22383. h: number;
  22384. }, scene: Scene, updatable?: boolean): Mesh;
  22385. /**
  22386. * Creates a ground mesh from a height map.
  22387. * Please consider using the same method from the MeshBuilder class instead
  22388. * @see http://doc.babylonjs.com/babylon101/height_map
  22389. * @param name defines the name of the mesh to create
  22390. * @param url sets the URL of the height map image resource
  22391. * @param width set the ground width size
  22392. * @param height set the ground height size
  22393. * @param subdivisions sets the number of subdivision per side
  22394. * @param minHeight is the minimum altitude on the ground
  22395. * @param maxHeight is the maximum altitude on the ground
  22396. * @param scene defines the hosting scene
  22397. * @param updatable defines if the mesh must be flagged as updatable
  22398. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22399. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22400. * @returns a new Mesh
  22401. */
  22402. 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;
  22403. /**
  22404. * Creates a tube mesh.
  22405. * The tube is a parametric shape.
  22406. * It has no predefined shape. Its final shape will depend on the input parameters.
  22407. * Please consider using the same method from the MeshBuilder class instead
  22408. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22409. * @param name defines the name of the mesh to create
  22410. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22411. * @param radius sets the tube radius size
  22412. * @param tessellation is the number of sides on the tubular surface
  22413. * @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
  22414. * @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
  22415. * @param scene defines the hosting scene
  22416. * @param updatable defines if the mesh must be flagged as updatable
  22417. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22418. * @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)
  22419. * @returns a new Mesh
  22420. */
  22421. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22422. (i: number, distance: number): number;
  22423. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22424. /**
  22425. * Creates a polyhedron mesh.
  22426. * Please consider using the same method from the MeshBuilder class instead.
  22427. * * 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
  22428. * * The parameter `size` (positive float, default 1) sets the polygon size
  22429. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22430. * * 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`
  22431. * * 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
  22432. * * 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)`)
  22433. * * 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
  22434. * * 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
  22435. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22436. * * If you create a double-sided mesh, you can choose what parts of 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
  22437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22438. * @param name defines the name of the mesh to create
  22439. * @param options defines the options used to create the mesh
  22440. * @param scene defines the hosting scene
  22441. * @returns a new Mesh
  22442. */
  22443. static CreatePolyhedron(name: string, options: {
  22444. type?: number;
  22445. size?: number;
  22446. sizeX?: number;
  22447. sizeY?: number;
  22448. sizeZ?: number;
  22449. custom?: any;
  22450. faceUV?: Vector4[];
  22451. faceColors?: Color4[];
  22452. updatable?: boolean;
  22453. sideOrientation?: number;
  22454. }, scene: Scene): Mesh;
  22455. /**
  22456. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22457. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22458. * * 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`)
  22459. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22460. * * 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
  22461. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22462. * * If you create a double-sided mesh, you can choose what parts of 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
  22463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22464. * @param name defines the name of the mesh
  22465. * @param options defines the options used to create the mesh
  22466. * @param scene defines the hosting scene
  22467. * @returns a new Mesh
  22468. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22469. */
  22470. static CreateIcoSphere(name: string, options: {
  22471. radius?: number;
  22472. flat?: boolean;
  22473. subdivisions?: number;
  22474. sideOrientation?: number;
  22475. updatable?: boolean;
  22476. }, scene: Scene): Mesh;
  22477. /**
  22478. * Creates a decal mesh.
  22479. * Please consider using the same method from the MeshBuilder class instead.
  22480. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22481. * @param name defines the name of the mesh
  22482. * @param sourceMesh defines the mesh receiving the decal
  22483. * @param position sets the position of the decal in world coordinates
  22484. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22485. * @param size sets the decal scaling
  22486. * @param angle sets the angle to rotate the decal
  22487. * @returns a new Mesh
  22488. */
  22489. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22490. /**
  22491. * Prepare internal position array for software CPU skinning
  22492. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22493. */
  22494. setPositionsForCPUSkinning(): Float32Array;
  22495. /**
  22496. * Prepare internal normal array for software CPU skinning
  22497. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22498. */
  22499. setNormalsForCPUSkinning(): Float32Array;
  22500. /**
  22501. * Updates the vertex buffer by applying transformation from the bones
  22502. * @param skeleton defines the skeleton to apply to current mesh
  22503. * @returns the current mesh
  22504. */
  22505. applySkeleton(skeleton: Skeleton): Mesh;
  22506. /**
  22507. * 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
  22508. * @param meshes defines the list of meshes to scan
  22509. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22510. */
  22511. static MinMax(meshes: AbstractMesh[]): {
  22512. min: Vector3;
  22513. max: Vector3;
  22514. };
  22515. /**
  22516. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22517. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22518. * @returns a vector3
  22519. */
  22520. static Center(meshesOrMinMaxVector: {
  22521. min: Vector3;
  22522. max: Vector3;
  22523. } | AbstractMesh[]): Vector3;
  22524. /**
  22525. * Merge the array of meshes into a single mesh for performance reasons.
  22526. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22527. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22528. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22529. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22530. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22531. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22532. * @returns a new mesh
  22533. */
  22534. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22535. /** @hidden */
  22536. addInstance(instance: InstancedMesh): void;
  22537. /** @hidden */
  22538. removeInstance(instance: InstancedMesh): void;
  22539. }
  22540. }
  22541. declare module "babylonjs/Materials/material" {
  22542. import { IAnimatable } from "babylonjs/Misc/tools";
  22543. import { SmartArray } from "babylonjs/Misc/smartArray";
  22544. import { Observable } from "babylonjs/Misc/observable";
  22545. import { Nullable } from "babylonjs/types";
  22546. import { Scene } from "babylonjs/scene";
  22547. import { Matrix } from "babylonjs/Maths/math";
  22548. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22550. import { Mesh } from "babylonjs/Meshes/mesh";
  22551. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22552. import { Effect } from "babylonjs/Materials/effect";
  22553. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22554. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22555. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22556. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22557. import { Animation } from "babylonjs/Animations/animation";
  22558. /**
  22559. * Base class for the main features of a material in Babylon.js
  22560. */
  22561. export class Material implements IAnimatable {
  22562. /**
  22563. * Returns the triangle fill mode
  22564. */
  22565. static readonly TriangleFillMode: number;
  22566. /**
  22567. * Returns the wireframe mode
  22568. */
  22569. static readonly WireFrameFillMode: number;
  22570. /**
  22571. * Returns the point fill mode
  22572. */
  22573. static readonly PointFillMode: number;
  22574. /**
  22575. * Returns the point list draw mode
  22576. */
  22577. static readonly PointListDrawMode: number;
  22578. /**
  22579. * Returns the line list draw mode
  22580. */
  22581. static readonly LineListDrawMode: number;
  22582. /**
  22583. * Returns the line loop draw mode
  22584. */
  22585. static readonly LineLoopDrawMode: number;
  22586. /**
  22587. * Returns the line strip draw mode
  22588. */
  22589. static readonly LineStripDrawMode: number;
  22590. /**
  22591. * Returns the triangle strip draw mode
  22592. */
  22593. static readonly TriangleStripDrawMode: number;
  22594. /**
  22595. * Returns the triangle fan draw mode
  22596. */
  22597. static readonly TriangleFanDrawMode: number;
  22598. /**
  22599. * Stores the clock-wise side orientation
  22600. */
  22601. static readonly ClockWiseSideOrientation: number;
  22602. /**
  22603. * Stores the counter clock-wise side orientation
  22604. */
  22605. static readonly CounterClockWiseSideOrientation: number;
  22606. /**
  22607. * The dirty texture flag value
  22608. */
  22609. static readonly TextureDirtyFlag: number;
  22610. /**
  22611. * The dirty light flag value
  22612. */
  22613. static readonly LightDirtyFlag: number;
  22614. /**
  22615. * The dirty fresnel flag value
  22616. */
  22617. static readonly FresnelDirtyFlag: number;
  22618. /**
  22619. * The dirty attribute flag value
  22620. */
  22621. static readonly AttributesDirtyFlag: number;
  22622. /**
  22623. * The dirty misc flag value
  22624. */
  22625. static readonly MiscDirtyFlag: number;
  22626. /**
  22627. * The all dirty flag value
  22628. */
  22629. static readonly AllDirtyFlag: number;
  22630. /**
  22631. * The ID of the material
  22632. */
  22633. id: string;
  22634. /**
  22635. * Gets or sets the unique id of the material
  22636. */
  22637. uniqueId: number;
  22638. /**
  22639. * The name of the material
  22640. */
  22641. name: string;
  22642. /**
  22643. * Gets or sets user defined metadata
  22644. */
  22645. metadata: any;
  22646. /**
  22647. * For internal use only. Please do not use.
  22648. */
  22649. reservedDataStore: any;
  22650. /**
  22651. * Specifies if the ready state should be checked on each call
  22652. */
  22653. checkReadyOnEveryCall: boolean;
  22654. /**
  22655. * Specifies if the ready state should be checked once
  22656. */
  22657. checkReadyOnlyOnce: boolean;
  22658. /**
  22659. * The state of the material
  22660. */
  22661. state: string;
  22662. /**
  22663. * The alpha value of the material
  22664. */
  22665. protected _alpha: number;
  22666. /**
  22667. * List of inspectable custom properties (used by the Inspector)
  22668. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22669. */
  22670. inspectableCustomProperties: IInspectable[];
  22671. /**
  22672. * Sets the alpha value of the material
  22673. */
  22674. /**
  22675. * Gets the alpha value of the material
  22676. */
  22677. alpha: number;
  22678. /**
  22679. * Specifies if back face culling is enabled
  22680. */
  22681. protected _backFaceCulling: boolean;
  22682. /**
  22683. * Sets the back-face culling state
  22684. */
  22685. /**
  22686. * Gets the back-face culling state
  22687. */
  22688. backFaceCulling: boolean;
  22689. /**
  22690. * Stores the value for side orientation
  22691. */
  22692. sideOrientation: number;
  22693. /**
  22694. * Callback triggered when the material is compiled
  22695. */
  22696. onCompiled: Nullable<(effect: Effect) => void>;
  22697. /**
  22698. * Callback triggered when an error occurs
  22699. */
  22700. onError: Nullable<(effect: Effect, errors: string) => void>;
  22701. /**
  22702. * Callback triggered to get the render target textures
  22703. */
  22704. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22705. /**
  22706. * Gets a boolean indicating that current material needs to register RTT
  22707. */
  22708. readonly hasRenderTargetTextures: boolean;
  22709. /**
  22710. * Specifies if the material should be serialized
  22711. */
  22712. doNotSerialize: boolean;
  22713. /**
  22714. * @hidden
  22715. */
  22716. _storeEffectOnSubMeshes: boolean;
  22717. /**
  22718. * Stores the animations for the material
  22719. */
  22720. animations: Nullable<Array<Animation>>;
  22721. /**
  22722. * An event triggered when the material is disposed
  22723. */
  22724. onDisposeObservable: Observable<Material>;
  22725. /**
  22726. * An observer which watches for dispose events
  22727. */
  22728. private _onDisposeObserver;
  22729. private _onUnBindObservable;
  22730. /**
  22731. * Called during a dispose event
  22732. */
  22733. onDispose: () => void;
  22734. private _onBindObservable;
  22735. /**
  22736. * An event triggered when the material is bound
  22737. */
  22738. readonly onBindObservable: Observable<AbstractMesh>;
  22739. /**
  22740. * An observer which watches for bind events
  22741. */
  22742. private _onBindObserver;
  22743. /**
  22744. * Called during a bind event
  22745. */
  22746. onBind: (Mesh: AbstractMesh) => void;
  22747. /**
  22748. * An event triggered when the material is unbound
  22749. */
  22750. readonly onUnBindObservable: Observable<Material>;
  22751. /**
  22752. * Stores the value of the alpha mode
  22753. */
  22754. private _alphaMode;
  22755. /**
  22756. * Sets the value of the alpha mode.
  22757. *
  22758. * | Value | Type | Description |
  22759. * | --- | --- | --- |
  22760. * | 0 | ALPHA_DISABLE | |
  22761. * | 1 | ALPHA_ADD | |
  22762. * | 2 | ALPHA_COMBINE | |
  22763. * | 3 | ALPHA_SUBTRACT | |
  22764. * | 4 | ALPHA_MULTIPLY | |
  22765. * | 5 | ALPHA_MAXIMIZED | |
  22766. * | 6 | ALPHA_ONEONE | |
  22767. * | 7 | ALPHA_PREMULTIPLIED | |
  22768. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22769. * | 9 | ALPHA_INTERPOLATE | |
  22770. * | 10 | ALPHA_SCREENMODE | |
  22771. *
  22772. */
  22773. /**
  22774. * Gets the value of the alpha mode
  22775. */
  22776. alphaMode: number;
  22777. /**
  22778. * Stores the state of the need depth pre-pass value
  22779. */
  22780. private _needDepthPrePass;
  22781. /**
  22782. * Sets the need depth pre-pass value
  22783. */
  22784. /**
  22785. * Gets the depth pre-pass value
  22786. */
  22787. needDepthPrePass: boolean;
  22788. /**
  22789. * Specifies if depth writing should be disabled
  22790. */
  22791. disableDepthWrite: boolean;
  22792. /**
  22793. * Specifies if depth writing should be forced
  22794. */
  22795. forceDepthWrite: boolean;
  22796. /**
  22797. * Specifies if there should be a separate pass for culling
  22798. */
  22799. separateCullingPass: boolean;
  22800. /**
  22801. * Stores the state specifing if fog should be enabled
  22802. */
  22803. private _fogEnabled;
  22804. /**
  22805. * Sets the state for enabling fog
  22806. */
  22807. /**
  22808. * Gets the value of the fog enabled state
  22809. */
  22810. fogEnabled: boolean;
  22811. /**
  22812. * Stores the size of points
  22813. */
  22814. pointSize: number;
  22815. /**
  22816. * Stores the z offset value
  22817. */
  22818. zOffset: number;
  22819. /**
  22820. * Gets a value specifying if wireframe mode is enabled
  22821. */
  22822. /**
  22823. * Sets the state of wireframe mode
  22824. */
  22825. wireframe: boolean;
  22826. /**
  22827. * Gets the value specifying if point clouds are enabled
  22828. */
  22829. /**
  22830. * Sets the state of point cloud mode
  22831. */
  22832. pointsCloud: boolean;
  22833. /**
  22834. * Gets the material fill mode
  22835. */
  22836. /**
  22837. * Sets the material fill mode
  22838. */
  22839. fillMode: number;
  22840. /**
  22841. * @hidden
  22842. * Stores the effects for the material
  22843. */
  22844. _effect: Nullable<Effect>;
  22845. /**
  22846. * @hidden
  22847. * Specifies if the material was previously ready
  22848. */
  22849. _wasPreviouslyReady: boolean;
  22850. /**
  22851. * Specifies if uniform buffers should be used
  22852. */
  22853. private _useUBO;
  22854. /**
  22855. * Stores a reference to the scene
  22856. */
  22857. private _scene;
  22858. /**
  22859. * Stores the fill mode state
  22860. */
  22861. private _fillMode;
  22862. /**
  22863. * Specifies if the depth write state should be cached
  22864. */
  22865. private _cachedDepthWriteState;
  22866. /**
  22867. * Stores the uniform buffer
  22868. */
  22869. protected _uniformBuffer: UniformBuffer;
  22870. /** @hidden */
  22871. _indexInSceneMaterialArray: number;
  22872. /** @hidden */
  22873. meshMap: Nullable<{
  22874. [id: string]: AbstractMesh | undefined;
  22875. }>;
  22876. /**
  22877. * Creates a material instance
  22878. * @param name defines the name of the material
  22879. * @param scene defines the scene to reference
  22880. * @param doNotAdd specifies if the material should be added to the scene
  22881. */
  22882. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22883. /**
  22884. * Returns a string representation of the current material
  22885. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22886. * @returns a string with material information
  22887. */
  22888. toString(fullDetails?: boolean): string;
  22889. /**
  22890. * Gets the class name of the material
  22891. * @returns a string with the class name of the material
  22892. */
  22893. getClassName(): string;
  22894. /**
  22895. * Specifies if updates for the material been locked
  22896. */
  22897. readonly isFrozen: boolean;
  22898. /**
  22899. * Locks updates for the material
  22900. */
  22901. freeze(): void;
  22902. /**
  22903. * Unlocks updates for the material
  22904. */
  22905. unfreeze(): void;
  22906. /**
  22907. * Specifies if the material is ready to be used
  22908. * @param mesh defines the mesh to check
  22909. * @param useInstances specifies if instances should be used
  22910. * @returns a boolean indicating if the material is ready to be used
  22911. */
  22912. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22913. /**
  22914. * Specifies that the submesh is ready to be used
  22915. * @param mesh defines the mesh to check
  22916. * @param subMesh defines which submesh to check
  22917. * @param useInstances specifies that instances should be used
  22918. * @returns a boolean indicating that the submesh is ready or not
  22919. */
  22920. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22921. /**
  22922. * Returns the material effect
  22923. * @returns the effect associated with the material
  22924. */
  22925. getEffect(): Nullable<Effect>;
  22926. /**
  22927. * Returns the current scene
  22928. * @returns a Scene
  22929. */
  22930. getScene(): Scene;
  22931. /**
  22932. * Specifies if the material will require alpha blending
  22933. * @returns a boolean specifying if alpha blending is needed
  22934. */
  22935. needAlphaBlending(): boolean;
  22936. /**
  22937. * Specifies if the mesh will require alpha blending
  22938. * @param mesh defines the mesh to check
  22939. * @returns a boolean specifying if alpha blending is needed for the mesh
  22940. */
  22941. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22942. /**
  22943. * Specifies if this material should be rendered in alpha test mode
  22944. * @returns a boolean specifying if an alpha test is needed.
  22945. */
  22946. needAlphaTesting(): boolean;
  22947. /**
  22948. * Gets the texture used for the alpha test
  22949. * @returns the texture to use for alpha testing
  22950. */
  22951. getAlphaTestTexture(): Nullable<BaseTexture>;
  22952. /**
  22953. * Marks the material to indicate that it needs to be re-calculated
  22954. */
  22955. markDirty(): void;
  22956. /** @hidden */
  22957. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22958. /**
  22959. * Binds the material to the mesh
  22960. * @param world defines the world transformation matrix
  22961. * @param mesh defines the mesh to bind the material to
  22962. */
  22963. bind(world: Matrix, mesh?: Mesh): void;
  22964. /**
  22965. * Binds the submesh to the material
  22966. * @param world defines the world transformation matrix
  22967. * @param mesh defines the mesh containing the submesh
  22968. * @param subMesh defines the submesh to bind the material to
  22969. */
  22970. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22971. /**
  22972. * Binds the world matrix to the material
  22973. * @param world defines the world transformation matrix
  22974. */
  22975. bindOnlyWorldMatrix(world: Matrix): void;
  22976. /**
  22977. * Binds the scene's uniform buffer to the effect.
  22978. * @param effect defines the effect to bind to the scene uniform buffer
  22979. * @param sceneUbo defines the uniform buffer storing scene data
  22980. */
  22981. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22982. /**
  22983. * Binds the view matrix to the effect
  22984. * @param effect defines the effect to bind the view matrix to
  22985. */
  22986. bindView(effect: Effect): void;
  22987. /**
  22988. * Binds the view projection matrix to the effect
  22989. * @param effect defines the effect to bind the view projection matrix to
  22990. */
  22991. bindViewProjection(effect: Effect): void;
  22992. /**
  22993. * Specifies if material alpha testing should be turned on for the mesh
  22994. * @param mesh defines the mesh to check
  22995. */
  22996. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22997. /**
  22998. * Processes to execute after binding the material to a mesh
  22999. * @param mesh defines the rendered mesh
  23000. */
  23001. protected _afterBind(mesh?: Mesh): void;
  23002. /**
  23003. * Unbinds the material from the mesh
  23004. */
  23005. unbind(): void;
  23006. /**
  23007. * Gets the active textures from the material
  23008. * @returns an array of textures
  23009. */
  23010. getActiveTextures(): BaseTexture[];
  23011. /**
  23012. * Specifies if the material uses a texture
  23013. * @param texture defines the texture to check against the material
  23014. * @returns a boolean specifying if the material uses the texture
  23015. */
  23016. hasTexture(texture: BaseTexture): boolean;
  23017. /**
  23018. * Makes a duplicate of the material, and gives it a new name
  23019. * @param name defines the new name for the duplicated material
  23020. * @returns the cloned material
  23021. */
  23022. clone(name: string): Nullable<Material>;
  23023. /**
  23024. * Gets the meshes bound to the material
  23025. * @returns an array of meshes bound to the material
  23026. */
  23027. getBindedMeshes(): AbstractMesh[];
  23028. /**
  23029. * Force shader compilation
  23030. * @param mesh defines the mesh associated with this material
  23031. * @param onCompiled defines a function to execute once the material is compiled
  23032. * @param options defines the options to configure the compilation
  23033. */
  23034. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23035. clipPlane: boolean;
  23036. }>): void;
  23037. /**
  23038. * Force shader compilation
  23039. * @param mesh defines the mesh that will use this material
  23040. * @param options defines additional options for compiling the shaders
  23041. * @returns a promise that resolves when the compilation completes
  23042. */
  23043. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23044. clipPlane: boolean;
  23045. }>): Promise<void>;
  23046. private static readonly _ImageProcessingDirtyCallBack;
  23047. private static readonly _TextureDirtyCallBack;
  23048. private static readonly _FresnelDirtyCallBack;
  23049. private static readonly _MiscDirtyCallBack;
  23050. private static readonly _LightsDirtyCallBack;
  23051. private static readonly _AttributeDirtyCallBack;
  23052. private static _FresnelAndMiscDirtyCallBack;
  23053. private static _TextureAndMiscDirtyCallBack;
  23054. private static readonly _DirtyCallbackArray;
  23055. private static readonly _RunDirtyCallBacks;
  23056. /**
  23057. * Marks a define in the material to indicate that it needs to be re-computed
  23058. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23059. */
  23060. markAsDirty(flag: number): void;
  23061. /**
  23062. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23063. * @param func defines a function which checks material defines against the submeshes
  23064. */
  23065. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23066. /**
  23067. * Indicates that image processing needs to be re-calculated for all submeshes
  23068. */
  23069. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23070. /**
  23071. * Indicates that textures need to be re-calculated for all submeshes
  23072. */
  23073. protected _markAllSubMeshesAsTexturesDirty(): void;
  23074. /**
  23075. * Indicates that fresnel needs to be re-calculated for all submeshes
  23076. */
  23077. protected _markAllSubMeshesAsFresnelDirty(): void;
  23078. /**
  23079. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23080. */
  23081. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23082. /**
  23083. * Indicates that lights need to be re-calculated for all submeshes
  23084. */
  23085. protected _markAllSubMeshesAsLightsDirty(): void;
  23086. /**
  23087. * Indicates that attributes need to be re-calculated for all submeshes
  23088. */
  23089. protected _markAllSubMeshesAsAttributesDirty(): void;
  23090. /**
  23091. * Indicates that misc needs to be re-calculated for all submeshes
  23092. */
  23093. protected _markAllSubMeshesAsMiscDirty(): void;
  23094. /**
  23095. * Indicates that textures and misc need to be re-calculated for all submeshes
  23096. */
  23097. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23098. /**
  23099. * Disposes the material
  23100. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23101. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23102. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23103. */
  23104. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23105. /** @hidden */
  23106. private releaseVertexArrayObject;
  23107. /**
  23108. * Serializes this material
  23109. * @returns the serialized material object
  23110. */
  23111. serialize(): any;
  23112. /**
  23113. * Creates a material from parsed material data
  23114. * @param parsedMaterial defines parsed material data
  23115. * @param scene defines the hosting scene
  23116. * @param rootUrl defines the root URL to use to load textures
  23117. * @returns a new material
  23118. */
  23119. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23120. }
  23121. }
  23122. declare module "babylonjs/Meshes/subMesh" {
  23123. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23124. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23125. import { Engine } from "babylonjs/Engines/engine";
  23126. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23127. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23128. import { Effect } from "babylonjs/Materials/effect";
  23129. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23130. import { Collider } from "babylonjs/Collisions/collider";
  23131. import { Material } from "babylonjs/Materials/material";
  23132. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23134. import { Mesh } from "babylonjs/Meshes/mesh";
  23135. import { Ray } from "babylonjs/Culling/ray";
  23136. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23137. /**
  23138. * Base class for submeshes
  23139. */
  23140. export class BaseSubMesh {
  23141. /** @hidden */
  23142. _materialDefines: Nullable<MaterialDefines>;
  23143. /** @hidden */
  23144. _materialEffect: Nullable<Effect>;
  23145. /**
  23146. * Gets associated effect
  23147. */
  23148. readonly effect: Nullable<Effect>;
  23149. /**
  23150. * Sets associated effect (effect used to render this submesh)
  23151. * @param effect defines the effect to associate with
  23152. * @param defines defines the set of defines used to compile this effect
  23153. */
  23154. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23155. }
  23156. /**
  23157. * Defines a subdivision inside a mesh
  23158. */
  23159. export class SubMesh extends BaseSubMesh implements ICullable {
  23160. /** the material index to use */
  23161. materialIndex: number;
  23162. /** vertex index start */
  23163. verticesStart: number;
  23164. /** vertices count */
  23165. verticesCount: number;
  23166. /** index start */
  23167. indexStart: number;
  23168. /** indices count */
  23169. indexCount: number;
  23170. /** @hidden */
  23171. _linesIndexCount: number;
  23172. private _mesh;
  23173. private _renderingMesh;
  23174. private _boundingInfo;
  23175. private _linesIndexBuffer;
  23176. /** @hidden */
  23177. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23178. /** @hidden */
  23179. _trianglePlanes: Plane[];
  23180. /** @hidden */
  23181. _lastColliderTransformMatrix: Nullable<Matrix>;
  23182. /** @hidden */
  23183. _renderId: number;
  23184. /** @hidden */
  23185. _alphaIndex: number;
  23186. /** @hidden */
  23187. _distanceToCamera: number;
  23188. /** @hidden */
  23189. _id: number;
  23190. private _currentMaterial;
  23191. /**
  23192. * Add a new submesh to a mesh
  23193. * @param materialIndex defines the material index to use
  23194. * @param verticesStart defines vertex index start
  23195. * @param verticesCount defines vertices count
  23196. * @param indexStart defines index start
  23197. * @param indexCount defines indices count
  23198. * @param mesh defines the parent mesh
  23199. * @param renderingMesh defines an optional rendering mesh
  23200. * @param createBoundingBox defines if bounding box should be created for this submesh
  23201. * @returns the new submesh
  23202. */
  23203. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23204. /**
  23205. * Creates a new submesh
  23206. * @param materialIndex defines the material index to use
  23207. * @param verticesStart defines vertex index start
  23208. * @param verticesCount defines vertices count
  23209. * @param indexStart defines index start
  23210. * @param indexCount defines indices count
  23211. * @param mesh defines the parent mesh
  23212. * @param renderingMesh defines an optional rendering mesh
  23213. * @param createBoundingBox defines if bounding box should be created for this submesh
  23214. */
  23215. constructor(
  23216. /** the material index to use */
  23217. materialIndex: number,
  23218. /** vertex index start */
  23219. verticesStart: number,
  23220. /** vertices count */
  23221. verticesCount: number,
  23222. /** index start */
  23223. indexStart: number,
  23224. /** indices count */
  23225. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23226. /**
  23227. * Returns true if this submesh covers the entire parent mesh
  23228. * @ignorenaming
  23229. */
  23230. readonly IsGlobal: boolean;
  23231. /**
  23232. * Returns the submesh BoudingInfo object
  23233. * @returns current bounding info (or mesh's one if the submesh is global)
  23234. */
  23235. getBoundingInfo(): BoundingInfo;
  23236. /**
  23237. * Sets the submesh BoundingInfo
  23238. * @param boundingInfo defines the new bounding info to use
  23239. * @returns the SubMesh
  23240. */
  23241. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23242. /**
  23243. * Returns the mesh of the current submesh
  23244. * @return the parent mesh
  23245. */
  23246. getMesh(): AbstractMesh;
  23247. /**
  23248. * Returns the rendering mesh of the submesh
  23249. * @returns the rendering mesh (could be different from parent mesh)
  23250. */
  23251. getRenderingMesh(): Mesh;
  23252. /**
  23253. * Returns the submesh material
  23254. * @returns null or the current material
  23255. */
  23256. getMaterial(): Nullable<Material>;
  23257. /**
  23258. * Sets a new updated BoundingInfo object to the submesh
  23259. * @param data defines an optional position array to use to determine the bounding info
  23260. * @returns the SubMesh
  23261. */
  23262. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23263. /** @hidden */
  23264. _checkCollision(collider: Collider): boolean;
  23265. /**
  23266. * Updates the submesh BoundingInfo
  23267. * @param world defines the world matrix to use to update the bounding info
  23268. * @returns the submesh
  23269. */
  23270. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23271. /**
  23272. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23273. * @param frustumPlanes defines the frustum planes
  23274. * @returns true if the submesh is intersecting with the frustum
  23275. */
  23276. isInFrustum(frustumPlanes: Plane[]): boolean;
  23277. /**
  23278. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23279. * @param frustumPlanes defines the frustum planes
  23280. * @returns true if the submesh is inside the frustum
  23281. */
  23282. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23283. /**
  23284. * Renders the submesh
  23285. * @param enableAlphaMode defines if alpha needs to be used
  23286. * @returns the submesh
  23287. */
  23288. render(enableAlphaMode: boolean): SubMesh;
  23289. /**
  23290. * @hidden
  23291. */
  23292. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23293. /**
  23294. * Checks if the submesh intersects with a ray
  23295. * @param ray defines the ray to test
  23296. * @returns true is the passed ray intersects the submesh bounding box
  23297. */
  23298. canIntersects(ray: Ray): boolean;
  23299. /**
  23300. * Intersects current submesh with a ray
  23301. * @param ray defines the ray to test
  23302. * @param positions defines mesh's positions array
  23303. * @param indices defines mesh's indices array
  23304. * @param fastCheck defines if only bounding info should be used
  23305. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23306. * @returns intersection info or null if no intersection
  23307. */
  23308. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23309. /** @hidden */
  23310. private _intersectLines;
  23311. /** @hidden */
  23312. private _intersectTriangles;
  23313. /** @hidden */
  23314. private _intersectUnIndexedTriangles;
  23315. /** @hidden */
  23316. _rebuild(): void;
  23317. /**
  23318. * Creates a new submesh from the passed mesh
  23319. * @param newMesh defines the new hosting mesh
  23320. * @param newRenderingMesh defines an optional rendering mesh
  23321. * @returns the new submesh
  23322. */
  23323. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23324. /**
  23325. * Release associated resources
  23326. */
  23327. dispose(): void;
  23328. /**
  23329. * Gets the class name
  23330. * @returns the string "SubMesh".
  23331. */
  23332. getClassName(): string;
  23333. /**
  23334. * Creates a new submesh from indices data
  23335. * @param materialIndex the index of the main mesh material
  23336. * @param startIndex the index where to start the copy in the mesh indices array
  23337. * @param indexCount the number of indices to copy then from the startIndex
  23338. * @param mesh the main mesh to create the submesh from
  23339. * @param renderingMesh the optional rendering mesh
  23340. * @returns a new submesh
  23341. */
  23342. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23343. }
  23344. }
  23345. declare module "babylonjs/Meshes/geometry" {
  23346. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23347. import { Scene } from "babylonjs/scene";
  23348. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23349. import { Engine } from "babylonjs/Engines/engine";
  23350. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23351. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23352. import { Effect } from "babylonjs/Materials/effect";
  23353. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23354. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23355. import { Mesh } from "babylonjs/Meshes/mesh";
  23356. /**
  23357. * Class used to store geometry data (vertex buffers + index buffer)
  23358. */
  23359. export class Geometry implements IGetSetVerticesData {
  23360. /**
  23361. * Gets or sets the ID of the geometry
  23362. */
  23363. id: string;
  23364. /**
  23365. * Gets or sets the unique ID of the geometry
  23366. */
  23367. uniqueId: number;
  23368. /**
  23369. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23370. */
  23371. delayLoadState: number;
  23372. /**
  23373. * Gets the file containing the data to load when running in delay load state
  23374. */
  23375. delayLoadingFile: Nullable<string>;
  23376. /**
  23377. * Callback called when the geometry is updated
  23378. */
  23379. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23380. private _scene;
  23381. private _engine;
  23382. private _meshes;
  23383. private _totalVertices;
  23384. /** @hidden */
  23385. _indices: IndicesArray;
  23386. /** @hidden */
  23387. _vertexBuffers: {
  23388. [key: string]: VertexBuffer;
  23389. };
  23390. private _isDisposed;
  23391. private _extend;
  23392. private _boundingBias;
  23393. /** @hidden */
  23394. _delayInfo: Array<string>;
  23395. private _indexBuffer;
  23396. private _indexBufferIsUpdatable;
  23397. /** @hidden */
  23398. _boundingInfo: Nullable<BoundingInfo>;
  23399. /** @hidden */
  23400. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23401. /** @hidden */
  23402. _softwareSkinningFrameId: number;
  23403. private _vertexArrayObjects;
  23404. private _updatable;
  23405. /** @hidden */
  23406. _positions: Nullable<Vector3[]>;
  23407. /**
  23408. * 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
  23409. */
  23410. /**
  23411. * 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
  23412. */
  23413. boundingBias: Vector2;
  23414. /**
  23415. * Static function used to attach a new empty geometry to a mesh
  23416. * @param mesh defines the mesh to attach the geometry to
  23417. * @returns the new Geometry
  23418. */
  23419. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23420. /**
  23421. * Creates a new geometry
  23422. * @param id defines the unique ID
  23423. * @param scene defines the hosting scene
  23424. * @param vertexData defines the VertexData used to get geometry data
  23425. * @param updatable defines if geometry must be updatable (false by default)
  23426. * @param mesh defines the mesh that will be associated with the geometry
  23427. */
  23428. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23429. /**
  23430. * Gets the current extend of the geometry
  23431. */
  23432. readonly extend: {
  23433. minimum: Vector3;
  23434. maximum: Vector3;
  23435. };
  23436. /**
  23437. * Gets the hosting scene
  23438. * @returns the hosting Scene
  23439. */
  23440. getScene(): Scene;
  23441. /**
  23442. * Gets the hosting engine
  23443. * @returns the hosting Engine
  23444. */
  23445. getEngine(): Engine;
  23446. /**
  23447. * Defines if the geometry is ready to use
  23448. * @returns true if the geometry is ready to be used
  23449. */
  23450. isReady(): boolean;
  23451. /**
  23452. * Gets a value indicating that the geometry should not be serialized
  23453. */
  23454. readonly doNotSerialize: boolean;
  23455. /** @hidden */
  23456. _rebuild(): void;
  23457. /**
  23458. * Affects all geometry data in one call
  23459. * @param vertexData defines the geometry data
  23460. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23461. */
  23462. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23463. /**
  23464. * Set specific vertex data
  23465. * @param kind defines the data kind (Position, normal, etc...)
  23466. * @param data defines the vertex data to use
  23467. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23468. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23469. */
  23470. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23471. /**
  23472. * Removes a specific vertex data
  23473. * @param kind defines the data kind (Position, normal, etc...)
  23474. */
  23475. removeVerticesData(kind: string): void;
  23476. /**
  23477. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23478. * @param buffer defines the vertex buffer to use
  23479. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23480. */
  23481. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23482. /**
  23483. * Update a specific vertex buffer
  23484. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23485. * It will do nothing if the buffer is not updatable
  23486. * @param kind defines the data kind (Position, normal, etc...)
  23487. * @param data defines the data to use
  23488. * @param offset defines the offset in the target buffer where to store the data
  23489. * @param useBytes set to true if the offset is in bytes
  23490. */
  23491. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23492. /**
  23493. * Update a specific vertex buffer
  23494. * This function will create a new buffer if the current one is not updatable
  23495. * @param kind defines the data kind (Position, normal, etc...)
  23496. * @param data defines the data to use
  23497. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23498. */
  23499. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23500. private _updateBoundingInfo;
  23501. /** @hidden */
  23502. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23503. /**
  23504. * Gets total number of vertices
  23505. * @returns the total number of vertices
  23506. */
  23507. getTotalVertices(): number;
  23508. /**
  23509. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23510. * @param kind defines the data kind (Position, normal, etc...)
  23511. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23512. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23513. * @returns a float array containing vertex data
  23514. */
  23515. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23516. /**
  23517. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23518. * @param kind defines the data kind (Position, normal, etc...)
  23519. * @returns true if the vertex buffer with the specified kind is updatable
  23520. */
  23521. isVertexBufferUpdatable(kind: string): boolean;
  23522. /**
  23523. * Gets a specific vertex buffer
  23524. * @param kind defines the data kind (Position, normal, etc...)
  23525. * @returns a VertexBuffer
  23526. */
  23527. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23528. /**
  23529. * Returns all vertex buffers
  23530. * @return an object holding all vertex buffers indexed by kind
  23531. */
  23532. getVertexBuffers(): Nullable<{
  23533. [key: string]: VertexBuffer;
  23534. }>;
  23535. /**
  23536. * Gets a boolean indicating if specific vertex buffer is present
  23537. * @param kind defines the data kind (Position, normal, etc...)
  23538. * @returns true if data is present
  23539. */
  23540. isVerticesDataPresent(kind: string): boolean;
  23541. /**
  23542. * Gets a list of all attached data kinds (Position, normal, etc...)
  23543. * @returns a list of string containing all kinds
  23544. */
  23545. getVerticesDataKinds(): string[];
  23546. /**
  23547. * Update index buffer
  23548. * @param indices defines the indices to store in the index buffer
  23549. * @param offset defines the offset in the target buffer where to store the data
  23550. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  23551. */
  23552. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23553. /**
  23554. * Creates a new index buffer
  23555. * @param indices defines the indices to store in the index buffer
  23556. * @param totalVertices defines the total number of vertices (could be null)
  23557. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23558. */
  23559. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23560. /**
  23561. * Return the total number of indices
  23562. * @returns the total number of indices
  23563. */
  23564. getTotalIndices(): number;
  23565. /**
  23566. * Gets the index buffer array
  23567. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23568. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23569. * @returns the index buffer array
  23570. */
  23571. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23572. /**
  23573. * Gets the index buffer
  23574. * @return the index buffer
  23575. */
  23576. getIndexBuffer(): Nullable<DataBuffer>;
  23577. /** @hidden */
  23578. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23579. /**
  23580. * Release the associated resources for a specific mesh
  23581. * @param mesh defines the source mesh
  23582. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23583. */
  23584. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23585. /**
  23586. * Apply current geometry to a given mesh
  23587. * @param mesh defines the mesh to apply geometry to
  23588. */
  23589. applyToMesh(mesh: Mesh): void;
  23590. private _updateExtend;
  23591. private _applyToMesh;
  23592. private notifyUpdate;
  23593. /**
  23594. * Load the geometry if it was flagged as delay loaded
  23595. * @param scene defines the hosting scene
  23596. * @param onLoaded defines a callback called when the geometry is loaded
  23597. */
  23598. load(scene: Scene, onLoaded?: () => void): void;
  23599. private _queueLoad;
  23600. /**
  23601. * Invert the geometry to move from a right handed system to a left handed one.
  23602. */
  23603. toLeftHanded(): void;
  23604. /** @hidden */
  23605. _resetPointsArrayCache(): void;
  23606. /** @hidden */
  23607. _generatePointsArray(): boolean;
  23608. /**
  23609. * Gets a value indicating if the geometry is disposed
  23610. * @returns true if the geometry was disposed
  23611. */
  23612. isDisposed(): boolean;
  23613. private _disposeVertexArrayObjects;
  23614. /**
  23615. * Free all associated resources
  23616. */
  23617. dispose(): void;
  23618. /**
  23619. * Clone the current geometry into a new geometry
  23620. * @param id defines the unique ID of the new geometry
  23621. * @returns a new geometry object
  23622. */
  23623. copy(id: string): Geometry;
  23624. /**
  23625. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23626. * @return a JSON representation of the current geometry data (without the vertices data)
  23627. */
  23628. serialize(): any;
  23629. private toNumberArray;
  23630. /**
  23631. * Serialize all vertices data into a JSON oject
  23632. * @returns a JSON representation of the current geometry data
  23633. */
  23634. serializeVerticeData(): any;
  23635. /**
  23636. * Extracts a clone of a mesh geometry
  23637. * @param mesh defines the source mesh
  23638. * @param id defines the unique ID of the new geometry object
  23639. * @returns the new geometry object
  23640. */
  23641. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23642. /**
  23643. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23644. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23645. * Be aware Math.random() could cause collisions, but:
  23646. * "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"
  23647. * @returns a string containing a new GUID
  23648. */
  23649. static RandomId(): string;
  23650. /** @hidden */
  23651. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23652. private static _CleanMatricesWeights;
  23653. /**
  23654. * Create a new geometry from persisted data (Using .babylon file format)
  23655. * @param parsedVertexData defines the persisted data
  23656. * @param scene defines the hosting scene
  23657. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23658. * @returns the new geometry object
  23659. */
  23660. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23661. }
  23662. }
  23663. declare module "babylonjs/Meshes/mesh.vertexData" {
  23664. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23665. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23666. import { Geometry } from "babylonjs/Meshes/geometry";
  23667. import { Mesh } from "babylonjs/Meshes/mesh";
  23668. /**
  23669. * Define an interface for all classes that will get and set the data on vertices
  23670. */
  23671. export interface IGetSetVerticesData {
  23672. /**
  23673. * Gets a boolean indicating if specific vertex data is present
  23674. * @param kind defines the vertex data kind to use
  23675. * @returns true is data kind is present
  23676. */
  23677. isVerticesDataPresent(kind: string): boolean;
  23678. /**
  23679. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23680. * @param kind defines the data kind (Position, normal, etc...)
  23681. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23682. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23683. * @returns a float array containing vertex data
  23684. */
  23685. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23686. /**
  23687. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23688. * @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.
  23689. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23690. * @returns the indices array or an empty array if the mesh has no geometry
  23691. */
  23692. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23693. /**
  23694. * Set specific vertex data
  23695. * @param kind defines the data kind (Position, normal, etc...)
  23696. * @param data defines the vertex data to use
  23697. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23698. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23699. */
  23700. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23701. /**
  23702. * Update a specific associated vertex buffer
  23703. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23704. * - VertexBuffer.PositionKind
  23705. * - VertexBuffer.UVKind
  23706. * - VertexBuffer.UV2Kind
  23707. * - VertexBuffer.UV3Kind
  23708. * - VertexBuffer.UV4Kind
  23709. * - VertexBuffer.UV5Kind
  23710. * - VertexBuffer.UV6Kind
  23711. * - VertexBuffer.ColorKind
  23712. * - VertexBuffer.MatricesIndicesKind
  23713. * - VertexBuffer.MatricesIndicesExtraKind
  23714. * - VertexBuffer.MatricesWeightsKind
  23715. * - VertexBuffer.MatricesWeightsExtraKind
  23716. * @param data defines the data source
  23717. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23718. * @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)
  23719. */
  23720. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23721. /**
  23722. * Creates a new index buffer
  23723. * @param indices defines the indices to store in the index buffer
  23724. * @param totalVertices defines the total number of vertices (could be null)
  23725. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23726. */
  23727. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23728. }
  23729. /**
  23730. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23731. */
  23732. export class VertexData {
  23733. /**
  23734. * Mesh side orientation : usually the external or front surface
  23735. */
  23736. static readonly FRONTSIDE: number;
  23737. /**
  23738. * Mesh side orientation : usually the internal or back surface
  23739. */
  23740. static readonly BACKSIDE: number;
  23741. /**
  23742. * Mesh side orientation : both internal and external or front and back surfaces
  23743. */
  23744. static readonly DOUBLESIDE: number;
  23745. /**
  23746. * Mesh side orientation : by default, `FRONTSIDE`
  23747. */
  23748. static readonly DEFAULTSIDE: number;
  23749. /**
  23750. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23751. */
  23752. positions: Nullable<FloatArray>;
  23753. /**
  23754. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23755. */
  23756. normals: Nullable<FloatArray>;
  23757. /**
  23758. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23759. */
  23760. tangents: Nullable<FloatArray>;
  23761. /**
  23762. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23763. */
  23764. uvs: Nullable<FloatArray>;
  23765. /**
  23766. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23767. */
  23768. uvs2: Nullable<FloatArray>;
  23769. /**
  23770. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23771. */
  23772. uvs3: Nullable<FloatArray>;
  23773. /**
  23774. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23775. */
  23776. uvs4: Nullable<FloatArray>;
  23777. /**
  23778. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23779. */
  23780. uvs5: Nullable<FloatArray>;
  23781. /**
  23782. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23783. */
  23784. uvs6: Nullable<FloatArray>;
  23785. /**
  23786. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23787. */
  23788. colors: Nullable<FloatArray>;
  23789. /**
  23790. * 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).
  23791. */
  23792. matricesIndices: Nullable<FloatArray>;
  23793. /**
  23794. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23795. */
  23796. matricesWeights: Nullable<FloatArray>;
  23797. /**
  23798. * An array extending the number of possible indices
  23799. */
  23800. matricesIndicesExtra: Nullable<FloatArray>;
  23801. /**
  23802. * An array extending the number of possible weights when the number of indices is extended
  23803. */
  23804. matricesWeightsExtra: Nullable<FloatArray>;
  23805. /**
  23806. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23807. */
  23808. indices: Nullable<IndicesArray>;
  23809. /**
  23810. * Uses the passed data array to set the set the values for the specified kind of data
  23811. * @param data a linear array of floating numbers
  23812. * @param kind the type of data that is being set, eg positions, colors etc
  23813. */
  23814. set(data: FloatArray, kind: string): void;
  23815. /**
  23816. * Associates the vertexData to the passed Mesh.
  23817. * Sets it as updatable or not (default `false`)
  23818. * @param mesh the mesh the vertexData is applied to
  23819. * @param updatable when used and having the value true allows new data to update the vertexData
  23820. * @returns the VertexData
  23821. */
  23822. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23823. /**
  23824. * Associates the vertexData to the passed Geometry.
  23825. * Sets it as updatable or not (default `false`)
  23826. * @param geometry the geometry the vertexData is applied to
  23827. * @param updatable when used and having the value true allows new data to update the vertexData
  23828. * @returns VertexData
  23829. */
  23830. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23831. /**
  23832. * Updates the associated mesh
  23833. * @param mesh the mesh to be updated
  23834. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23835. * @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
  23836. * @returns VertexData
  23837. */
  23838. updateMesh(mesh: Mesh): VertexData;
  23839. /**
  23840. * Updates the associated geometry
  23841. * @param geometry the geometry to be updated
  23842. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23843. * @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
  23844. * @returns VertexData.
  23845. */
  23846. updateGeometry(geometry: Geometry): VertexData;
  23847. private _applyTo;
  23848. private _update;
  23849. /**
  23850. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23851. * @param matrix the transforming matrix
  23852. * @returns the VertexData
  23853. */
  23854. transform(matrix: Matrix): VertexData;
  23855. /**
  23856. * Merges the passed VertexData into the current one
  23857. * @param other the VertexData to be merged into the current one
  23858. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23859. * @returns the modified VertexData
  23860. */
  23861. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23862. private _mergeElement;
  23863. private _validate;
  23864. /**
  23865. * Serializes the VertexData
  23866. * @returns a serialized object
  23867. */
  23868. serialize(): any;
  23869. /**
  23870. * Extracts the vertexData from a mesh
  23871. * @param mesh the mesh from which to extract the VertexData
  23872. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23873. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23874. * @returns the object VertexData associated to the passed mesh
  23875. */
  23876. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23877. /**
  23878. * Extracts the vertexData from the geometry
  23879. * @param geometry the geometry from which to extract the VertexData
  23880. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23881. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23882. * @returns the object VertexData associated to the passed mesh
  23883. */
  23884. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23885. private static _ExtractFrom;
  23886. /**
  23887. * Creates the VertexData for a Ribbon
  23888. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23889. * * pathArray array of paths, each of which an array of successive Vector3
  23890. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23891. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23892. * * 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
  23893. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23894. * * 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)
  23895. * * 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)
  23896. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23897. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23898. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23899. * @returns the VertexData of the ribbon
  23900. */
  23901. static CreateRibbon(options: {
  23902. pathArray: Vector3[][];
  23903. closeArray?: boolean;
  23904. closePath?: boolean;
  23905. offset?: number;
  23906. sideOrientation?: number;
  23907. frontUVs?: Vector4;
  23908. backUVs?: Vector4;
  23909. invertUV?: boolean;
  23910. uvs?: Vector2[];
  23911. colors?: Color4[];
  23912. }): VertexData;
  23913. /**
  23914. * Creates the VertexData for a box
  23915. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23916. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23917. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23918. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23919. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23920. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23921. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23922. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23923. * * 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)
  23924. * * 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)
  23925. * @returns the VertexData of the box
  23926. */
  23927. static CreateBox(options: {
  23928. size?: number;
  23929. width?: number;
  23930. height?: number;
  23931. depth?: number;
  23932. faceUV?: Vector4[];
  23933. faceColors?: Color4[];
  23934. sideOrientation?: number;
  23935. frontUVs?: Vector4;
  23936. backUVs?: Vector4;
  23937. }): VertexData;
  23938. /**
  23939. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23940. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23941. * * segments sets the number of horizontal strips optional, default 32
  23942. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23943. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23944. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23945. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23946. * * 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
  23947. * * 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
  23948. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23949. * * 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)
  23950. * * 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)
  23951. * @returns the VertexData of the ellipsoid
  23952. */
  23953. static CreateSphere(options: {
  23954. segments?: number;
  23955. diameter?: number;
  23956. diameterX?: number;
  23957. diameterY?: number;
  23958. diameterZ?: number;
  23959. arc?: number;
  23960. slice?: number;
  23961. sideOrientation?: number;
  23962. frontUVs?: Vector4;
  23963. backUVs?: Vector4;
  23964. }): VertexData;
  23965. /**
  23966. * Creates the VertexData for a cylinder, cone or prism
  23967. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23968. * * height sets the height (y direction) of the cylinder, optional, default 2
  23969. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23970. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23971. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23972. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23973. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23974. * * 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
  23975. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23976. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23977. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23978. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23979. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23980. * * 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)
  23981. * * 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)
  23982. * @returns the VertexData of the cylinder, cone or prism
  23983. */
  23984. static CreateCylinder(options: {
  23985. height?: number;
  23986. diameterTop?: number;
  23987. diameterBottom?: number;
  23988. diameter?: number;
  23989. tessellation?: number;
  23990. subdivisions?: number;
  23991. arc?: number;
  23992. faceColors?: Color4[];
  23993. faceUV?: Vector4[];
  23994. hasRings?: boolean;
  23995. enclose?: boolean;
  23996. sideOrientation?: number;
  23997. frontUVs?: Vector4;
  23998. backUVs?: Vector4;
  23999. }): VertexData;
  24000. /**
  24001. * Creates the VertexData for a torus
  24002. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24003. * * diameter the diameter of the torus, optional default 1
  24004. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24005. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24006. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24007. * * 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)
  24008. * * 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)
  24009. * @returns the VertexData of the torus
  24010. */
  24011. static CreateTorus(options: {
  24012. diameter?: number;
  24013. thickness?: number;
  24014. tessellation?: number;
  24015. sideOrientation?: number;
  24016. frontUVs?: Vector4;
  24017. backUVs?: Vector4;
  24018. }): VertexData;
  24019. /**
  24020. * Creates the VertexData of the LineSystem
  24021. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24022. * - lines an array of lines, each line being an array of successive Vector3
  24023. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24024. * @returns the VertexData of the LineSystem
  24025. */
  24026. static CreateLineSystem(options: {
  24027. lines: Vector3[][];
  24028. colors?: Nullable<Color4[][]>;
  24029. }): VertexData;
  24030. /**
  24031. * Create the VertexData for a DashedLines
  24032. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24033. * - points an array successive Vector3
  24034. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24035. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24036. * - dashNb the intended total number of dashes, optional, default 200
  24037. * @returns the VertexData for the DashedLines
  24038. */
  24039. static CreateDashedLines(options: {
  24040. points: Vector3[];
  24041. dashSize?: number;
  24042. gapSize?: number;
  24043. dashNb?: number;
  24044. }): VertexData;
  24045. /**
  24046. * Creates the VertexData for a Ground
  24047. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24048. * - width the width (x direction) of the ground, optional, default 1
  24049. * - height the height (z direction) of the ground, optional, default 1
  24050. * - subdivisions the number of subdivisions per side, optional, default 1
  24051. * @returns the VertexData of the Ground
  24052. */
  24053. static CreateGround(options: {
  24054. width?: number;
  24055. height?: number;
  24056. subdivisions?: number;
  24057. subdivisionsX?: number;
  24058. subdivisionsY?: number;
  24059. }): VertexData;
  24060. /**
  24061. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24062. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24063. * * xmin the ground minimum X coordinate, optional, default -1
  24064. * * zmin the ground minimum Z coordinate, optional, default -1
  24065. * * xmax the ground maximum X coordinate, optional, default 1
  24066. * * zmax the ground maximum Z coordinate, optional, default 1
  24067. * * 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}
  24068. * * 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}
  24069. * @returns the VertexData of the TiledGround
  24070. */
  24071. static CreateTiledGround(options: {
  24072. xmin: number;
  24073. zmin: number;
  24074. xmax: number;
  24075. zmax: number;
  24076. subdivisions?: {
  24077. w: number;
  24078. h: number;
  24079. };
  24080. precision?: {
  24081. w: number;
  24082. h: number;
  24083. };
  24084. }): VertexData;
  24085. /**
  24086. * Creates the VertexData of the Ground designed from a heightmap
  24087. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24088. * * width the width (x direction) of the ground
  24089. * * height the height (z direction) of the ground
  24090. * * subdivisions the number of subdivisions per side
  24091. * * minHeight the minimum altitude on the ground, optional, default 0
  24092. * * maxHeight the maximum altitude on the ground, optional default 1
  24093. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24094. * * buffer the array holding the image color data
  24095. * * bufferWidth the width of image
  24096. * * bufferHeight the height of image
  24097. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24098. * @returns the VertexData of the Ground designed from a heightmap
  24099. */
  24100. static CreateGroundFromHeightMap(options: {
  24101. width: number;
  24102. height: number;
  24103. subdivisions: number;
  24104. minHeight: number;
  24105. maxHeight: number;
  24106. colorFilter: Color3;
  24107. buffer: Uint8Array;
  24108. bufferWidth: number;
  24109. bufferHeight: number;
  24110. alphaFilter: number;
  24111. }): VertexData;
  24112. /**
  24113. * Creates the VertexData for a Plane
  24114. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24115. * * size sets the width and height of the plane to the value of size, optional default 1
  24116. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24117. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24118. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24119. * * 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)
  24120. * * 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)
  24121. * @returns the VertexData of the box
  24122. */
  24123. static CreatePlane(options: {
  24124. size?: number;
  24125. width?: number;
  24126. height?: number;
  24127. sideOrientation?: number;
  24128. frontUVs?: Vector4;
  24129. backUVs?: Vector4;
  24130. }): VertexData;
  24131. /**
  24132. * Creates the VertexData of the Disc or regular Polygon
  24133. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24134. * * radius the radius of the disc, optional default 0.5
  24135. * * tessellation the number of polygon sides, optional, default 64
  24136. * * 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
  24137. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24138. * * 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)
  24139. * * 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)
  24140. * @returns the VertexData of the box
  24141. */
  24142. static CreateDisc(options: {
  24143. radius?: number;
  24144. tessellation?: number;
  24145. arc?: number;
  24146. sideOrientation?: number;
  24147. frontUVs?: Vector4;
  24148. backUVs?: Vector4;
  24149. }): VertexData;
  24150. /**
  24151. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24152. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24153. * @param polygon a mesh built from polygonTriangulation.build()
  24154. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24155. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24156. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24157. * @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)
  24158. * @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)
  24159. * @returns the VertexData of the Polygon
  24160. */
  24161. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24162. /**
  24163. * Creates the VertexData of the IcoSphere
  24164. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24165. * * radius the radius of the IcoSphere, optional default 1
  24166. * * radiusX allows stretching in the x direction, optional, default radius
  24167. * * radiusY allows stretching in the y direction, optional, default radius
  24168. * * radiusZ allows stretching in the z direction, optional, default radius
  24169. * * flat when true creates a flat shaded mesh, optional, default true
  24170. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24171. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24172. * * 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)
  24173. * * 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)
  24174. * @returns the VertexData of the IcoSphere
  24175. */
  24176. static CreateIcoSphere(options: {
  24177. radius?: number;
  24178. radiusX?: number;
  24179. radiusY?: number;
  24180. radiusZ?: number;
  24181. flat?: boolean;
  24182. subdivisions?: number;
  24183. sideOrientation?: number;
  24184. frontUVs?: Vector4;
  24185. backUVs?: Vector4;
  24186. }): VertexData;
  24187. /**
  24188. * Creates the VertexData for a Polyhedron
  24189. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24190. * * type provided types are:
  24191. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24192. * * 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)
  24193. * * size the size of the IcoSphere, optional default 1
  24194. * * sizeX allows stretching in the x direction, optional, default size
  24195. * * sizeY allows stretching in the y direction, optional, default size
  24196. * * sizeZ allows stretching in the z direction, optional, default size
  24197. * * 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
  24198. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24199. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24200. * * flat when true creates a flat shaded mesh, optional, default true
  24201. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24202. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24203. * * 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)
  24204. * * 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)
  24205. * @returns the VertexData of the Polyhedron
  24206. */
  24207. static CreatePolyhedron(options: {
  24208. type?: number;
  24209. size?: number;
  24210. sizeX?: number;
  24211. sizeY?: number;
  24212. sizeZ?: number;
  24213. custom?: any;
  24214. faceUV?: Vector4[];
  24215. faceColors?: Color4[];
  24216. flat?: boolean;
  24217. sideOrientation?: number;
  24218. frontUVs?: Vector4;
  24219. backUVs?: Vector4;
  24220. }): VertexData;
  24221. /**
  24222. * Creates the VertexData for a TorusKnot
  24223. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24224. * * radius the radius of the torus knot, optional, default 2
  24225. * * tube the thickness of the tube, optional, default 0.5
  24226. * * radialSegments the number of sides on each tube segments, optional, default 32
  24227. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24228. * * p the number of windings around the z axis, optional, default 2
  24229. * * q the number of windings around the x axis, optional, default 3
  24230. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24231. * * 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)
  24232. * * 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)
  24233. * @returns the VertexData of the Torus Knot
  24234. */
  24235. static CreateTorusKnot(options: {
  24236. radius?: number;
  24237. tube?: number;
  24238. radialSegments?: number;
  24239. tubularSegments?: number;
  24240. p?: number;
  24241. q?: number;
  24242. sideOrientation?: number;
  24243. frontUVs?: Vector4;
  24244. backUVs?: Vector4;
  24245. }): VertexData;
  24246. /**
  24247. * Compute normals for given positions and indices
  24248. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24249. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24250. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24251. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24252. * * facetNormals : optional array of facet normals (vector3)
  24253. * * facetPositions : optional array of facet positions (vector3)
  24254. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24255. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24256. * * bInfo : optional bounding info, required for facetPartitioning computation
  24257. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24258. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24259. * * useRightHandedSystem: optional boolean to for right handed system computation
  24260. * * depthSort : optional boolean to enable the facet depth sort computation
  24261. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24262. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24263. */
  24264. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24265. facetNormals?: any;
  24266. facetPositions?: any;
  24267. facetPartitioning?: any;
  24268. ratio?: number;
  24269. bInfo?: any;
  24270. bbSize?: Vector3;
  24271. subDiv?: any;
  24272. useRightHandedSystem?: boolean;
  24273. depthSort?: boolean;
  24274. distanceTo?: Vector3;
  24275. depthSortedFacets?: any;
  24276. }): void;
  24277. /** @hidden */
  24278. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24279. /**
  24280. * Applies VertexData created from the imported parameters to the geometry
  24281. * @param parsedVertexData the parsed data from an imported file
  24282. * @param geometry the geometry to apply the VertexData to
  24283. */
  24284. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24285. }
  24286. }
  24287. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24288. import { Nullable } from "babylonjs/types";
  24289. import { Scene } from "babylonjs/scene";
  24290. import { Vector4 } from "babylonjs/Maths/math";
  24291. import { Mesh } from "babylonjs/Meshes/mesh";
  24292. /**
  24293. * Class containing static functions to help procedurally build meshes
  24294. */
  24295. export class DiscBuilder {
  24296. /**
  24297. * Creates a plane polygonal mesh. By default, this is a disc
  24298. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24299. * * 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
  24300. * * 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
  24301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24302. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24304. * @param name defines the name of the mesh
  24305. * @param options defines the options used to create the mesh
  24306. * @param scene defines the hosting scene
  24307. * @returns the plane polygonal mesh
  24308. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24309. */
  24310. static CreateDisc(name: string, options: {
  24311. radius?: number;
  24312. tessellation?: number;
  24313. arc?: number;
  24314. updatable?: boolean;
  24315. sideOrientation?: number;
  24316. frontUVs?: Vector4;
  24317. backUVs?: Vector4;
  24318. }, scene?: Nullable<Scene>): Mesh;
  24319. }
  24320. }
  24321. declare module "babylonjs/Particles/solidParticleSystem" {
  24322. import { Vector3 } from "babylonjs/Maths/math";
  24323. import { Mesh } from "babylonjs/Meshes/mesh";
  24324. import { Scene, IDisposable } from "babylonjs/scene";
  24325. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24326. /**
  24327. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24328. *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.
  24329. * The SPS is also a particle system. It provides some methods to manage the particles.
  24330. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24331. *
  24332. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24333. */
  24334. export class SolidParticleSystem implements IDisposable {
  24335. /**
  24336. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24337. * Example : var p = SPS.particles[i];
  24338. */
  24339. particles: SolidParticle[];
  24340. /**
  24341. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24342. */
  24343. nbParticles: number;
  24344. /**
  24345. * If the particles must ever face the camera (default false). Useful for planar particles.
  24346. */
  24347. billboard: boolean;
  24348. /**
  24349. * Recompute normals when adding a shape
  24350. */
  24351. recomputeNormals: boolean;
  24352. /**
  24353. * This a counter ofr your own usage. It's not set by any SPS functions.
  24354. */
  24355. counter: number;
  24356. /**
  24357. * The SPS name. This name is also given to the underlying mesh.
  24358. */
  24359. name: string;
  24360. /**
  24361. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24362. */
  24363. mesh: Mesh;
  24364. /**
  24365. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24366. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24367. */
  24368. vars: any;
  24369. /**
  24370. * This array is populated when the SPS is set as 'pickable'.
  24371. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24372. * Each element of this array is an object `{idx: int, faceId: int}`.
  24373. * `idx` is the picked particle index in the `SPS.particles` array
  24374. * `faceId` is the picked face index counted within this particle.
  24375. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24376. */
  24377. pickedParticles: {
  24378. idx: number;
  24379. faceId: number;
  24380. }[];
  24381. /**
  24382. * This array is populated when `enableDepthSort` is set to true.
  24383. * Each element of this array is an instance of the class DepthSortedParticle.
  24384. */
  24385. depthSortedParticles: DepthSortedParticle[];
  24386. /**
  24387. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24388. * @hidden
  24389. */
  24390. _bSphereOnly: boolean;
  24391. /**
  24392. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24393. * @hidden
  24394. */
  24395. _bSphereRadiusFactor: number;
  24396. private _scene;
  24397. private _positions;
  24398. private _indices;
  24399. private _normals;
  24400. private _colors;
  24401. private _uvs;
  24402. private _indices32;
  24403. private _positions32;
  24404. private _normals32;
  24405. private _fixedNormal32;
  24406. private _colors32;
  24407. private _uvs32;
  24408. private _index;
  24409. private _updatable;
  24410. private _pickable;
  24411. private _isVisibilityBoxLocked;
  24412. private _alwaysVisible;
  24413. private _depthSort;
  24414. private _shapeCounter;
  24415. private _copy;
  24416. private _color;
  24417. private _computeParticleColor;
  24418. private _computeParticleTexture;
  24419. private _computeParticleRotation;
  24420. private _computeParticleVertex;
  24421. private _computeBoundingBox;
  24422. private _depthSortParticles;
  24423. private _camera;
  24424. private _mustUnrotateFixedNormals;
  24425. private _particlesIntersect;
  24426. private _needs32Bits;
  24427. /**
  24428. * Creates a SPS (Solid Particle System) object.
  24429. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24430. * @param scene (Scene) is the scene in which the SPS is added.
  24431. * @param options defines the options of the sps e.g.
  24432. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24433. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24434. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24435. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24436. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24437. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24438. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24439. */
  24440. constructor(name: string, scene: Scene, options?: {
  24441. updatable?: boolean;
  24442. isPickable?: boolean;
  24443. enableDepthSort?: boolean;
  24444. particleIntersection?: boolean;
  24445. boundingSphereOnly?: boolean;
  24446. bSphereRadiusFactor?: number;
  24447. });
  24448. /**
  24449. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24450. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24451. * @returns the created mesh
  24452. */
  24453. buildMesh(): Mesh;
  24454. /**
  24455. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24456. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24457. * Thus the particles generated from `digest()` have their property `position` set yet.
  24458. * @param mesh ( Mesh ) is the mesh to be digested
  24459. * @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
  24460. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24461. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24462. * @returns the current SPS
  24463. */
  24464. digest(mesh: Mesh, options?: {
  24465. facetNb?: number;
  24466. number?: number;
  24467. delta?: number;
  24468. }): SolidParticleSystem;
  24469. private _unrotateFixedNormals;
  24470. private _resetCopy;
  24471. private _meshBuilder;
  24472. private _posToShape;
  24473. private _uvsToShapeUV;
  24474. private _addParticle;
  24475. /**
  24476. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24477. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24478. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24479. * @param nb (positive integer) the number of particles to be created from this model
  24480. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24481. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24482. * @returns the number of shapes in the system
  24483. */
  24484. addShape(mesh: Mesh, nb: number, options?: {
  24485. positionFunction?: any;
  24486. vertexFunction?: any;
  24487. }): number;
  24488. private _rebuildParticle;
  24489. /**
  24490. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24491. * @returns the SPS.
  24492. */
  24493. rebuildMesh(): SolidParticleSystem;
  24494. /**
  24495. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24496. * This method calls `updateParticle()` for each particle of the SPS.
  24497. * For an animated SPS, it is usually called within the render loop.
  24498. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24499. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24500. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24501. * @returns the SPS.
  24502. */
  24503. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24504. /**
  24505. * Disposes the SPS.
  24506. */
  24507. dispose(): void;
  24508. /**
  24509. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24510. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24511. * @returns the SPS.
  24512. */
  24513. refreshVisibleSize(): SolidParticleSystem;
  24514. /**
  24515. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24516. * @param size the size (float) of the visibility box
  24517. * note : this doesn't lock the SPS mesh bounding box.
  24518. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24519. */
  24520. setVisibilityBox(size: number): void;
  24521. /**
  24522. * Gets whether the SPS as always visible or not
  24523. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24524. */
  24525. /**
  24526. * Sets the SPS as always visible or not
  24527. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24528. */
  24529. isAlwaysVisible: boolean;
  24530. /**
  24531. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24532. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24533. */
  24534. /**
  24535. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24536. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24537. */
  24538. isVisibilityBoxLocked: boolean;
  24539. /**
  24540. * Tells to `setParticles()` to compute the particle rotations or not.
  24541. * Default value : true. The SPS is faster when it's set to false.
  24542. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24543. */
  24544. /**
  24545. * Gets if `setParticles()` computes the particle rotations or not.
  24546. * Default value : true. The SPS is faster when it's set to false.
  24547. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24548. */
  24549. computeParticleRotation: boolean;
  24550. /**
  24551. * Tells to `setParticles()` to compute the particle colors or not.
  24552. * Default value : true. The SPS is faster when it's set to false.
  24553. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24554. */
  24555. /**
  24556. * Gets if `setParticles()` computes the particle colors or not.
  24557. * Default value : true. The SPS is faster when it's set to false.
  24558. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24559. */
  24560. computeParticleColor: boolean;
  24561. /**
  24562. * Gets if `setParticles()` computes the particle textures or not.
  24563. * Default value : true. The SPS is faster when it's set to false.
  24564. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24565. */
  24566. computeParticleTexture: boolean;
  24567. /**
  24568. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24569. * Default value : false. The SPS is faster when it's set to false.
  24570. * Note : the particle custom vertex positions aren't stored values.
  24571. */
  24572. /**
  24573. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24574. * Default value : false. The SPS is faster when it's set to false.
  24575. * Note : the particle custom vertex positions aren't stored values.
  24576. */
  24577. computeParticleVertex: boolean;
  24578. /**
  24579. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24580. */
  24581. /**
  24582. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24583. */
  24584. computeBoundingBox: boolean;
  24585. /**
  24586. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24587. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24588. * Default : `true`
  24589. */
  24590. /**
  24591. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24592. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24593. * Default : `true`
  24594. */
  24595. depthSortParticles: boolean;
  24596. /**
  24597. * This function does nothing. It may be overwritten to set all the particle first values.
  24598. * The SPS doesn't call this function, you may have to call it by your own.
  24599. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24600. */
  24601. initParticles(): void;
  24602. /**
  24603. * This function does nothing. It may be overwritten to recycle a particle.
  24604. * The SPS doesn't call this function, you may have to call it by your own.
  24605. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24606. * @param particle The particle to recycle
  24607. * @returns the recycled particle
  24608. */
  24609. recycleParticle(particle: SolidParticle): SolidParticle;
  24610. /**
  24611. * Updates a particle : this function should be overwritten by the user.
  24612. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24613. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24614. * @example : just set a particle position or velocity and recycle conditions
  24615. * @param particle The particle to update
  24616. * @returns the updated particle
  24617. */
  24618. updateParticle(particle: SolidParticle): SolidParticle;
  24619. /**
  24620. * Updates a vertex of a particle : it can be overwritten by the user.
  24621. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24622. * @param particle the current particle
  24623. * @param vertex the current index of the current particle
  24624. * @param pt the index of the current vertex in the particle shape
  24625. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24626. * @example : just set a vertex particle position
  24627. * @returns the updated vertex
  24628. */
  24629. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24630. /**
  24631. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24632. * This does nothing and may be overwritten by the user.
  24633. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24634. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24635. * @param update the boolean update value actually passed to setParticles()
  24636. */
  24637. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24638. /**
  24639. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24640. * This will be passed three parameters.
  24641. * This does nothing and may be overwritten by the user.
  24642. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24643. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24644. * @param update the boolean update value actually passed to setParticles()
  24645. */
  24646. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24647. }
  24648. }
  24649. declare module "babylonjs/Particles/solidParticle" {
  24650. import { Nullable } from "babylonjs/types";
  24651. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24652. import { Mesh } from "babylonjs/Meshes/mesh";
  24653. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24654. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24655. /**
  24656. * Represents one particle of a solid particle system.
  24657. */
  24658. export class SolidParticle {
  24659. /**
  24660. * particle global index
  24661. */
  24662. idx: number;
  24663. /**
  24664. * The color of the particle
  24665. */
  24666. color: Nullable<Color4>;
  24667. /**
  24668. * The world space position of the particle.
  24669. */
  24670. position: Vector3;
  24671. /**
  24672. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24673. */
  24674. rotation: Vector3;
  24675. /**
  24676. * The world space rotation quaternion of the particle.
  24677. */
  24678. rotationQuaternion: Nullable<Quaternion>;
  24679. /**
  24680. * The scaling of the particle.
  24681. */
  24682. scaling: Vector3;
  24683. /**
  24684. * The uvs of the particle.
  24685. */
  24686. uvs: Vector4;
  24687. /**
  24688. * The current speed of the particle.
  24689. */
  24690. velocity: Vector3;
  24691. /**
  24692. * The pivot point in the particle local space.
  24693. */
  24694. pivot: Vector3;
  24695. /**
  24696. * Must the particle be translated from its pivot point in its local space ?
  24697. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24698. * Default : false
  24699. */
  24700. translateFromPivot: boolean;
  24701. /**
  24702. * Is the particle active or not ?
  24703. */
  24704. alive: boolean;
  24705. /**
  24706. * Is the particle visible or not ?
  24707. */
  24708. isVisible: boolean;
  24709. /**
  24710. * Index of this particle in the global "positions" array (Internal use)
  24711. * @hidden
  24712. */
  24713. _pos: number;
  24714. /**
  24715. * @hidden Index of this particle in the global "indices" array (Internal use)
  24716. */
  24717. _ind: number;
  24718. /**
  24719. * @hidden ModelShape of this particle (Internal use)
  24720. */
  24721. _model: ModelShape;
  24722. /**
  24723. * ModelShape id of this particle
  24724. */
  24725. shapeId: number;
  24726. /**
  24727. * Index of the particle in its shape id (Internal use)
  24728. */
  24729. idxInShape: number;
  24730. /**
  24731. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24732. */
  24733. _modelBoundingInfo: BoundingInfo;
  24734. /**
  24735. * @hidden Particle BoundingInfo object (Internal use)
  24736. */
  24737. _boundingInfo: BoundingInfo;
  24738. /**
  24739. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24740. */
  24741. _sps: SolidParticleSystem;
  24742. /**
  24743. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24744. */
  24745. _stillInvisible: boolean;
  24746. /**
  24747. * @hidden Last computed particle rotation matrix
  24748. */
  24749. _rotationMatrix: number[];
  24750. /**
  24751. * Parent particle Id, if any.
  24752. * Default null.
  24753. */
  24754. parentId: Nullable<number>;
  24755. /**
  24756. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24757. * The possible values are :
  24758. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24759. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24760. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24761. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24762. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24763. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24764. * */
  24765. cullingStrategy: number;
  24766. /**
  24767. * @hidden Internal global position in the SPS.
  24768. */
  24769. _globalPosition: Vector3;
  24770. /**
  24771. * Creates a Solid Particle object.
  24772. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24773. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24774. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24775. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24776. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24777. * @param shapeId (integer) is the model shape identifier in the SPS.
  24778. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24779. * @param sps defines the sps it is associated to
  24780. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24781. */
  24782. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24783. /**
  24784. * Legacy support, changed scale to scaling
  24785. */
  24786. /**
  24787. * Legacy support, changed scale to scaling
  24788. */
  24789. scale: Vector3;
  24790. /**
  24791. * Legacy support, changed quaternion to rotationQuaternion
  24792. */
  24793. /**
  24794. * Legacy support, changed quaternion to rotationQuaternion
  24795. */
  24796. quaternion: Nullable<Quaternion>;
  24797. /**
  24798. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24799. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24800. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24801. * @returns true if it intersects
  24802. */
  24803. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24804. /**
  24805. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24806. * A particle is in the frustum if its bounding box intersects the frustum
  24807. * @param frustumPlanes defines the frustum to test
  24808. * @returns true if the particle is in the frustum planes
  24809. */
  24810. isInFrustum(frustumPlanes: Plane[]): boolean;
  24811. /**
  24812. * get the rotation matrix of the particle
  24813. * @hidden
  24814. */
  24815. getRotationMatrix(m: Matrix): void;
  24816. }
  24817. /**
  24818. * Represents the shape of the model used by one particle of a solid particle system.
  24819. * SPS internal tool, don't use it manually.
  24820. */
  24821. export class ModelShape {
  24822. /**
  24823. * The shape id
  24824. * @hidden
  24825. */
  24826. shapeID: number;
  24827. /**
  24828. * flat array of model positions (internal use)
  24829. * @hidden
  24830. */
  24831. _shape: Vector3[];
  24832. /**
  24833. * flat array of model UVs (internal use)
  24834. * @hidden
  24835. */
  24836. _shapeUV: number[];
  24837. /**
  24838. * length of the shape in the model indices array (internal use)
  24839. * @hidden
  24840. */
  24841. _indicesLength: number;
  24842. /**
  24843. * Custom position function (internal use)
  24844. * @hidden
  24845. */
  24846. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24847. /**
  24848. * Custom vertex function (internal use)
  24849. * @hidden
  24850. */
  24851. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24852. /**
  24853. * 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.
  24854. * SPS internal tool, don't use it manually.
  24855. * @hidden
  24856. */
  24857. 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>);
  24858. }
  24859. /**
  24860. * Represents a Depth Sorted Particle in the solid particle system.
  24861. */
  24862. export class DepthSortedParticle {
  24863. /**
  24864. * Index of the particle in the "indices" array
  24865. */
  24866. ind: number;
  24867. /**
  24868. * Length of the particle shape in the "indices" array
  24869. */
  24870. indicesLength: number;
  24871. /**
  24872. * Squared distance from the particle to the camera
  24873. */
  24874. sqDistance: number;
  24875. }
  24876. }
  24877. declare module "babylonjs/Meshes/abstractMesh" {
  24878. import { Observable } from "babylonjs/Misc/observable";
  24879. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24880. import { Camera } from "babylonjs/Cameras/camera";
  24881. import { Scene, IDisposable } from "babylonjs/scene";
  24882. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24883. import { Node } from "babylonjs/node";
  24884. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24885. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24886. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24887. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24888. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24889. import { Material } from "babylonjs/Materials/material";
  24890. import { Light } from "babylonjs/Lights/light";
  24891. import { Skeleton } from "babylonjs/Bones/skeleton";
  24892. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24893. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24894. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24895. import { Ray } from "babylonjs/Culling/ray";
  24896. import { Collider } from "babylonjs/Collisions/collider";
  24897. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24898. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24899. /**
  24900. * Class used to store all common mesh properties
  24901. */
  24902. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24903. /** No occlusion */
  24904. static OCCLUSION_TYPE_NONE: number;
  24905. /** Occlusion set to optimisitic */
  24906. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24907. /** Occlusion set to strict */
  24908. static OCCLUSION_TYPE_STRICT: number;
  24909. /** Use an accurante occlusion algorithm */
  24910. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24911. /** Use a conservative occlusion algorithm */
  24912. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24913. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24914. * Test order :
  24915. * Is the bounding sphere outside the frustum ?
  24916. * If not, are the bounding box vertices outside the frustum ?
  24917. * It not, then the cullable object is in the frustum.
  24918. */
  24919. static readonly CULLINGSTRATEGY_STANDARD: number;
  24920. /** Culling strategy : Bounding Sphere Only.
  24921. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24922. * It's also less accurate than the standard because some not visible objects can still be selected.
  24923. * Test : is the bounding sphere outside the frustum ?
  24924. * If not, then the cullable object is in the frustum.
  24925. */
  24926. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24927. /** Culling strategy : Optimistic Inclusion.
  24928. * This in an inclusion test first, then the standard exclusion test.
  24929. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24930. * 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.
  24931. * Anyway, it's as accurate as the standard strategy.
  24932. * Test :
  24933. * Is the cullable object bounding sphere center in the frustum ?
  24934. * If not, apply the default culling strategy.
  24935. */
  24936. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24937. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24938. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24939. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24940. * 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.
  24941. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24942. * Test :
  24943. * Is the cullable object bounding sphere center in the frustum ?
  24944. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24945. */
  24946. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24947. /**
  24948. * No billboard
  24949. */
  24950. static readonly BILLBOARDMODE_NONE: number;
  24951. /** Billboard on X axis */
  24952. static readonly BILLBOARDMODE_X: number;
  24953. /** Billboard on Y axis */
  24954. static readonly BILLBOARDMODE_Y: number;
  24955. /** Billboard on Z axis */
  24956. static readonly BILLBOARDMODE_Z: number;
  24957. /** Billboard on all axes */
  24958. static readonly BILLBOARDMODE_ALL: number;
  24959. private _facetData;
  24960. /**
  24961. * The culling strategy to use to check whether the mesh must be rendered or not.
  24962. * This value can be changed at any time and will be used on the next render mesh selection.
  24963. * The possible values are :
  24964. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24965. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24966. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24967. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24968. * Please read each static variable documentation to get details about the culling process.
  24969. * */
  24970. cullingStrategy: number;
  24971. /**
  24972. * Gets the number of facets in the mesh
  24973. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24974. */
  24975. readonly facetNb: number;
  24976. /**
  24977. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24978. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24979. */
  24980. partitioningSubdivisions: number;
  24981. /**
  24982. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24983. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24984. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24985. */
  24986. partitioningBBoxRatio: number;
  24987. /**
  24988. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24989. * Works only for updatable meshes.
  24990. * Doesn't work with multi-materials
  24991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24992. */
  24993. mustDepthSortFacets: boolean;
  24994. /**
  24995. * The location (Vector3) where the facet depth sort must be computed from.
  24996. * By default, the active camera position.
  24997. * Used only when facet depth sort is enabled
  24998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24999. */
  25000. facetDepthSortFrom: Vector3;
  25001. /**
  25002. * gets a boolean indicating if facetData is enabled
  25003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25004. */
  25005. readonly isFacetDataEnabled: boolean;
  25006. /** @hidden */
  25007. _updateNonUniformScalingState(value: boolean): boolean;
  25008. /**
  25009. * An event triggered when this mesh collides with another one
  25010. */
  25011. onCollideObservable: Observable<AbstractMesh>;
  25012. private _onCollideObserver;
  25013. /** Set a function to call when this mesh collides with another one */
  25014. onCollide: () => void;
  25015. /**
  25016. * An event triggered when the collision's position changes
  25017. */
  25018. onCollisionPositionChangeObservable: Observable<Vector3>;
  25019. private _onCollisionPositionChangeObserver;
  25020. /** Set a function to call when the collision's position changes */
  25021. onCollisionPositionChange: () => void;
  25022. /**
  25023. * An event triggered when material is changed
  25024. */
  25025. onMaterialChangedObservable: Observable<AbstractMesh>;
  25026. /**
  25027. * Gets or sets the orientation for POV movement & rotation
  25028. */
  25029. definedFacingForward: boolean;
  25030. /** @hidden */
  25031. _occlusionQuery: Nullable<WebGLQuery>;
  25032. private _visibility;
  25033. /** @hidden */
  25034. _isActive: boolean;
  25035. /** @hidden */
  25036. _onlyForInstances: boolean;
  25037. /** @hidden */
  25038. _renderingGroup: Nullable<RenderingGroup>;
  25039. /**
  25040. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25041. */
  25042. /**
  25043. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25044. */
  25045. visibility: number;
  25046. /** Gets or sets the alpha index used to sort transparent meshes
  25047. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25048. */
  25049. alphaIndex: number;
  25050. /**
  25051. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25052. */
  25053. isVisible: boolean;
  25054. /**
  25055. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25056. */
  25057. isPickable: boolean;
  25058. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25059. showSubMeshesBoundingBox: boolean;
  25060. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25061. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25062. */
  25063. isBlocker: boolean;
  25064. /**
  25065. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25066. */
  25067. enablePointerMoveEvents: boolean;
  25068. /**
  25069. * Specifies the rendering group id for this mesh (0 by default)
  25070. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25071. */
  25072. renderingGroupId: number;
  25073. private _material;
  25074. /** Gets or sets current material */
  25075. material: Nullable<Material>;
  25076. private _receiveShadows;
  25077. /**
  25078. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25079. * @see http://doc.babylonjs.com/babylon101/shadows
  25080. */
  25081. receiveShadows: boolean;
  25082. /** Defines color to use when rendering outline */
  25083. outlineColor: Color3;
  25084. /** Define width to use when rendering outline */
  25085. outlineWidth: number;
  25086. /** Defines color to use when rendering overlay */
  25087. overlayColor: Color3;
  25088. /** Defines alpha to use when rendering overlay */
  25089. overlayAlpha: number;
  25090. private _hasVertexAlpha;
  25091. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25092. hasVertexAlpha: boolean;
  25093. private _useVertexColors;
  25094. /** 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) */
  25095. useVertexColors: boolean;
  25096. private _computeBonesUsingShaders;
  25097. /**
  25098. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25099. */
  25100. computeBonesUsingShaders: boolean;
  25101. private _numBoneInfluencers;
  25102. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25103. numBoneInfluencers: number;
  25104. private _applyFog;
  25105. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25106. applyFog: boolean;
  25107. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25108. useOctreeForRenderingSelection: boolean;
  25109. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25110. useOctreeForPicking: boolean;
  25111. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25112. useOctreeForCollisions: boolean;
  25113. private _layerMask;
  25114. /**
  25115. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25116. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25117. */
  25118. layerMask: number;
  25119. /**
  25120. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25121. */
  25122. alwaysSelectAsActiveMesh: boolean;
  25123. /**
  25124. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25125. */
  25126. doNotSyncBoundingInfo: boolean;
  25127. /**
  25128. * Gets or sets the current action manager
  25129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25130. */
  25131. actionManager: Nullable<AbstractActionManager>;
  25132. private _checkCollisions;
  25133. private _collisionMask;
  25134. private _collisionGroup;
  25135. /**
  25136. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25137. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25138. */
  25139. ellipsoid: Vector3;
  25140. /**
  25141. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25142. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25143. */
  25144. ellipsoidOffset: Vector3;
  25145. private _collider;
  25146. private _oldPositionForCollisions;
  25147. private _diffPositionForCollisions;
  25148. /**
  25149. * Gets or sets a collision mask used to mask collisions (default is -1).
  25150. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25151. */
  25152. collisionMask: number;
  25153. /**
  25154. * Gets or sets the current collision group mask (-1 by default).
  25155. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25156. */
  25157. collisionGroup: number;
  25158. /**
  25159. * Defines edge width used when edgesRenderer is enabled
  25160. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25161. */
  25162. edgesWidth: number;
  25163. /**
  25164. * Defines edge color used when edgesRenderer is enabled
  25165. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25166. */
  25167. edgesColor: Color4;
  25168. /** @hidden */
  25169. _edgesRenderer: Nullable<IEdgesRenderer>;
  25170. /** @hidden */
  25171. _masterMesh: Nullable<AbstractMesh>;
  25172. /** @hidden */
  25173. _boundingInfo: Nullable<BoundingInfo>;
  25174. /** @hidden */
  25175. _renderId: number;
  25176. /**
  25177. * Gets or sets the list of subMeshes
  25178. * @see http://doc.babylonjs.com/how_to/multi_materials
  25179. */
  25180. subMeshes: SubMesh[];
  25181. /** @hidden */
  25182. _intersectionsInProgress: AbstractMesh[];
  25183. /** @hidden */
  25184. _unIndexed: boolean;
  25185. /** @hidden */
  25186. _lightSources: Light[];
  25187. /** Gets the list of lights affecting that mesh */
  25188. readonly lightSources: Light[];
  25189. /** @hidden */
  25190. readonly _positions: Nullable<Vector3[]>;
  25191. /** @hidden */
  25192. _waitingData: {
  25193. lods: Nullable<any>;
  25194. actions: Nullable<any>;
  25195. freezeWorldMatrix: Nullable<boolean>;
  25196. };
  25197. private _skeleton;
  25198. /** @hidden */
  25199. _bonesTransformMatrices: Nullable<Float32Array>;
  25200. /**
  25201. * Gets or sets a skeleton to apply skining transformations
  25202. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25203. */
  25204. skeleton: Nullable<Skeleton>;
  25205. /**
  25206. * An event triggered when the mesh is rebuilt.
  25207. */
  25208. onRebuildObservable: Observable<AbstractMesh>;
  25209. /**
  25210. * Creates a new AbstractMesh
  25211. * @param name defines the name of the mesh
  25212. * @param scene defines the hosting scene
  25213. */
  25214. constructor(name: string, scene?: Nullable<Scene>);
  25215. /**
  25216. * Returns the string "AbstractMesh"
  25217. * @returns "AbstractMesh"
  25218. */
  25219. getClassName(): string;
  25220. /**
  25221. * Gets a string representation of the current mesh
  25222. * @param fullDetails defines a boolean indicating if full details must be included
  25223. * @returns a string representation of the current mesh
  25224. */
  25225. toString(fullDetails?: boolean): string;
  25226. /**
  25227. * @hidden
  25228. */
  25229. protected _getEffectiveParent(): Nullable<Node>;
  25230. /** @hidden */
  25231. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25232. /** @hidden */
  25233. _rebuild(): void;
  25234. /** @hidden */
  25235. _resyncLightSources(): void;
  25236. /** @hidden */
  25237. _resyncLighSource(light: Light): void;
  25238. /** @hidden */
  25239. _unBindEffect(): void;
  25240. /** @hidden */
  25241. _removeLightSource(light: Light): void;
  25242. private _markSubMeshesAsDirty;
  25243. /** @hidden */
  25244. _markSubMeshesAsLightDirty(): void;
  25245. /** @hidden */
  25246. _markSubMeshesAsAttributesDirty(): void;
  25247. /** @hidden */
  25248. _markSubMeshesAsMiscDirty(): void;
  25249. /**
  25250. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25251. */
  25252. scaling: Vector3;
  25253. /**
  25254. * Returns true if the mesh is blocked. Implemented by child classes
  25255. */
  25256. readonly isBlocked: boolean;
  25257. /**
  25258. * Returns the mesh itself by default. Implemented by child classes
  25259. * @param camera defines the camera to use to pick the right LOD level
  25260. * @returns the currentAbstractMesh
  25261. */
  25262. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25263. /**
  25264. * Returns 0 by default. Implemented by child classes
  25265. * @returns an integer
  25266. */
  25267. getTotalVertices(): number;
  25268. /**
  25269. * Returns a positive integer : the total number of indices in this mesh geometry.
  25270. * @returns the numner of indices or zero if the mesh has no geometry.
  25271. */
  25272. getTotalIndices(): number;
  25273. /**
  25274. * Returns null by default. Implemented by child classes
  25275. * @returns null
  25276. */
  25277. getIndices(): Nullable<IndicesArray>;
  25278. /**
  25279. * Returns the array of the requested vertex data kind. Implemented by child classes
  25280. * @param kind defines the vertex data kind to use
  25281. * @returns null
  25282. */
  25283. getVerticesData(kind: string): Nullable<FloatArray>;
  25284. /**
  25285. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25286. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25287. * Note that a new underlying VertexBuffer object is created each call.
  25288. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25289. * @param kind defines vertex data kind:
  25290. * * VertexBuffer.PositionKind
  25291. * * VertexBuffer.UVKind
  25292. * * VertexBuffer.UV2Kind
  25293. * * VertexBuffer.UV3Kind
  25294. * * VertexBuffer.UV4Kind
  25295. * * VertexBuffer.UV5Kind
  25296. * * VertexBuffer.UV6Kind
  25297. * * VertexBuffer.ColorKind
  25298. * * VertexBuffer.MatricesIndicesKind
  25299. * * VertexBuffer.MatricesIndicesExtraKind
  25300. * * VertexBuffer.MatricesWeightsKind
  25301. * * VertexBuffer.MatricesWeightsExtraKind
  25302. * @param data defines the data source
  25303. * @param updatable defines if the data must be flagged as updatable (or static)
  25304. * @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
  25305. * @returns the current mesh
  25306. */
  25307. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25308. /**
  25309. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25310. * If the mesh has no geometry, it is simply returned as it is.
  25311. * @param kind defines vertex data kind:
  25312. * * VertexBuffer.PositionKind
  25313. * * VertexBuffer.UVKind
  25314. * * VertexBuffer.UV2Kind
  25315. * * VertexBuffer.UV3Kind
  25316. * * VertexBuffer.UV4Kind
  25317. * * VertexBuffer.UV5Kind
  25318. * * VertexBuffer.UV6Kind
  25319. * * VertexBuffer.ColorKind
  25320. * * VertexBuffer.MatricesIndicesKind
  25321. * * VertexBuffer.MatricesIndicesExtraKind
  25322. * * VertexBuffer.MatricesWeightsKind
  25323. * * VertexBuffer.MatricesWeightsExtraKind
  25324. * @param data defines the data source
  25325. * @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
  25326. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25327. * @returns the current mesh
  25328. */
  25329. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25330. /**
  25331. * Sets the mesh indices,
  25332. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25333. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25334. * @param totalVertices Defines the total number of vertices
  25335. * @returns the current mesh
  25336. */
  25337. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25338. /**
  25339. * Gets a boolean indicating if specific vertex data is present
  25340. * @param kind defines the vertex data kind to use
  25341. * @returns true is data kind is present
  25342. */
  25343. isVerticesDataPresent(kind: string): boolean;
  25344. /**
  25345. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25346. * @returns a BoundingInfo
  25347. */
  25348. getBoundingInfo(): BoundingInfo;
  25349. /**
  25350. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25351. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25352. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25353. * @returns the current mesh
  25354. */
  25355. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25356. /**
  25357. * Overwrite the current bounding info
  25358. * @param boundingInfo defines the new bounding info
  25359. * @returns the current mesh
  25360. */
  25361. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25362. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25363. readonly useBones: boolean;
  25364. /** @hidden */
  25365. _preActivate(): void;
  25366. /** @hidden */
  25367. _preActivateForIntermediateRendering(renderId: number): void;
  25368. /** @hidden */
  25369. _activate(renderId: number): boolean;
  25370. /** @hidden */
  25371. _postActivate(): void;
  25372. /** @hidden */
  25373. _freeze(): void;
  25374. /** @hidden */
  25375. _unFreeze(): void;
  25376. /**
  25377. * Gets the current world matrix
  25378. * @returns a Matrix
  25379. */
  25380. getWorldMatrix(): Matrix;
  25381. /** @hidden */
  25382. _getWorldMatrixDeterminant(): number;
  25383. /**
  25384. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25385. */
  25386. readonly isAnInstance: boolean;
  25387. /**
  25388. * Perform relative position change from the point of view of behind the front of the mesh.
  25389. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25390. * Supports definition of mesh facing forward or backward
  25391. * @param amountRight defines the distance on the right axis
  25392. * @param amountUp defines the distance on the up axis
  25393. * @param amountForward defines the distance on the forward axis
  25394. * @returns the current mesh
  25395. */
  25396. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25397. /**
  25398. * Calculate relative position change from the point of view of behind the front of the mesh.
  25399. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25400. * Supports definition of mesh facing forward or backward
  25401. * @param amountRight defines the distance on the right axis
  25402. * @param amountUp defines the distance on the up axis
  25403. * @param amountForward defines the distance on the forward axis
  25404. * @returns the new displacement vector
  25405. */
  25406. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25407. /**
  25408. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25409. * Supports definition of mesh facing forward or backward
  25410. * @param flipBack defines the flip
  25411. * @param twirlClockwise defines the twirl
  25412. * @param tiltRight defines the tilt
  25413. * @returns the current mesh
  25414. */
  25415. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25416. /**
  25417. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25418. * Supports definition of mesh facing forward or backward.
  25419. * @param flipBack defines the flip
  25420. * @param twirlClockwise defines the twirl
  25421. * @param tiltRight defines the tilt
  25422. * @returns the new rotation vector
  25423. */
  25424. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25425. /**
  25426. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25427. * This means the mesh underlying bounding box and sphere are recomputed.
  25428. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25429. * @returns the current mesh
  25430. */
  25431. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25432. /** @hidden */
  25433. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25434. /** @hidden */
  25435. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25436. /** @hidden */
  25437. _updateBoundingInfo(): AbstractMesh;
  25438. /** @hidden */
  25439. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25440. /** @hidden */
  25441. protected _afterComputeWorldMatrix(): void;
  25442. /** @hidden */
  25443. readonly _effectiveMesh: AbstractMesh;
  25444. /**
  25445. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25446. * A mesh is in the frustum if its bounding box intersects the frustum
  25447. * @param frustumPlanes defines the frustum to test
  25448. * @returns true if the mesh is in the frustum planes
  25449. */
  25450. isInFrustum(frustumPlanes: Plane[]): boolean;
  25451. /**
  25452. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25453. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25454. * @param frustumPlanes defines the frustum to test
  25455. * @returns true if the mesh is completely in the frustum planes
  25456. */
  25457. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25458. /**
  25459. * True if the mesh intersects another mesh or a SolidParticle object
  25460. * @param mesh defines a target mesh or SolidParticle to test
  25461. * @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)
  25462. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25463. * @returns true if there is an intersection
  25464. */
  25465. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25466. /**
  25467. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25468. * @param point defines the point to test
  25469. * @returns true if there is an intersection
  25470. */
  25471. intersectsPoint(point: Vector3): boolean;
  25472. /**
  25473. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25474. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25475. */
  25476. checkCollisions: boolean;
  25477. /**
  25478. * Gets Collider object used to compute collisions (not physics)
  25479. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25480. */
  25481. readonly collider: Nullable<Collider>;
  25482. /**
  25483. * Move the mesh using collision engine
  25484. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25485. * @param displacement defines the requested displacement vector
  25486. * @returns the current mesh
  25487. */
  25488. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25489. private _onCollisionPositionChange;
  25490. /** @hidden */
  25491. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25492. /** @hidden */
  25493. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25494. /** @hidden */
  25495. _checkCollision(collider: Collider): AbstractMesh;
  25496. /** @hidden */
  25497. _generatePointsArray(): boolean;
  25498. /**
  25499. * Checks if the passed Ray intersects with the mesh
  25500. * @param ray defines the ray to use
  25501. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25502. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25503. * @returns the picking info
  25504. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25505. */
  25506. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25507. /**
  25508. * Clones the current mesh
  25509. * @param name defines the mesh name
  25510. * @param newParent defines the new mesh parent
  25511. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25512. * @returns the new mesh
  25513. */
  25514. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25515. /**
  25516. * Disposes all the submeshes of the current meshnp
  25517. * @returns the current mesh
  25518. */
  25519. releaseSubMeshes(): AbstractMesh;
  25520. /**
  25521. * Releases resources associated with this abstract mesh.
  25522. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25523. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25524. */
  25525. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25526. /**
  25527. * Adds the passed mesh as a child to the current mesh
  25528. * @param mesh defines the child mesh
  25529. * @returns the current mesh
  25530. */
  25531. addChild(mesh: AbstractMesh): AbstractMesh;
  25532. /**
  25533. * Removes the passed mesh from the current mesh children list
  25534. * @param mesh defines the child mesh
  25535. * @returns the current mesh
  25536. */
  25537. removeChild(mesh: AbstractMesh): AbstractMesh;
  25538. /** @hidden */
  25539. private _initFacetData;
  25540. /**
  25541. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25542. * This method can be called within the render loop.
  25543. * 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
  25544. * @returns the current mesh
  25545. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25546. */
  25547. updateFacetData(): AbstractMesh;
  25548. /**
  25549. * Returns the facetLocalNormals array.
  25550. * The normals are expressed in the mesh local spac
  25551. * @returns an array of Vector3
  25552. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25553. */
  25554. getFacetLocalNormals(): Vector3[];
  25555. /**
  25556. * Returns the facetLocalPositions array.
  25557. * The facet positions are expressed in the mesh local space
  25558. * @returns an array of Vector3
  25559. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25560. */
  25561. getFacetLocalPositions(): Vector3[];
  25562. /**
  25563. * Returns the facetLocalPartioning array
  25564. * @returns an array of array of numbers
  25565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25566. */
  25567. getFacetLocalPartitioning(): number[][];
  25568. /**
  25569. * Returns the i-th facet position in the world system.
  25570. * This method allocates a new Vector3 per call
  25571. * @param i defines the facet index
  25572. * @returns a new Vector3
  25573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25574. */
  25575. getFacetPosition(i: number): Vector3;
  25576. /**
  25577. * Sets the reference Vector3 with the i-th facet position in the world system
  25578. * @param i defines the facet index
  25579. * @param ref defines the target vector
  25580. * @returns the current mesh
  25581. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25582. */
  25583. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25584. /**
  25585. * Returns the i-th facet normal in the world system.
  25586. * This method allocates a new Vector3 per call
  25587. * @param i defines the facet index
  25588. * @returns a new Vector3
  25589. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25590. */
  25591. getFacetNormal(i: number): Vector3;
  25592. /**
  25593. * Sets the reference Vector3 with the i-th facet normal in the world system
  25594. * @param i defines the facet index
  25595. * @param ref defines the target vector
  25596. * @returns the current mesh
  25597. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25598. */
  25599. getFacetNormalToRef(i: number, ref: Vector3): this;
  25600. /**
  25601. * 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)
  25602. * @param x defines x coordinate
  25603. * @param y defines y coordinate
  25604. * @param z defines z coordinate
  25605. * @returns the array of facet indexes
  25606. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25607. */
  25608. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25609. /**
  25610. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25611. * @param projected sets as the (x,y,z) world projection on the facet
  25612. * @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
  25613. * @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
  25614. * @param x defines x coordinate
  25615. * @param y defines y coordinate
  25616. * @param z defines z coordinate
  25617. * @returns the face index if found (or null instead)
  25618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25619. */
  25620. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25621. /**
  25622. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25623. * @param projected sets as the (x,y,z) local projection on the facet
  25624. * @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
  25625. * @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
  25626. * @param x defines x coordinate
  25627. * @param y defines y coordinate
  25628. * @param z defines z coordinate
  25629. * @returns the face index if found (or null instead)
  25630. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25631. */
  25632. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25633. /**
  25634. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25635. * @returns the parameters
  25636. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25637. */
  25638. getFacetDataParameters(): any;
  25639. /**
  25640. * Disables the feature FacetData and frees the related memory
  25641. * @returns the current mesh
  25642. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25643. */
  25644. disableFacetData(): AbstractMesh;
  25645. /**
  25646. * Updates the AbstractMesh indices array
  25647. * @param indices defines the data source
  25648. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25649. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  25650. * @returns the current mesh
  25651. */
  25652. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25653. /**
  25654. * Creates new normals data for the mesh
  25655. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25656. * @returns the current mesh
  25657. */
  25658. createNormals(updatable: boolean): AbstractMesh;
  25659. /**
  25660. * Align the mesh with a normal
  25661. * @param normal defines the normal to use
  25662. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25663. * @returns the current mesh
  25664. */
  25665. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25666. /** @hidden */
  25667. _checkOcclusionQuery(): boolean;
  25668. }
  25669. }
  25670. declare module "babylonjs/Actions/actionEvent" {
  25671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25672. import { Nullable } from "babylonjs/types";
  25673. import { Sprite } from "babylonjs/Sprites/sprite";
  25674. import { Scene } from "babylonjs/scene";
  25675. import { Vector2 } from "babylonjs/Maths/math";
  25676. /**
  25677. * Interface used to define ActionEvent
  25678. */
  25679. export interface IActionEvent {
  25680. /** The mesh or sprite that triggered the action */
  25681. source: any;
  25682. /** The X mouse cursor position at the time of the event */
  25683. pointerX: number;
  25684. /** The Y mouse cursor position at the time of the event */
  25685. pointerY: number;
  25686. /** The mesh that is currently pointed at (can be null) */
  25687. meshUnderPointer: Nullable<AbstractMesh>;
  25688. /** the original (browser) event that triggered the ActionEvent */
  25689. sourceEvent?: any;
  25690. /** additional data for the event */
  25691. additionalData?: any;
  25692. }
  25693. /**
  25694. * ActionEvent is the event being sent when an action is triggered.
  25695. */
  25696. export class ActionEvent implements IActionEvent {
  25697. /** The mesh or sprite that triggered the action */
  25698. source: any;
  25699. /** The X mouse cursor position at the time of the event */
  25700. pointerX: number;
  25701. /** The Y mouse cursor position at the time of the event */
  25702. pointerY: number;
  25703. /** The mesh that is currently pointed at (can be null) */
  25704. meshUnderPointer: Nullable<AbstractMesh>;
  25705. /** the original (browser) event that triggered the ActionEvent */
  25706. sourceEvent?: any;
  25707. /** additional data for the event */
  25708. additionalData?: any;
  25709. /**
  25710. * Creates a new ActionEvent
  25711. * @param source The mesh or sprite that triggered the action
  25712. * @param pointerX The X mouse cursor position at the time of the event
  25713. * @param pointerY The Y mouse cursor position at the time of the event
  25714. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25715. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25716. * @param additionalData additional data for the event
  25717. */
  25718. constructor(
  25719. /** The mesh or sprite that triggered the action */
  25720. source: any,
  25721. /** The X mouse cursor position at the time of the event */
  25722. pointerX: number,
  25723. /** The Y mouse cursor position at the time of the event */
  25724. pointerY: number,
  25725. /** The mesh that is currently pointed at (can be null) */
  25726. meshUnderPointer: Nullable<AbstractMesh>,
  25727. /** the original (browser) event that triggered the ActionEvent */
  25728. sourceEvent?: any,
  25729. /** additional data for the event */
  25730. additionalData?: any);
  25731. /**
  25732. * Helper function to auto-create an ActionEvent from a source mesh.
  25733. * @param source The source mesh that triggered the event
  25734. * @param evt The original (browser) event
  25735. * @param additionalData additional data for the event
  25736. * @returns the new ActionEvent
  25737. */
  25738. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25739. /**
  25740. * Helper function to auto-create an ActionEvent from a source sprite
  25741. * @param source The source sprite that triggered the event
  25742. * @param scene Scene associated with the sprite
  25743. * @param evt The original (browser) event
  25744. * @param additionalData additional data for the event
  25745. * @returns the new ActionEvent
  25746. */
  25747. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25748. /**
  25749. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25750. * @param scene the scene where the event occurred
  25751. * @param evt The original (browser) event
  25752. * @returns the new ActionEvent
  25753. */
  25754. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25755. /**
  25756. * Helper function to auto-create an ActionEvent from a primitive
  25757. * @param prim defines the target primitive
  25758. * @param pointerPos defines the pointer position
  25759. * @param evt The original (browser) event
  25760. * @param additionalData additional data for the event
  25761. * @returns the new ActionEvent
  25762. */
  25763. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25764. }
  25765. }
  25766. declare module "babylonjs/Actions/abstractActionManager" {
  25767. import { IDisposable } from "babylonjs/scene";
  25768. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25769. import { IAction } from "babylonjs/Actions/action";
  25770. import { Nullable } from "babylonjs/types";
  25771. /**
  25772. * Abstract class used to decouple action Manager from scene and meshes.
  25773. * Do not instantiate.
  25774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25775. */
  25776. export abstract class AbstractActionManager implements IDisposable {
  25777. /** Gets the list of active triggers */
  25778. static Triggers: {
  25779. [key: string]: number;
  25780. };
  25781. /** Gets the cursor to use when hovering items */
  25782. hoverCursor: string;
  25783. /** Gets the list of actions */
  25784. actions: IAction[];
  25785. /**
  25786. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25787. */
  25788. isRecursive: boolean;
  25789. /**
  25790. * Releases all associated resources
  25791. */
  25792. abstract dispose(): void;
  25793. /**
  25794. * Does this action manager has pointer triggers
  25795. */
  25796. abstract readonly hasPointerTriggers: boolean;
  25797. /**
  25798. * Does this action manager has pick triggers
  25799. */
  25800. abstract readonly hasPickTriggers: boolean;
  25801. /**
  25802. * Process a specific trigger
  25803. * @param trigger defines the trigger to process
  25804. * @param evt defines the event details to be processed
  25805. */
  25806. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25807. /**
  25808. * Does this action manager handles actions of any of the given triggers
  25809. * @param triggers defines the triggers to be tested
  25810. * @return a boolean indicating whether one (or more) of the triggers is handled
  25811. */
  25812. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25813. /**
  25814. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25815. * speed.
  25816. * @param triggerA defines the trigger to be tested
  25817. * @param triggerB defines the trigger to be tested
  25818. * @return a boolean indicating whether one (or more) of the triggers is handled
  25819. */
  25820. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25821. /**
  25822. * Does this action manager handles actions of a given trigger
  25823. * @param trigger defines the trigger to be tested
  25824. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25825. * @return whether the trigger is handled
  25826. */
  25827. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25828. /**
  25829. * Serialize this manager to a JSON object
  25830. * @param name defines the property name to store this manager
  25831. * @returns a JSON representation of this manager
  25832. */
  25833. abstract serialize(name: string): any;
  25834. /**
  25835. * Registers an action to this action manager
  25836. * @param action defines the action to be registered
  25837. * @return the action amended (prepared) after registration
  25838. */
  25839. abstract registerAction(action: IAction): Nullable<IAction>;
  25840. /**
  25841. * Unregisters an action to this action manager
  25842. * @param action defines the action to be unregistered
  25843. * @return a boolean indicating whether the action has been unregistered
  25844. */
  25845. abstract unregisterAction(action: IAction): Boolean;
  25846. /**
  25847. * Does exist one action manager with at least one trigger
  25848. **/
  25849. static readonly HasTriggers: boolean;
  25850. /**
  25851. * Does exist one action manager with at least one pick trigger
  25852. **/
  25853. static readonly HasPickTriggers: boolean;
  25854. /**
  25855. * Does exist one action manager that handles actions of a given trigger
  25856. * @param trigger defines the trigger to be tested
  25857. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25858. **/
  25859. static HasSpecificTrigger(trigger: number): boolean;
  25860. }
  25861. }
  25862. declare module "babylonjs/node" {
  25863. import { Scene } from "babylonjs/scene";
  25864. import { Nullable } from "babylonjs/types";
  25865. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25866. import { Engine } from "babylonjs/Engines/engine";
  25867. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25868. import { Observable } from "babylonjs/Misc/observable";
  25869. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25870. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25871. import { Animatable } from "babylonjs/Animations/animatable";
  25872. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25873. import { Animation } from "babylonjs/Animations/animation";
  25874. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25876. /**
  25877. * Defines how a node can be built from a string name.
  25878. */
  25879. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25880. /**
  25881. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25882. */
  25883. export class Node implements IBehaviorAware<Node> {
  25884. /** @hidden */
  25885. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25886. private static _NodeConstructors;
  25887. /**
  25888. * Add a new node constructor
  25889. * @param type defines the type name of the node to construct
  25890. * @param constructorFunc defines the constructor function
  25891. */
  25892. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25893. /**
  25894. * Returns a node constructor based on type name
  25895. * @param type defines the type name
  25896. * @param name defines the new node name
  25897. * @param scene defines the hosting scene
  25898. * @param options defines optional options to transmit to constructors
  25899. * @returns the new constructor or null
  25900. */
  25901. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25902. /**
  25903. * Gets or sets the name of the node
  25904. */
  25905. name: string;
  25906. /**
  25907. * Gets or sets the id of the node
  25908. */
  25909. id: string;
  25910. /**
  25911. * Gets or sets the unique id of the node
  25912. */
  25913. uniqueId: number;
  25914. /**
  25915. * Gets or sets a string used to store user defined state for the node
  25916. */
  25917. state: string;
  25918. /**
  25919. * Gets or sets an object used to store user defined information for the node
  25920. */
  25921. metadata: any;
  25922. /**
  25923. * For internal use only. Please do not use.
  25924. */
  25925. reservedDataStore: any;
  25926. /**
  25927. * List of inspectable custom properties (used by the Inspector)
  25928. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25929. */
  25930. inspectableCustomProperties: IInspectable[];
  25931. /**
  25932. * Gets or sets a boolean used to define if the node must be serialized
  25933. */
  25934. doNotSerialize: boolean;
  25935. /** @hidden */
  25936. _isDisposed: boolean;
  25937. /**
  25938. * Gets a list of Animations associated with the node
  25939. */
  25940. animations: import("babylonjs/Animations/animation").Animation[];
  25941. protected _ranges: {
  25942. [name: string]: Nullable<AnimationRange>;
  25943. };
  25944. /**
  25945. * Callback raised when the node is ready to be used
  25946. */
  25947. onReady: Nullable<(node: Node) => void>;
  25948. private _isEnabled;
  25949. private _isParentEnabled;
  25950. private _isReady;
  25951. /** @hidden */
  25952. _currentRenderId: number;
  25953. private _parentUpdateId;
  25954. /** @hidden */
  25955. _childUpdateId: number;
  25956. /** @hidden */
  25957. _waitingParentId: Nullable<string>;
  25958. /** @hidden */
  25959. _scene: Scene;
  25960. /** @hidden */
  25961. _cache: any;
  25962. private _parentNode;
  25963. private _children;
  25964. /** @hidden */
  25965. _worldMatrix: Matrix;
  25966. /** @hidden */
  25967. _worldMatrixDeterminant: number;
  25968. /** @hidden */
  25969. _worldMatrixDeterminantIsDirty: boolean;
  25970. /** @hidden */
  25971. private _sceneRootNodesIndex;
  25972. /**
  25973. * Gets a boolean indicating if the node has been disposed
  25974. * @returns true if the node was disposed
  25975. */
  25976. isDisposed(): boolean;
  25977. /**
  25978. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25979. * @see https://doc.babylonjs.com/how_to/parenting
  25980. */
  25981. parent: Nullable<Node>;
  25982. private addToSceneRootNodes;
  25983. private removeFromSceneRootNodes;
  25984. private _animationPropertiesOverride;
  25985. /**
  25986. * Gets or sets the animation properties override
  25987. */
  25988. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25989. /**
  25990. * Gets a string idenfifying the name of the class
  25991. * @returns "Node" string
  25992. */
  25993. getClassName(): string;
  25994. /** @hidden */
  25995. readonly _isNode: boolean;
  25996. /**
  25997. * An event triggered when the mesh is disposed
  25998. */
  25999. onDisposeObservable: Observable<Node>;
  26000. private _onDisposeObserver;
  26001. /**
  26002. * Sets a callback that will be raised when the node will be disposed
  26003. */
  26004. onDispose: () => void;
  26005. /**
  26006. * Creates a new Node
  26007. * @param name the name and id to be given to this node
  26008. * @param scene the scene this node will be added to
  26009. * @param addToRootNodes the node will be added to scene.rootNodes
  26010. */
  26011. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26012. /**
  26013. * Gets the scene of the node
  26014. * @returns a scene
  26015. */
  26016. getScene(): Scene;
  26017. /**
  26018. * Gets the engine of the node
  26019. * @returns a Engine
  26020. */
  26021. getEngine(): Engine;
  26022. private _behaviors;
  26023. /**
  26024. * Attach a behavior to the node
  26025. * @see http://doc.babylonjs.com/features/behaviour
  26026. * @param behavior defines the behavior to attach
  26027. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26028. * @returns the current Node
  26029. */
  26030. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26031. /**
  26032. * Remove an attached behavior
  26033. * @see http://doc.babylonjs.com/features/behaviour
  26034. * @param behavior defines the behavior to attach
  26035. * @returns the current Node
  26036. */
  26037. removeBehavior(behavior: Behavior<Node>): Node;
  26038. /**
  26039. * Gets the list of attached behaviors
  26040. * @see http://doc.babylonjs.com/features/behaviour
  26041. */
  26042. readonly behaviors: Behavior<Node>[];
  26043. /**
  26044. * Gets an attached behavior by name
  26045. * @param name defines the name of the behavior to look for
  26046. * @see http://doc.babylonjs.com/features/behaviour
  26047. * @returns null if behavior was not found else the requested behavior
  26048. */
  26049. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26050. /**
  26051. * Returns the latest update of the World matrix
  26052. * @returns a Matrix
  26053. */
  26054. getWorldMatrix(): Matrix;
  26055. /** @hidden */
  26056. _getWorldMatrixDeterminant(): number;
  26057. /**
  26058. * Returns directly the latest state of the mesh World matrix.
  26059. * A Matrix is returned.
  26060. */
  26061. readonly worldMatrixFromCache: Matrix;
  26062. /** @hidden */
  26063. _initCache(): void;
  26064. /** @hidden */
  26065. updateCache(force?: boolean): void;
  26066. /** @hidden */
  26067. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26068. /** @hidden */
  26069. _updateCache(ignoreParentClass?: boolean): void;
  26070. /** @hidden */
  26071. _isSynchronized(): boolean;
  26072. /** @hidden */
  26073. _markSyncedWithParent(): void;
  26074. /** @hidden */
  26075. isSynchronizedWithParent(): boolean;
  26076. /** @hidden */
  26077. isSynchronized(): boolean;
  26078. /**
  26079. * Is this node ready to be used/rendered
  26080. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26081. * @return true if the node is ready
  26082. */
  26083. isReady(completeCheck?: boolean): boolean;
  26084. /**
  26085. * Is this node enabled?
  26086. * 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
  26087. * @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
  26088. * @return whether this node (and its parent) is enabled
  26089. */
  26090. isEnabled(checkAncestors?: boolean): boolean;
  26091. /** @hidden */
  26092. protected _syncParentEnabledState(): void;
  26093. /**
  26094. * Set the enabled state of this node
  26095. * @param value defines the new enabled state
  26096. */
  26097. setEnabled(value: boolean): void;
  26098. /**
  26099. * Is this node a descendant of the given node?
  26100. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26101. * @param ancestor defines the parent node to inspect
  26102. * @returns a boolean indicating if this node is a descendant of the given node
  26103. */
  26104. isDescendantOf(ancestor: Node): boolean;
  26105. /** @hidden */
  26106. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26107. /**
  26108. * Will return all nodes that have this node as ascendant
  26109. * @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
  26110. * @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
  26111. * @return all children nodes of all types
  26112. */
  26113. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26114. /**
  26115. * Get all child-meshes of this node
  26116. * @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)
  26117. * @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
  26118. * @returns an array of AbstractMesh
  26119. */
  26120. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26121. /**
  26122. * Get all direct children of this node
  26123. * @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
  26124. * @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)
  26125. * @returns an array of Node
  26126. */
  26127. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26128. /** @hidden */
  26129. _setReady(state: boolean): void;
  26130. /**
  26131. * Get an animation by name
  26132. * @param name defines the name of the animation to look for
  26133. * @returns null if not found else the requested animation
  26134. */
  26135. getAnimationByName(name: string): Nullable<Animation>;
  26136. /**
  26137. * Creates an animation range for this node
  26138. * @param name defines the name of the range
  26139. * @param from defines the starting key
  26140. * @param to defines the end key
  26141. */
  26142. createAnimationRange(name: string, from: number, to: number): void;
  26143. /**
  26144. * Delete a specific animation range
  26145. * @param name defines the name of the range to delete
  26146. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26147. */
  26148. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26149. /**
  26150. * Get an animation range by name
  26151. * @param name defines the name of the animation range to look for
  26152. * @returns null if not found else the requested animation range
  26153. */
  26154. getAnimationRange(name: string): Nullable<AnimationRange>;
  26155. /**
  26156. * Gets the list of all animation ranges defined on this node
  26157. * @returns an array
  26158. */
  26159. getAnimationRanges(): Nullable<AnimationRange>[];
  26160. /**
  26161. * Will start the animation sequence
  26162. * @param name defines the range frames for animation sequence
  26163. * @param loop defines if the animation should loop (false by default)
  26164. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26165. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26166. * @returns the object created for this animation. If range does not exist, it will return null
  26167. */
  26168. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26169. /**
  26170. * Serialize animation ranges into a JSON compatible object
  26171. * @returns serialization object
  26172. */
  26173. serializeAnimationRanges(): any;
  26174. /**
  26175. * Computes the world matrix of the node
  26176. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26177. * @returns the world matrix
  26178. */
  26179. computeWorldMatrix(force?: boolean): Matrix;
  26180. /**
  26181. * Releases resources associated with this node.
  26182. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26183. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26184. */
  26185. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26186. /**
  26187. * Parse animation range data from a serialization object and store them into a given node
  26188. * @param node defines where to store the animation ranges
  26189. * @param parsedNode defines the serialization object to read data from
  26190. * @param scene defines the hosting scene
  26191. */
  26192. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26193. /**
  26194. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26195. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26196. * @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
  26197. * @returns the new bounding vectors
  26198. */
  26199. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26200. min: Vector3;
  26201. max: Vector3;
  26202. };
  26203. }
  26204. }
  26205. declare module "babylonjs/Animations/animation" {
  26206. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26207. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26208. import { Nullable } from "babylonjs/types";
  26209. import { Scene } from "babylonjs/scene";
  26210. import { IAnimatable } from "babylonjs/Misc/tools";
  26211. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26212. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26213. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26214. import { Node } from "babylonjs/node";
  26215. import { Animatable } from "babylonjs/Animations/animatable";
  26216. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26217. /**
  26218. * @hidden
  26219. */
  26220. export class _IAnimationState {
  26221. key: number;
  26222. repeatCount: number;
  26223. workValue?: any;
  26224. loopMode?: number;
  26225. offsetValue?: any;
  26226. highLimitValue?: any;
  26227. }
  26228. /**
  26229. * Class used to store any kind of animation
  26230. */
  26231. export class Animation {
  26232. /**Name of the animation */
  26233. name: string;
  26234. /**Property to animate */
  26235. targetProperty: string;
  26236. /**The frames per second of the animation */
  26237. framePerSecond: number;
  26238. /**The data type of the animation */
  26239. dataType: number;
  26240. /**The loop mode of the animation */
  26241. loopMode?: number | undefined;
  26242. /**Specifies if blending should be enabled */
  26243. enableBlending?: boolean | undefined;
  26244. /**
  26245. * Use matrix interpolation instead of using direct key value when animating matrices
  26246. */
  26247. static AllowMatricesInterpolation: boolean;
  26248. /**
  26249. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26250. */
  26251. static AllowMatrixDecomposeForInterpolation: boolean;
  26252. /**
  26253. * Stores the key frames of the animation
  26254. */
  26255. private _keys;
  26256. /**
  26257. * Stores the easing function of the animation
  26258. */
  26259. private _easingFunction;
  26260. /**
  26261. * @hidden Internal use only
  26262. */
  26263. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26264. /**
  26265. * The set of event that will be linked to this animation
  26266. */
  26267. private _events;
  26268. /**
  26269. * Stores an array of target property paths
  26270. */
  26271. targetPropertyPath: string[];
  26272. /**
  26273. * Stores the blending speed of the animation
  26274. */
  26275. blendingSpeed: number;
  26276. /**
  26277. * Stores the animation ranges for the animation
  26278. */
  26279. private _ranges;
  26280. /**
  26281. * @hidden Internal use
  26282. */
  26283. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26284. /**
  26285. * Sets up an animation
  26286. * @param property The property to animate
  26287. * @param animationType The animation type to apply
  26288. * @param framePerSecond The frames per second of the animation
  26289. * @param easingFunction The easing function used in the animation
  26290. * @returns The created animation
  26291. */
  26292. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26293. /**
  26294. * Create and start an animation on a node
  26295. * @param name defines the name of the global animation that will be run on all nodes
  26296. * @param node defines the root node where the animation will take place
  26297. * @param targetProperty defines property to animate
  26298. * @param framePerSecond defines the number of frame per second yo use
  26299. * @param totalFrame defines the number of frames in total
  26300. * @param from defines the initial value
  26301. * @param to defines the final value
  26302. * @param loopMode defines which loop mode you want to use (off by default)
  26303. * @param easingFunction defines the easing function to use (linear by default)
  26304. * @param onAnimationEnd defines the callback to call when animation end
  26305. * @returns the animatable created for this animation
  26306. */
  26307. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26308. /**
  26309. * Create and start an animation on a node and its descendants
  26310. * @param name defines the name of the global animation that will be run on all nodes
  26311. * @param node defines the root node where the animation will take place
  26312. * @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
  26313. * @param targetProperty defines property to animate
  26314. * @param framePerSecond defines the number of frame per second to use
  26315. * @param totalFrame defines the number of frames in total
  26316. * @param from defines the initial value
  26317. * @param to defines the final value
  26318. * @param loopMode defines which loop mode you want to use (off by default)
  26319. * @param easingFunction defines the easing function to use (linear by default)
  26320. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26321. * @returns the list of animatables created for all nodes
  26322. * @example https://www.babylonjs-playground.com/#MH0VLI
  26323. */
  26324. 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[]>;
  26325. /**
  26326. * Creates a new animation, merges it with the existing animations and starts it
  26327. * @param name Name of the animation
  26328. * @param node Node which contains the scene that begins the animations
  26329. * @param targetProperty Specifies which property to animate
  26330. * @param framePerSecond The frames per second of the animation
  26331. * @param totalFrame The total number of frames
  26332. * @param from The frame at the beginning of the animation
  26333. * @param to The frame at the end of the animation
  26334. * @param loopMode Specifies the loop mode of the animation
  26335. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26336. * @param onAnimationEnd Callback to run once the animation is complete
  26337. * @returns Nullable animation
  26338. */
  26339. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26340. /**
  26341. * Transition property of an host to the target Value
  26342. * @param property The property to transition
  26343. * @param targetValue The target Value of the property
  26344. * @param host The object where the property to animate belongs
  26345. * @param scene Scene used to run the animation
  26346. * @param frameRate Framerate (in frame/s) to use
  26347. * @param transition The transition type we want to use
  26348. * @param duration The duration of the animation, in milliseconds
  26349. * @param onAnimationEnd Callback trigger at the end of the animation
  26350. * @returns Nullable animation
  26351. */
  26352. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26353. /**
  26354. * Return the array of runtime animations currently using this animation
  26355. */
  26356. readonly runtimeAnimations: RuntimeAnimation[];
  26357. /**
  26358. * Specifies if any of the runtime animations are currently running
  26359. */
  26360. readonly hasRunningRuntimeAnimations: boolean;
  26361. /**
  26362. * Initializes the animation
  26363. * @param name Name of the animation
  26364. * @param targetProperty Property to animate
  26365. * @param framePerSecond The frames per second of the animation
  26366. * @param dataType The data type of the animation
  26367. * @param loopMode The loop mode of the animation
  26368. * @param enableBlending Specifies if blending should be enabled
  26369. */
  26370. constructor(
  26371. /**Name of the animation */
  26372. name: string,
  26373. /**Property to animate */
  26374. targetProperty: string,
  26375. /**The frames per second of the animation */
  26376. framePerSecond: number,
  26377. /**The data type of the animation */
  26378. dataType: number,
  26379. /**The loop mode of the animation */
  26380. loopMode?: number | undefined,
  26381. /**Specifies if blending should be enabled */
  26382. enableBlending?: boolean | undefined);
  26383. /**
  26384. * Converts the animation to a string
  26385. * @param fullDetails support for multiple levels of logging within scene loading
  26386. * @returns String form of the animation
  26387. */
  26388. toString(fullDetails?: boolean): string;
  26389. /**
  26390. * Add an event to this animation
  26391. * @param event Event to add
  26392. */
  26393. addEvent(event: AnimationEvent): void;
  26394. /**
  26395. * Remove all events found at the given frame
  26396. * @param frame The frame to remove events from
  26397. */
  26398. removeEvents(frame: number): void;
  26399. /**
  26400. * Retrieves all the events from the animation
  26401. * @returns Events from the animation
  26402. */
  26403. getEvents(): AnimationEvent[];
  26404. /**
  26405. * Creates an animation range
  26406. * @param name Name of the animation range
  26407. * @param from Starting frame of the animation range
  26408. * @param to Ending frame of the animation
  26409. */
  26410. createRange(name: string, from: number, to: number): void;
  26411. /**
  26412. * Deletes an animation range by name
  26413. * @param name Name of the animation range to delete
  26414. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26415. */
  26416. deleteRange(name: string, deleteFrames?: boolean): void;
  26417. /**
  26418. * Gets the animation range by name, or null if not defined
  26419. * @param name Name of the animation range
  26420. * @returns Nullable animation range
  26421. */
  26422. getRange(name: string): Nullable<AnimationRange>;
  26423. /**
  26424. * Gets the key frames from the animation
  26425. * @returns The key frames of the animation
  26426. */
  26427. getKeys(): Array<IAnimationKey>;
  26428. /**
  26429. * Gets the highest frame rate of the animation
  26430. * @returns Highest frame rate of the animation
  26431. */
  26432. getHighestFrame(): number;
  26433. /**
  26434. * Gets the easing function of the animation
  26435. * @returns Easing function of the animation
  26436. */
  26437. getEasingFunction(): IEasingFunction;
  26438. /**
  26439. * Sets the easing function of the animation
  26440. * @param easingFunction A custom mathematical formula for animation
  26441. */
  26442. setEasingFunction(easingFunction: EasingFunction): void;
  26443. /**
  26444. * Interpolates a scalar linearly
  26445. * @param startValue Start value of the animation curve
  26446. * @param endValue End value of the animation curve
  26447. * @param gradient Scalar amount to interpolate
  26448. * @returns Interpolated scalar value
  26449. */
  26450. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26451. /**
  26452. * Interpolates a scalar cubically
  26453. * @param startValue Start value of the animation curve
  26454. * @param outTangent End tangent of the animation
  26455. * @param endValue End value of the animation curve
  26456. * @param inTangent Start tangent of the animation curve
  26457. * @param gradient Scalar amount to interpolate
  26458. * @returns Interpolated scalar value
  26459. */
  26460. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26461. /**
  26462. * Interpolates a quaternion using a spherical linear interpolation
  26463. * @param startValue Start value of the animation curve
  26464. * @param endValue End value of the animation curve
  26465. * @param gradient Scalar amount to interpolate
  26466. * @returns Interpolated quaternion value
  26467. */
  26468. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26469. /**
  26470. * Interpolates a quaternion cubically
  26471. * @param startValue Start value of the animation curve
  26472. * @param outTangent End tangent of the animation curve
  26473. * @param endValue End value of the animation curve
  26474. * @param inTangent Start tangent of the animation curve
  26475. * @param gradient Scalar amount to interpolate
  26476. * @returns Interpolated quaternion value
  26477. */
  26478. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26479. /**
  26480. * Interpolates a Vector3 linearl
  26481. * @param startValue Start value of the animation curve
  26482. * @param endValue End value of the animation curve
  26483. * @param gradient Scalar amount to interpolate
  26484. * @returns Interpolated scalar value
  26485. */
  26486. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26487. /**
  26488. * Interpolates a Vector3 cubically
  26489. * @param startValue Start value of the animation curve
  26490. * @param outTangent End tangent of the animation
  26491. * @param endValue End value of the animation curve
  26492. * @param inTangent Start tangent of the animation curve
  26493. * @param gradient Scalar amount to interpolate
  26494. * @returns InterpolatedVector3 value
  26495. */
  26496. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26497. /**
  26498. * Interpolates a Vector2 linearly
  26499. * @param startValue Start value of the animation curve
  26500. * @param endValue End value of the animation curve
  26501. * @param gradient Scalar amount to interpolate
  26502. * @returns Interpolated Vector2 value
  26503. */
  26504. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26505. /**
  26506. * Interpolates a Vector2 cubically
  26507. * @param startValue Start value of the animation curve
  26508. * @param outTangent End tangent of the animation
  26509. * @param endValue End value of the animation curve
  26510. * @param inTangent Start tangent of the animation curve
  26511. * @param gradient Scalar amount to interpolate
  26512. * @returns Interpolated Vector2 value
  26513. */
  26514. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26515. /**
  26516. * Interpolates a size linearly
  26517. * @param startValue Start value of the animation curve
  26518. * @param endValue End value of the animation curve
  26519. * @param gradient Scalar amount to interpolate
  26520. * @returns Interpolated Size value
  26521. */
  26522. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26523. /**
  26524. * Interpolates a Color3 linearly
  26525. * @param startValue Start value of the animation curve
  26526. * @param endValue End value of the animation curve
  26527. * @param gradient Scalar amount to interpolate
  26528. * @returns Interpolated Color3 value
  26529. */
  26530. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26531. /**
  26532. * @hidden Internal use only
  26533. */
  26534. _getKeyValue(value: any): any;
  26535. /**
  26536. * @hidden Internal use only
  26537. */
  26538. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26539. /**
  26540. * Defines the function to use to interpolate matrices
  26541. * @param startValue defines the start matrix
  26542. * @param endValue defines the end matrix
  26543. * @param gradient defines the gradient between both matrices
  26544. * @param result defines an optional target matrix where to store the interpolation
  26545. * @returns the interpolated matrix
  26546. */
  26547. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26548. /**
  26549. * Makes a copy of the animation
  26550. * @returns Cloned animation
  26551. */
  26552. clone(): Animation;
  26553. /**
  26554. * Sets the key frames of the animation
  26555. * @param values The animation key frames to set
  26556. */
  26557. setKeys(values: Array<IAnimationKey>): void;
  26558. /**
  26559. * Serializes the animation to an object
  26560. * @returns Serialized object
  26561. */
  26562. serialize(): any;
  26563. /**
  26564. * Float animation type
  26565. */
  26566. private static _ANIMATIONTYPE_FLOAT;
  26567. /**
  26568. * Vector3 animation type
  26569. */
  26570. private static _ANIMATIONTYPE_VECTOR3;
  26571. /**
  26572. * Quaternion animation type
  26573. */
  26574. private static _ANIMATIONTYPE_QUATERNION;
  26575. /**
  26576. * Matrix animation type
  26577. */
  26578. private static _ANIMATIONTYPE_MATRIX;
  26579. /**
  26580. * Color3 animation type
  26581. */
  26582. private static _ANIMATIONTYPE_COLOR3;
  26583. /**
  26584. * Vector2 animation type
  26585. */
  26586. private static _ANIMATIONTYPE_VECTOR2;
  26587. /**
  26588. * Size animation type
  26589. */
  26590. private static _ANIMATIONTYPE_SIZE;
  26591. /**
  26592. * Relative Loop Mode
  26593. */
  26594. private static _ANIMATIONLOOPMODE_RELATIVE;
  26595. /**
  26596. * Cycle Loop Mode
  26597. */
  26598. private static _ANIMATIONLOOPMODE_CYCLE;
  26599. /**
  26600. * Constant Loop Mode
  26601. */
  26602. private static _ANIMATIONLOOPMODE_CONSTANT;
  26603. /**
  26604. * Get the float animation type
  26605. */
  26606. static readonly ANIMATIONTYPE_FLOAT: number;
  26607. /**
  26608. * Get the Vector3 animation type
  26609. */
  26610. static readonly ANIMATIONTYPE_VECTOR3: number;
  26611. /**
  26612. * Get the Vector2 animation type
  26613. */
  26614. static readonly ANIMATIONTYPE_VECTOR2: number;
  26615. /**
  26616. * Get the Size animation type
  26617. */
  26618. static readonly ANIMATIONTYPE_SIZE: number;
  26619. /**
  26620. * Get the Quaternion animation type
  26621. */
  26622. static readonly ANIMATIONTYPE_QUATERNION: number;
  26623. /**
  26624. * Get the Matrix animation type
  26625. */
  26626. static readonly ANIMATIONTYPE_MATRIX: number;
  26627. /**
  26628. * Get the Color3 animation type
  26629. */
  26630. static readonly ANIMATIONTYPE_COLOR3: number;
  26631. /**
  26632. * Get the Relative Loop Mode
  26633. */
  26634. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26635. /**
  26636. * Get the Cycle Loop Mode
  26637. */
  26638. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26639. /**
  26640. * Get the Constant Loop Mode
  26641. */
  26642. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26643. /** @hidden */
  26644. static _UniversalLerp(left: any, right: any, amount: number): any;
  26645. /**
  26646. * Parses an animation object and creates an animation
  26647. * @param parsedAnimation Parsed animation object
  26648. * @returns Animation object
  26649. */
  26650. static Parse(parsedAnimation: any): Animation;
  26651. /**
  26652. * Appends the serialized animations from the source animations
  26653. * @param source Source containing the animations
  26654. * @param destination Target to store the animations
  26655. */
  26656. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26657. }
  26658. }
  26659. declare module "babylonjs/Materials/Textures/baseTexture" {
  26660. import { Observable } from "babylonjs/Misc/observable";
  26661. import { IAnimatable } from "babylonjs/Misc/tools";
  26662. import { Nullable } from "babylonjs/types";
  26663. import { Scene } from "babylonjs/scene";
  26664. import { Matrix, ISize } from "babylonjs/Maths/math";
  26665. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26666. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26667. /**
  26668. * Base class of all the textures in babylon.
  26669. * It groups all the common properties the materials, post process, lights... might need
  26670. * in order to make a correct use of the texture.
  26671. */
  26672. export class BaseTexture implements IAnimatable {
  26673. /**
  26674. * Default anisotropic filtering level for the application.
  26675. * It is set to 4 as a good tradeoff between perf and quality.
  26676. */
  26677. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26678. /**
  26679. * Gets or sets the unique id of the texture
  26680. */
  26681. uniqueId: number;
  26682. /**
  26683. * Define the name of the texture.
  26684. */
  26685. name: string;
  26686. /**
  26687. * Gets or sets an object used to store user defined information.
  26688. */
  26689. metadata: any;
  26690. /**
  26691. * For internal use only. Please do not use.
  26692. */
  26693. reservedDataStore: any;
  26694. private _hasAlpha;
  26695. /**
  26696. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26697. */
  26698. hasAlpha: boolean;
  26699. /**
  26700. * Defines if the alpha value should be determined via the rgb values.
  26701. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26702. */
  26703. getAlphaFromRGB: boolean;
  26704. /**
  26705. * Intensity or strength of the texture.
  26706. * It is commonly used by materials to fine tune the intensity of the texture
  26707. */
  26708. level: number;
  26709. /**
  26710. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26711. * This is part of the texture as textures usually maps to one uv set.
  26712. */
  26713. coordinatesIndex: number;
  26714. private _coordinatesMode;
  26715. /**
  26716. * How a texture is mapped.
  26717. *
  26718. * | Value | Type | Description |
  26719. * | ----- | ----------------------------------- | ----------- |
  26720. * | 0 | EXPLICIT_MODE | |
  26721. * | 1 | SPHERICAL_MODE | |
  26722. * | 2 | PLANAR_MODE | |
  26723. * | 3 | CUBIC_MODE | |
  26724. * | 4 | PROJECTION_MODE | |
  26725. * | 5 | SKYBOX_MODE | |
  26726. * | 6 | INVCUBIC_MODE | |
  26727. * | 7 | EQUIRECTANGULAR_MODE | |
  26728. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26729. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26730. */
  26731. coordinatesMode: number;
  26732. /**
  26733. * | Value | Type | Description |
  26734. * | ----- | ------------------ | ----------- |
  26735. * | 0 | CLAMP_ADDRESSMODE | |
  26736. * | 1 | WRAP_ADDRESSMODE | |
  26737. * | 2 | MIRROR_ADDRESSMODE | |
  26738. */
  26739. wrapU: number;
  26740. /**
  26741. * | Value | Type | Description |
  26742. * | ----- | ------------------ | ----------- |
  26743. * | 0 | CLAMP_ADDRESSMODE | |
  26744. * | 1 | WRAP_ADDRESSMODE | |
  26745. * | 2 | MIRROR_ADDRESSMODE | |
  26746. */
  26747. wrapV: number;
  26748. /**
  26749. * | Value | Type | Description |
  26750. * | ----- | ------------------ | ----------- |
  26751. * | 0 | CLAMP_ADDRESSMODE | |
  26752. * | 1 | WRAP_ADDRESSMODE | |
  26753. * | 2 | MIRROR_ADDRESSMODE | |
  26754. */
  26755. wrapR: number;
  26756. /**
  26757. * With compliant hardware and browser (supporting anisotropic filtering)
  26758. * this defines the level of anisotropic filtering in the texture.
  26759. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26760. */
  26761. anisotropicFilteringLevel: number;
  26762. /**
  26763. * Define if the texture is a cube texture or if false a 2d texture.
  26764. */
  26765. isCube: boolean;
  26766. /**
  26767. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26768. */
  26769. is3D: boolean;
  26770. /**
  26771. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26772. * HDR texture are usually stored in linear space.
  26773. * This only impacts the PBR and Background materials
  26774. */
  26775. gammaSpace: boolean;
  26776. /**
  26777. * Gets whether or not the texture contains RGBD data.
  26778. */
  26779. readonly isRGBD: boolean;
  26780. /**
  26781. * Is Z inverted in the texture (useful in a cube texture).
  26782. */
  26783. invertZ: boolean;
  26784. /**
  26785. * Are mip maps generated for this texture or not.
  26786. */
  26787. readonly noMipmap: boolean;
  26788. /**
  26789. * @hidden
  26790. */
  26791. lodLevelInAlpha: boolean;
  26792. /**
  26793. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26794. */
  26795. lodGenerationOffset: number;
  26796. /**
  26797. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26798. */
  26799. lodGenerationScale: number;
  26800. /**
  26801. * Define if the texture is a render target.
  26802. */
  26803. isRenderTarget: boolean;
  26804. /**
  26805. * Define the unique id of the texture in the scene.
  26806. */
  26807. readonly uid: string;
  26808. /**
  26809. * Return a string representation of the texture.
  26810. * @returns the texture as a string
  26811. */
  26812. toString(): string;
  26813. /**
  26814. * Get the class name of the texture.
  26815. * @returns "BaseTexture"
  26816. */
  26817. getClassName(): string;
  26818. /**
  26819. * Define the list of animation attached to the texture.
  26820. */
  26821. animations: import("babylonjs/Animations/animation").Animation[];
  26822. /**
  26823. * An event triggered when the texture is disposed.
  26824. */
  26825. onDisposeObservable: Observable<BaseTexture>;
  26826. private _onDisposeObserver;
  26827. /**
  26828. * Callback triggered when the texture has been disposed.
  26829. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26830. */
  26831. onDispose: () => void;
  26832. /**
  26833. * Define the current state of the loading sequence when in delayed load mode.
  26834. */
  26835. delayLoadState: number;
  26836. private _scene;
  26837. /** @hidden */
  26838. _texture: Nullable<InternalTexture>;
  26839. private _uid;
  26840. /**
  26841. * Define if the texture is preventinga material to render or not.
  26842. * If not and the texture is not ready, the engine will use a default black texture instead.
  26843. */
  26844. readonly isBlocking: boolean;
  26845. /**
  26846. * Instantiates a new BaseTexture.
  26847. * Base class of all the textures in babylon.
  26848. * It groups all the common properties the materials, post process, lights... might need
  26849. * in order to make a correct use of the texture.
  26850. * @param scene Define the scene the texture blongs to
  26851. */
  26852. constructor(scene: Nullable<Scene>);
  26853. /**
  26854. * Get the scene the texture belongs to.
  26855. * @returns the scene or null if undefined
  26856. */
  26857. getScene(): Nullable<Scene>;
  26858. /**
  26859. * Get the texture transform matrix used to offset tile the texture for istance.
  26860. * @returns the transformation matrix
  26861. */
  26862. getTextureMatrix(): Matrix;
  26863. /**
  26864. * Get the texture reflection matrix used to rotate/transform the reflection.
  26865. * @returns the reflection matrix
  26866. */
  26867. getReflectionTextureMatrix(): Matrix;
  26868. /**
  26869. * Get the underlying lower level texture from Babylon.
  26870. * @returns the insternal texture
  26871. */
  26872. getInternalTexture(): Nullable<InternalTexture>;
  26873. /**
  26874. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26875. * @returns true if ready or not blocking
  26876. */
  26877. isReadyOrNotBlocking(): boolean;
  26878. /**
  26879. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26880. * @returns true if fully ready
  26881. */
  26882. isReady(): boolean;
  26883. private _cachedSize;
  26884. /**
  26885. * Get the size of the texture.
  26886. * @returns the texture size.
  26887. */
  26888. getSize(): ISize;
  26889. /**
  26890. * Get the base size of the texture.
  26891. * It can be different from the size if the texture has been resized for POT for instance
  26892. * @returns the base size
  26893. */
  26894. getBaseSize(): ISize;
  26895. /**
  26896. * Update the sampling mode of the texture.
  26897. * Default is Trilinear mode.
  26898. *
  26899. * | Value | Type | Description |
  26900. * | ----- | ------------------ | ----------- |
  26901. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26902. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26903. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26904. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26905. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26906. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26907. * | 7 | NEAREST_LINEAR | |
  26908. * | 8 | NEAREST_NEAREST | |
  26909. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26910. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26911. * | 11 | LINEAR_LINEAR | |
  26912. * | 12 | LINEAR_NEAREST | |
  26913. *
  26914. * > _mag_: magnification filter (close to the viewer)
  26915. * > _min_: minification filter (far from the viewer)
  26916. * > _mip_: filter used between mip map levels
  26917. *@param samplingMode Define the new sampling mode of the texture
  26918. */
  26919. updateSamplingMode(samplingMode: number): void;
  26920. /**
  26921. * Scales the texture if is `canRescale()`
  26922. * @param ratio the resize factor we want to use to rescale
  26923. */
  26924. scale(ratio: number): void;
  26925. /**
  26926. * Get if the texture can rescale.
  26927. */
  26928. readonly canRescale: boolean;
  26929. /** @hidden */
  26930. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26931. /** @hidden */
  26932. _rebuild(): void;
  26933. /**
  26934. * Triggers the load sequence in delayed load mode.
  26935. */
  26936. delayLoad(): void;
  26937. /**
  26938. * Clones the texture.
  26939. * @returns the cloned texture
  26940. */
  26941. clone(): Nullable<BaseTexture>;
  26942. /**
  26943. * Get the texture underlying type (INT, FLOAT...)
  26944. */
  26945. readonly textureType: number;
  26946. /**
  26947. * Get the texture underlying format (RGB, RGBA...)
  26948. */
  26949. readonly textureFormat: number;
  26950. /**
  26951. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26952. * This will returns an RGBA array buffer containing either in values (0-255) or
  26953. * float values (0-1) depending of the underlying buffer type.
  26954. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26955. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26956. * @param buffer defines a user defined buffer to fill with data (can be null)
  26957. * @returns The Array buffer containing the pixels data.
  26958. */
  26959. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26960. /**
  26961. * Release and destroy the underlying lower level texture aka internalTexture.
  26962. */
  26963. releaseInternalTexture(): void;
  26964. /**
  26965. * Get the polynomial representation of the texture data.
  26966. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26967. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26968. */
  26969. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26970. /** @hidden */
  26971. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26972. /** @hidden */
  26973. readonly _lodTextureMid: Nullable<BaseTexture>;
  26974. /** @hidden */
  26975. readonly _lodTextureLow: Nullable<BaseTexture>;
  26976. /**
  26977. * Dispose the texture and release its associated resources.
  26978. */
  26979. dispose(): void;
  26980. /**
  26981. * Serialize the texture into a JSON representation that can be parsed later on.
  26982. * @returns the JSON representation of the texture
  26983. */
  26984. serialize(): any;
  26985. /**
  26986. * Helper function to be called back once a list of texture contains only ready textures.
  26987. * @param textures Define the list of textures to wait for
  26988. * @param callback Define the callback triggered once the entire list will be ready
  26989. */
  26990. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26991. }
  26992. }
  26993. declare module "babylonjs/Materials/uniformBuffer" {
  26994. import { Nullable, FloatArray } from "babylonjs/types";
  26995. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26996. import { Engine } from "babylonjs/Engines/engine";
  26997. import { Effect } from "babylonjs/Materials/effect";
  26998. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26999. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27000. /**
  27001. * Uniform buffer objects.
  27002. *
  27003. * Handles blocks of uniform on the GPU.
  27004. *
  27005. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27006. *
  27007. * For more information, please refer to :
  27008. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27009. */
  27010. export class UniformBuffer {
  27011. private _engine;
  27012. private _buffer;
  27013. private _data;
  27014. private _bufferData;
  27015. private _dynamic?;
  27016. private _uniformLocations;
  27017. private _uniformSizes;
  27018. private _uniformLocationPointer;
  27019. private _needSync;
  27020. private _noUBO;
  27021. private _currentEffect;
  27022. private static _MAX_UNIFORM_SIZE;
  27023. private static _tempBuffer;
  27024. /**
  27025. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27026. * This is dynamic to allow compat with webgl 1 and 2.
  27027. * You will need to pass the name of the uniform as well as the value.
  27028. */
  27029. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27030. /**
  27031. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27032. * This is dynamic to allow compat with webgl 1 and 2.
  27033. * You will need to pass the name of the uniform as well as the value.
  27034. */
  27035. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27036. /**
  27037. * Lambda to Update a single float in a uniform buffer.
  27038. * This is dynamic to allow compat with webgl 1 and 2.
  27039. * You will need to pass the name of the uniform as well as the value.
  27040. */
  27041. updateFloat: (name: string, x: number) => void;
  27042. /**
  27043. * Lambda to Update a vec2 of float in a uniform buffer.
  27044. * This is dynamic to allow compat with webgl 1 and 2.
  27045. * You will need to pass the name of the uniform as well as the value.
  27046. */
  27047. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27048. /**
  27049. * Lambda to Update a vec3 of float in a uniform buffer.
  27050. * This is dynamic to allow compat with webgl 1 and 2.
  27051. * You will need to pass the name of the uniform as well as the value.
  27052. */
  27053. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27054. /**
  27055. * Lambda to Update a vec4 of float in a uniform buffer.
  27056. * This is dynamic to allow compat with webgl 1 and 2.
  27057. * You will need to pass the name of the uniform as well as the value.
  27058. */
  27059. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27060. /**
  27061. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27062. * This is dynamic to allow compat with webgl 1 and 2.
  27063. * You will need to pass the name of the uniform as well as the value.
  27064. */
  27065. updateMatrix: (name: string, mat: Matrix) => void;
  27066. /**
  27067. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27068. * This is dynamic to allow compat with webgl 1 and 2.
  27069. * You will need to pass the name of the uniform as well as the value.
  27070. */
  27071. updateVector3: (name: string, vector: Vector3) => void;
  27072. /**
  27073. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27074. * This is dynamic to allow compat with webgl 1 and 2.
  27075. * You will need to pass the name of the uniform as well as the value.
  27076. */
  27077. updateVector4: (name: string, vector: Vector4) => void;
  27078. /**
  27079. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27080. * This is dynamic to allow compat with webgl 1 and 2.
  27081. * You will need to pass the name of the uniform as well as the value.
  27082. */
  27083. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27084. /**
  27085. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27086. * This is dynamic to allow compat with webgl 1 and 2.
  27087. * You will need to pass the name of the uniform as well as the value.
  27088. */
  27089. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27090. /**
  27091. * Instantiates a new Uniform buffer objects.
  27092. *
  27093. * Handles blocks of uniform on the GPU.
  27094. *
  27095. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27096. *
  27097. * For more information, please refer to :
  27098. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27099. * @param engine Define the engine the buffer is associated with
  27100. * @param data Define the data contained in the buffer
  27101. * @param dynamic Define if the buffer is updatable
  27102. */
  27103. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27104. /**
  27105. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27106. * or just falling back on setUniformXXX calls.
  27107. */
  27108. readonly useUbo: boolean;
  27109. /**
  27110. * Indicates if the WebGL underlying uniform buffer is in sync
  27111. * with the javascript cache data.
  27112. */
  27113. readonly isSync: boolean;
  27114. /**
  27115. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27116. * Also, a dynamic UniformBuffer will disable cache verification and always
  27117. * update the underlying WebGL uniform buffer to the GPU.
  27118. * @returns if Dynamic, otherwise false
  27119. */
  27120. isDynamic(): boolean;
  27121. /**
  27122. * The data cache on JS side.
  27123. * @returns the underlying data as a float array
  27124. */
  27125. getData(): Float32Array;
  27126. /**
  27127. * The underlying WebGL Uniform buffer.
  27128. * @returns the webgl buffer
  27129. */
  27130. getBuffer(): Nullable<DataBuffer>;
  27131. /**
  27132. * std140 layout specifies how to align data within an UBO structure.
  27133. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27134. * for specs.
  27135. */
  27136. private _fillAlignment;
  27137. /**
  27138. * Adds an uniform in the buffer.
  27139. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27140. * for the layout to be correct !
  27141. * @param name Name of the uniform, as used in the uniform block in the shader.
  27142. * @param size Data size, or data directly.
  27143. */
  27144. addUniform(name: string, size: number | number[]): void;
  27145. /**
  27146. * Adds a Matrix 4x4 to the uniform buffer.
  27147. * @param name Name of the uniform, as used in the uniform block in the shader.
  27148. * @param mat A 4x4 matrix.
  27149. */
  27150. addMatrix(name: string, mat: Matrix): void;
  27151. /**
  27152. * Adds a vec2 to the uniform buffer.
  27153. * @param name Name of the uniform, as used in the uniform block in the shader.
  27154. * @param x Define the x component value of the vec2
  27155. * @param y Define the y component value of the vec2
  27156. */
  27157. addFloat2(name: string, x: number, y: number): void;
  27158. /**
  27159. * Adds a vec3 to the uniform buffer.
  27160. * @param name Name of the uniform, as used in the uniform block in the shader.
  27161. * @param x Define the x component value of the vec3
  27162. * @param y Define the y component value of the vec3
  27163. * @param z Define the z component value of the vec3
  27164. */
  27165. addFloat3(name: string, x: number, y: number, z: number): void;
  27166. /**
  27167. * Adds a vec3 to the uniform buffer.
  27168. * @param name Name of the uniform, as used in the uniform block in the shader.
  27169. * @param color Define the vec3 from a Color
  27170. */
  27171. addColor3(name: string, color: Color3): void;
  27172. /**
  27173. * Adds a vec4 to the uniform buffer.
  27174. * @param name Name of the uniform, as used in the uniform block in the shader.
  27175. * @param color Define the rgb components from a Color
  27176. * @param alpha Define the a component of the vec4
  27177. */
  27178. addColor4(name: string, color: Color3, alpha: number): void;
  27179. /**
  27180. * Adds a vec3 to the uniform buffer.
  27181. * @param name Name of the uniform, as used in the uniform block in the shader.
  27182. * @param vector Define the vec3 components from a Vector
  27183. */
  27184. addVector3(name: string, vector: Vector3): void;
  27185. /**
  27186. * Adds a Matrix 3x3 to the uniform buffer.
  27187. * @param name Name of the uniform, as used in the uniform block in the shader.
  27188. */
  27189. addMatrix3x3(name: string): void;
  27190. /**
  27191. * Adds a Matrix 2x2 to the uniform buffer.
  27192. * @param name Name of the uniform, as used in the uniform block in the shader.
  27193. */
  27194. addMatrix2x2(name: string): void;
  27195. /**
  27196. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27197. */
  27198. create(): void;
  27199. /** @hidden */
  27200. _rebuild(): void;
  27201. /**
  27202. * Updates the WebGL Uniform Buffer on the GPU.
  27203. * If the `dynamic` flag is set to true, no cache comparison is done.
  27204. * Otherwise, the buffer will be updated only if the cache differs.
  27205. */
  27206. update(): void;
  27207. /**
  27208. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27209. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27210. * @param data Define the flattened data
  27211. * @param size Define the size of the data.
  27212. */
  27213. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27214. private _updateMatrix3x3ForUniform;
  27215. private _updateMatrix3x3ForEffect;
  27216. private _updateMatrix2x2ForEffect;
  27217. private _updateMatrix2x2ForUniform;
  27218. private _updateFloatForEffect;
  27219. private _updateFloatForUniform;
  27220. private _updateFloat2ForEffect;
  27221. private _updateFloat2ForUniform;
  27222. private _updateFloat3ForEffect;
  27223. private _updateFloat3ForUniform;
  27224. private _updateFloat4ForEffect;
  27225. private _updateFloat4ForUniform;
  27226. private _updateMatrixForEffect;
  27227. private _updateMatrixForUniform;
  27228. private _updateVector3ForEffect;
  27229. private _updateVector3ForUniform;
  27230. private _updateVector4ForEffect;
  27231. private _updateVector4ForUniform;
  27232. private _updateColor3ForEffect;
  27233. private _updateColor3ForUniform;
  27234. private _updateColor4ForEffect;
  27235. private _updateColor4ForUniform;
  27236. /**
  27237. * Sets a sampler uniform on the effect.
  27238. * @param name Define the name of the sampler.
  27239. * @param texture Define the texture to set in the sampler
  27240. */
  27241. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27242. /**
  27243. * Directly updates the value of the uniform in the cache AND on the GPU.
  27244. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27245. * @param data Define the flattened data
  27246. */
  27247. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27248. /**
  27249. * Binds this uniform buffer to an effect.
  27250. * @param effect Define the effect to bind the buffer to
  27251. * @param name Name of the uniform block in the shader.
  27252. */
  27253. bindToEffect(effect: Effect, name: string): void;
  27254. /**
  27255. * Disposes the uniform buffer.
  27256. */
  27257. dispose(): void;
  27258. }
  27259. }
  27260. declare module "babylonjs/Audio/analyser" {
  27261. import { Scene } from "babylonjs/scene";
  27262. /**
  27263. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27265. */
  27266. export class Analyser {
  27267. /**
  27268. * Gets or sets the smoothing
  27269. * @ignorenaming
  27270. */
  27271. SMOOTHING: number;
  27272. /**
  27273. * Gets or sets the FFT table size
  27274. * @ignorenaming
  27275. */
  27276. FFT_SIZE: number;
  27277. /**
  27278. * Gets or sets the bar graph amplitude
  27279. * @ignorenaming
  27280. */
  27281. BARGRAPHAMPLITUDE: number;
  27282. /**
  27283. * Gets or sets the position of the debug canvas
  27284. * @ignorenaming
  27285. */
  27286. DEBUGCANVASPOS: {
  27287. x: number;
  27288. y: number;
  27289. };
  27290. /**
  27291. * Gets or sets the debug canvas size
  27292. * @ignorenaming
  27293. */
  27294. DEBUGCANVASSIZE: {
  27295. width: number;
  27296. height: number;
  27297. };
  27298. private _byteFreqs;
  27299. private _byteTime;
  27300. private _floatFreqs;
  27301. private _webAudioAnalyser;
  27302. private _debugCanvas;
  27303. private _debugCanvasContext;
  27304. private _scene;
  27305. private _registerFunc;
  27306. private _audioEngine;
  27307. /**
  27308. * Creates a new analyser
  27309. * @param scene defines hosting scene
  27310. */
  27311. constructor(scene: Scene);
  27312. /**
  27313. * Get the number of data values you will have to play with for the visualization
  27314. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27315. * @returns a number
  27316. */
  27317. getFrequencyBinCount(): number;
  27318. /**
  27319. * Gets the current frequency data as a byte array
  27320. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27321. * @returns a Uint8Array
  27322. */
  27323. getByteFrequencyData(): Uint8Array;
  27324. /**
  27325. * Gets the current waveform as a byte array
  27326. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27327. * @returns a Uint8Array
  27328. */
  27329. getByteTimeDomainData(): Uint8Array;
  27330. /**
  27331. * Gets the current frequency data as a float array
  27332. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27333. * @returns a Float32Array
  27334. */
  27335. getFloatFrequencyData(): Float32Array;
  27336. /**
  27337. * Renders the debug canvas
  27338. */
  27339. drawDebugCanvas(): void;
  27340. /**
  27341. * Stops rendering the debug canvas and removes it
  27342. */
  27343. stopDebugCanvas(): void;
  27344. /**
  27345. * Connects two audio nodes
  27346. * @param inputAudioNode defines first node to connect
  27347. * @param outputAudioNode defines second node to connect
  27348. */
  27349. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27350. /**
  27351. * Releases all associated resources
  27352. */
  27353. dispose(): void;
  27354. }
  27355. }
  27356. declare module "babylonjs/Audio/audioEngine" {
  27357. import { IDisposable } from "babylonjs/scene";
  27358. import { Analyser } from "babylonjs/Audio/analyser";
  27359. import { Nullable } from "babylonjs/types";
  27360. import { Observable } from "babylonjs/Misc/observable";
  27361. /**
  27362. * This represents an audio engine and it is responsible
  27363. * to play, synchronize and analyse sounds throughout the application.
  27364. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27365. */
  27366. export interface IAudioEngine extends IDisposable {
  27367. /**
  27368. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27369. */
  27370. readonly canUseWebAudio: boolean;
  27371. /**
  27372. * Gets the current AudioContext if available.
  27373. */
  27374. readonly audioContext: Nullable<AudioContext>;
  27375. /**
  27376. * The master gain node defines the global audio volume of your audio engine.
  27377. */
  27378. readonly masterGain: GainNode;
  27379. /**
  27380. * Gets whether or not mp3 are supported by your browser.
  27381. */
  27382. readonly isMP3supported: boolean;
  27383. /**
  27384. * Gets whether or not ogg are supported by your browser.
  27385. */
  27386. readonly isOGGsupported: boolean;
  27387. /**
  27388. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27389. * @ignoreNaming
  27390. */
  27391. WarnedWebAudioUnsupported: boolean;
  27392. /**
  27393. * Defines if the audio engine relies on a custom unlocked button.
  27394. * In this case, the embedded button will not be displayed.
  27395. */
  27396. useCustomUnlockedButton: boolean;
  27397. /**
  27398. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27399. */
  27400. readonly unlocked: boolean;
  27401. /**
  27402. * Event raised when audio has been unlocked on the browser.
  27403. */
  27404. onAudioUnlockedObservable: Observable<AudioEngine>;
  27405. /**
  27406. * Event raised when audio has been locked on the browser.
  27407. */
  27408. onAudioLockedObservable: Observable<AudioEngine>;
  27409. /**
  27410. * Flags the audio engine in Locked state.
  27411. * This happens due to new browser policies preventing audio to autoplay.
  27412. */
  27413. lock(): void;
  27414. /**
  27415. * Unlocks the audio engine once a user action has been done on the dom.
  27416. * This is helpful to resume play once browser policies have been satisfied.
  27417. */
  27418. unlock(): void;
  27419. }
  27420. /**
  27421. * This represents the default audio engine used in babylon.
  27422. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27424. */
  27425. export class AudioEngine implements IAudioEngine {
  27426. private _audioContext;
  27427. private _audioContextInitialized;
  27428. private _muteButton;
  27429. private _hostElement;
  27430. /**
  27431. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27432. */
  27433. canUseWebAudio: boolean;
  27434. /**
  27435. * The master gain node defines the global audio volume of your audio engine.
  27436. */
  27437. masterGain: GainNode;
  27438. /**
  27439. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27440. * @ignoreNaming
  27441. */
  27442. WarnedWebAudioUnsupported: boolean;
  27443. /**
  27444. * Gets whether or not mp3 are supported by your browser.
  27445. */
  27446. isMP3supported: boolean;
  27447. /**
  27448. * Gets whether or not ogg are supported by your browser.
  27449. */
  27450. isOGGsupported: boolean;
  27451. /**
  27452. * Gets whether audio has been unlocked on the device.
  27453. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27454. * a user interaction has happened.
  27455. */
  27456. unlocked: boolean;
  27457. /**
  27458. * Defines if the audio engine relies on a custom unlocked button.
  27459. * In this case, the embedded button will not be displayed.
  27460. */
  27461. useCustomUnlockedButton: boolean;
  27462. /**
  27463. * Event raised when audio has been unlocked on the browser.
  27464. */
  27465. onAudioUnlockedObservable: Observable<AudioEngine>;
  27466. /**
  27467. * Event raised when audio has been locked on the browser.
  27468. */
  27469. onAudioLockedObservable: Observable<AudioEngine>;
  27470. /**
  27471. * Gets the current AudioContext if available.
  27472. */
  27473. readonly audioContext: Nullable<AudioContext>;
  27474. private _connectedAnalyser;
  27475. /**
  27476. * Instantiates a new audio engine.
  27477. *
  27478. * There should be only one per page as some browsers restrict the number
  27479. * of audio contexts you can create.
  27480. * @param hostElement defines the host element where to display the mute icon if necessary
  27481. */
  27482. constructor(hostElement?: Nullable<HTMLElement>);
  27483. /**
  27484. * Flags the audio engine in Locked state.
  27485. * This happens due to new browser policies preventing audio to autoplay.
  27486. */
  27487. lock(): void;
  27488. /**
  27489. * Unlocks the audio engine once a user action has been done on the dom.
  27490. * This is helpful to resume play once browser policies have been satisfied.
  27491. */
  27492. unlock(): void;
  27493. private _resumeAudioContext;
  27494. private _initializeAudioContext;
  27495. private _tryToRun;
  27496. private _triggerRunningState;
  27497. private _triggerSuspendedState;
  27498. private _displayMuteButton;
  27499. private _moveButtonToTopLeft;
  27500. private _onResize;
  27501. private _hideMuteButton;
  27502. /**
  27503. * Destroy and release the resources associated with the audio ccontext.
  27504. */
  27505. dispose(): void;
  27506. /**
  27507. * Gets the global volume sets on the master gain.
  27508. * @returns the global volume if set or -1 otherwise
  27509. */
  27510. getGlobalVolume(): number;
  27511. /**
  27512. * Sets the global volume of your experience (sets on the master gain).
  27513. * @param newVolume Defines the new global volume of the application
  27514. */
  27515. setGlobalVolume(newVolume: number): void;
  27516. /**
  27517. * Connect the audio engine to an audio analyser allowing some amazing
  27518. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27520. * @param analyser The analyser to connect to the engine
  27521. */
  27522. connectToAnalyser(analyser: Analyser): void;
  27523. }
  27524. }
  27525. declare module "babylonjs/Loading/loadingScreen" {
  27526. /**
  27527. * Interface used to present a loading screen while loading a scene
  27528. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27529. */
  27530. export interface ILoadingScreen {
  27531. /**
  27532. * Function called to display the loading screen
  27533. */
  27534. displayLoadingUI: () => void;
  27535. /**
  27536. * Function called to hide the loading screen
  27537. */
  27538. hideLoadingUI: () => void;
  27539. /**
  27540. * Gets or sets the color to use for the background
  27541. */
  27542. loadingUIBackgroundColor: string;
  27543. /**
  27544. * Gets or sets the text to display while loading
  27545. */
  27546. loadingUIText: string;
  27547. }
  27548. /**
  27549. * Class used for the default loading screen
  27550. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27551. */
  27552. export class DefaultLoadingScreen implements ILoadingScreen {
  27553. private _renderingCanvas;
  27554. private _loadingText;
  27555. private _loadingDivBackgroundColor;
  27556. private _loadingDiv;
  27557. private _loadingTextDiv;
  27558. /**
  27559. * Creates a new default loading screen
  27560. * @param _renderingCanvas defines the canvas used to render the scene
  27561. * @param _loadingText defines the default text to display
  27562. * @param _loadingDivBackgroundColor defines the default background color
  27563. */
  27564. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27565. /**
  27566. * Function called to display the loading screen
  27567. */
  27568. displayLoadingUI(): void;
  27569. /**
  27570. * Function called to hide the loading screen
  27571. */
  27572. hideLoadingUI(): void;
  27573. /**
  27574. * Gets or sets the text to display while loading
  27575. */
  27576. loadingUIText: string;
  27577. /**
  27578. * Gets or sets the color to use for the background
  27579. */
  27580. loadingUIBackgroundColor: string;
  27581. private _resizeLoadingUI;
  27582. }
  27583. }
  27584. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27585. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27586. import { Engine } from "babylonjs/Engines/engine";
  27587. import { Nullable } from "babylonjs/types";
  27588. /** @hidden */
  27589. export class WebGLPipelineContext implements IPipelineContext {
  27590. engine: Engine;
  27591. program: Nullable<WebGLProgram>;
  27592. context?: WebGLRenderingContext;
  27593. vertexShader?: WebGLShader;
  27594. fragmentShader?: WebGLShader;
  27595. isParallelCompiled: boolean;
  27596. onCompiled?: () => void;
  27597. transformFeedback?: WebGLTransformFeedback | null;
  27598. readonly isAsync: boolean;
  27599. readonly isReady: boolean;
  27600. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27601. }
  27602. }
  27603. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27604. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27605. /** @hidden */
  27606. export class WebGLDataBuffer extends DataBuffer {
  27607. private _buffer;
  27608. constructor(resource: WebGLBuffer);
  27609. readonly underlyingResource: any;
  27610. }
  27611. }
  27612. declare module "babylonjs/Materials/Textures/videoTexture" {
  27613. import { Observable } from "babylonjs/Misc/observable";
  27614. import { Nullable } from "babylonjs/types";
  27615. import { Scene } from "babylonjs/scene";
  27616. import { Texture } from "babylonjs/Materials/Textures/texture";
  27617. /**
  27618. * Settings for finer control over video usage
  27619. */
  27620. export interface VideoTextureSettings {
  27621. /**
  27622. * Applies `autoplay` to video, if specified
  27623. */
  27624. autoPlay?: boolean;
  27625. /**
  27626. * Applies `loop` to video, if specified
  27627. */
  27628. loop?: boolean;
  27629. /**
  27630. * Automatically updates internal texture from video at every frame in the render loop
  27631. */
  27632. autoUpdateTexture: boolean;
  27633. /**
  27634. * Image src displayed during the video loading or until the user interacts with the video.
  27635. */
  27636. poster?: string;
  27637. }
  27638. /**
  27639. * If you want to display a video in your scene, this is the special texture for that.
  27640. * This special texture works similar to other textures, with the exception of a few parameters.
  27641. * @see https://doc.babylonjs.com/how_to/video_texture
  27642. */
  27643. export class VideoTexture extends Texture {
  27644. /**
  27645. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27646. */
  27647. readonly autoUpdateTexture: boolean;
  27648. /**
  27649. * The video instance used by the texture internally
  27650. */
  27651. readonly video: HTMLVideoElement;
  27652. private _onUserActionRequestedObservable;
  27653. /**
  27654. * Event triggerd when a dom action is required by the user to play the video.
  27655. * This happens due to recent changes in browser policies preventing video to auto start.
  27656. */
  27657. readonly onUserActionRequestedObservable: Observable<Texture>;
  27658. private _generateMipMaps;
  27659. private _engine;
  27660. private _stillImageCaptured;
  27661. private _displayingPosterTexture;
  27662. private _settings;
  27663. private _createInternalTextureOnEvent;
  27664. /**
  27665. * Creates a video texture.
  27666. * If you want to display a video in your scene, this is the special texture for that.
  27667. * This special texture works similar to other textures, with the exception of a few parameters.
  27668. * @see https://doc.babylonjs.com/how_to/video_texture
  27669. * @param name optional name, will detect from video source, if not defined
  27670. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27671. * @param scene is obviously the current scene.
  27672. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27673. * @param invertY is false by default but can be used to invert video on Y axis
  27674. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27675. * @param settings allows finer control over video usage
  27676. */
  27677. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27678. private _getName;
  27679. private _getVideo;
  27680. private _createInternalTexture;
  27681. private reset;
  27682. /**
  27683. * @hidden Internal method to initiate `update`.
  27684. */
  27685. _rebuild(): void;
  27686. /**
  27687. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27688. */
  27689. update(): void;
  27690. /**
  27691. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27692. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27693. */
  27694. updateTexture(isVisible: boolean): void;
  27695. protected _updateInternalTexture: () => void;
  27696. /**
  27697. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27698. * @param url New url.
  27699. */
  27700. updateURL(url: string): void;
  27701. /**
  27702. * Dispose the texture and release its associated resources.
  27703. */
  27704. dispose(): void;
  27705. /**
  27706. * Creates a video texture straight from a stream.
  27707. * @param scene Define the scene the texture should be created in
  27708. * @param stream Define the stream the texture should be created from
  27709. * @returns The created video texture as a promise
  27710. */
  27711. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27712. /**
  27713. * Creates a video texture straight from your WebCam video feed.
  27714. * @param scene Define the scene the texture should be created in
  27715. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27716. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27717. * @returns The created video texture as a promise
  27718. */
  27719. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27720. minWidth: number;
  27721. maxWidth: number;
  27722. minHeight: number;
  27723. maxHeight: number;
  27724. deviceId: string;
  27725. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27726. /**
  27727. * Creates a video texture straight from your WebCam video feed.
  27728. * @param scene Define the scene the texture should be created in
  27729. * @param onReady Define a callback to triggered once the texture will be ready
  27730. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27731. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27732. */
  27733. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27734. minWidth: number;
  27735. maxWidth: number;
  27736. minHeight: number;
  27737. maxHeight: number;
  27738. deviceId: string;
  27739. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27740. }
  27741. }
  27742. declare module "babylonjs/Engines/engine" {
  27743. import { Observable } from "babylonjs/Misc/observable";
  27744. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27745. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27746. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27747. import { Camera } from "babylonjs/Cameras/camera";
  27748. import { Scene } from "babylonjs/scene";
  27749. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27750. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27751. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27752. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27753. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27754. import { Material } from "babylonjs/Materials/material";
  27755. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27756. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27757. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27758. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27759. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27760. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27761. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27762. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27763. import { WebRequest } from "babylonjs/Misc/webRequest";
  27764. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27765. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27766. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27767. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27768. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27769. /**
  27770. * Interface for attribute information associated with buffer instanciation
  27771. */
  27772. export class InstancingAttributeInfo {
  27773. /**
  27774. * Index/offset of the attribute in the vertex shader
  27775. */
  27776. index: number;
  27777. /**
  27778. * size of the attribute, 1, 2, 3 or 4
  27779. */
  27780. attributeSize: number;
  27781. /**
  27782. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27783. * default is FLOAT
  27784. */
  27785. attribyteType: number;
  27786. /**
  27787. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27788. */
  27789. normalized: boolean;
  27790. /**
  27791. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27792. */
  27793. offset: number;
  27794. /**
  27795. * Name of the GLSL attribute, for debugging purpose only
  27796. */
  27797. attributeName: string;
  27798. }
  27799. /**
  27800. * Define options used to create a depth texture
  27801. */
  27802. export class DepthTextureCreationOptions {
  27803. /** Specifies whether or not a stencil should be allocated in the texture */
  27804. generateStencil?: boolean;
  27805. /** Specifies whether or not bilinear filtering is enable on the texture */
  27806. bilinearFiltering?: boolean;
  27807. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27808. comparisonFunction?: number;
  27809. /** Specifies if the created texture is a cube texture */
  27810. isCube?: boolean;
  27811. }
  27812. /**
  27813. * Class used to describe the capabilities of the engine relatively to the current browser
  27814. */
  27815. export class EngineCapabilities {
  27816. /** Maximum textures units per fragment shader */
  27817. maxTexturesImageUnits: number;
  27818. /** Maximum texture units per vertex shader */
  27819. maxVertexTextureImageUnits: number;
  27820. /** Maximum textures units in the entire pipeline */
  27821. maxCombinedTexturesImageUnits: number;
  27822. /** Maximum texture size */
  27823. maxTextureSize: number;
  27824. /** Maximum cube texture size */
  27825. maxCubemapTextureSize: number;
  27826. /** Maximum render texture size */
  27827. maxRenderTextureSize: number;
  27828. /** Maximum number of vertex attributes */
  27829. maxVertexAttribs: number;
  27830. /** Maximum number of varyings */
  27831. maxVaryingVectors: number;
  27832. /** Maximum number of uniforms per vertex shader */
  27833. maxVertexUniformVectors: number;
  27834. /** Maximum number of uniforms per fragment shader */
  27835. maxFragmentUniformVectors: number;
  27836. /** Defines if standard derivates (dx/dy) are supported */
  27837. standardDerivatives: boolean;
  27838. /** Defines if s3tc texture compression is supported */
  27839. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27840. /** Defines if pvrtc texture compression is supported */
  27841. pvrtc: any;
  27842. /** Defines if etc1 texture compression is supported */
  27843. etc1: any;
  27844. /** Defines if etc2 texture compression is supported */
  27845. etc2: any;
  27846. /** Defines if astc texture compression is supported */
  27847. astc: any;
  27848. /** Defines if float textures are supported */
  27849. textureFloat: boolean;
  27850. /** Defines if vertex array objects are supported */
  27851. vertexArrayObject: boolean;
  27852. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27853. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27854. /** Gets the maximum level of anisotropy supported */
  27855. maxAnisotropy: number;
  27856. /** Defines if instancing is supported */
  27857. instancedArrays: boolean;
  27858. /** Defines if 32 bits indices are supported */
  27859. uintIndices: boolean;
  27860. /** Defines if high precision shaders are supported */
  27861. highPrecisionShaderSupported: boolean;
  27862. /** Defines if depth reading in the fragment shader is supported */
  27863. fragmentDepthSupported: boolean;
  27864. /** Defines if float texture linear filtering is supported*/
  27865. textureFloatLinearFiltering: boolean;
  27866. /** Defines if rendering to float textures is supported */
  27867. textureFloatRender: boolean;
  27868. /** Defines if half float textures are supported*/
  27869. textureHalfFloat: boolean;
  27870. /** Defines if half float texture linear filtering is supported*/
  27871. textureHalfFloatLinearFiltering: boolean;
  27872. /** Defines if rendering to half float textures is supported */
  27873. textureHalfFloatRender: boolean;
  27874. /** Defines if textureLOD shader command is supported */
  27875. textureLOD: boolean;
  27876. /** Defines if draw buffers extension is supported */
  27877. drawBuffersExtension: boolean;
  27878. /** Defines if depth textures are supported */
  27879. depthTextureExtension: boolean;
  27880. /** Defines if float color buffer are supported */
  27881. colorBufferFloat: boolean;
  27882. /** Gets disjoint timer query extension (null if not supported) */
  27883. timerQuery: EXT_disjoint_timer_query;
  27884. /** Defines if timestamp can be used with timer query */
  27885. canUseTimestampForTimerQuery: boolean;
  27886. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27887. multiview: any;
  27888. /** Function used to let the system compiles shaders in background */
  27889. parallelShaderCompile: {
  27890. COMPLETION_STATUS_KHR: number;
  27891. };
  27892. }
  27893. /** Interface defining initialization parameters for Engine class */
  27894. export interface EngineOptions extends WebGLContextAttributes {
  27895. /**
  27896. * Defines if the engine should no exceed a specified device ratio
  27897. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27898. */
  27899. limitDeviceRatio?: number;
  27900. /**
  27901. * Defines if webvr should be enabled automatically
  27902. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27903. */
  27904. autoEnableWebVR?: boolean;
  27905. /**
  27906. * Defines if webgl2 should be turned off even if supported
  27907. * @see http://doc.babylonjs.com/features/webgl2
  27908. */
  27909. disableWebGL2Support?: boolean;
  27910. /**
  27911. * Defines if webaudio should be initialized as well
  27912. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27913. */
  27914. audioEngine?: boolean;
  27915. /**
  27916. * Defines if animations should run using a deterministic lock step
  27917. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27918. */
  27919. deterministicLockstep?: boolean;
  27920. /** Defines the maximum steps to use with deterministic lock step mode */
  27921. lockstepMaxSteps?: number;
  27922. /**
  27923. * Defines that engine should ignore context lost events
  27924. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27925. */
  27926. doNotHandleContextLost?: boolean;
  27927. /**
  27928. * Defines that engine should ignore modifying touch action attribute and style
  27929. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27930. */
  27931. doNotHandleTouchAction?: boolean;
  27932. /**
  27933. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27934. */
  27935. useHighPrecisionFloats?: boolean;
  27936. }
  27937. /**
  27938. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27939. */
  27940. export class Engine {
  27941. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27942. static ExceptionList: ({
  27943. key: string;
  27944. capture: string;
  27945. captureConstraint: number;
  27946. targets: string[];
  27947. } | {
  27948. key: string;
  27949. capture: null;
  27950. captureConstraint: null;
  27951. targets: string[];
  27952. })[];
  27953. /** Gets the list of created engines */
  27954. static readonly Instances: Engine[];
  27955. /**
  27956. * Gets the latest created engine
  27957. */
  27958. static readonly LastCreatedEngine: Nullable<Engine>;
  27959. /**
  27960. * Gets the latest created scene
  27961. */
  27962. static readonly LastCreatedScene: Nullable<Scene>;
  27963. /**
  27964. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27965. * @param flag defines which part of the materials must be marked as dirty
  27966. * @param predicate defines a predicate used to filter which materials should be affected
  27967. */
  27968. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27969. /**
  27970. * Hidden
  27971. */
  27972. static _TextureLoaders: IInternalTextureLoader[];
  27973. /** Defines that alpha blending is disabled */
  27974. static readonly ALPHA_DISABLE: number;
  27975. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27976. static readonly ALPHA_ADD: number;
  27977. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27978. static readonly ALPHA_COMBINE: number;
  27979. /** Defines that alpha blending to DEST - SRC * DEST */
  27980. static readonly ALPHA_SUBTRACT: number;
  27981. /** Defines that alpha blending to SRC * DEST */
  27982. static readonly ALPHA_MULTIPLY: number;
  27983. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27984. static readonly ALPHA_MAXIMIZED: number;
  27985. /** Defines that alpha blending to SRC + DEST */
  27986. static readonly ALPHA_ONEONE: number;
  27987. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27988. static readonly ALPHA_PREMULTIPLIED: number;
  27989. /**
  27990. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27991. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27992. */
  27993. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27994. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27995. static readonly ALPHA_INTERPOLATE: number;
  27996. /**
  27997. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27998. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27999. */
  28000. static readonly ALPHA_SCREENMODE: number;
  28001. /** Defines that the ressource is not delayed*/
  28002. static readonly DELAYLOADSTATE_NONE: number;
  28003. /** Defines that the ressource was successfully delay loaded */
  28004. static readonly DELAYLOADSTATE_LOADED: number;
  28005. /** Defines that the ressource is currently delay loading */
  28006. static readonly DELAYLOADSTATE_LOADING: number;
  28007. /** Defines that the ressource is delayed and has not started loading */
  28008. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28009. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28010. static readonly NEVER: number;
  28011. /** 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 */
  28012. static readonly ALWAYS: number;
  28013. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28014. static readonly LESS: number;
  28015. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28016. static readonly EQUAL: number;
  28017. /** 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 */
  28018. static readonly LEQUAL: number;
  28019. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28020. static readonly GREATER: number;
  28021. /** 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 */
  28022. static readonly GEQUAL: number;
  28023. /** 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 */
  28024. static readonly NOTEQUAL: number;
  28025. /** Passed to stencilOperation to specify that stencil value must be kept */
  28026. static readonly KEEP: number;
  28027. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28028. static readonly REPLACE: number;
  28029. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28030. static readonly INCR: number;
  28031. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28032. static readonly DECR: number;
  28033. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28034. static readonly INVERT: number;
  28035. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28036. static readonly INCR_WRAP: number;
  28037. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28038. static readonly DECR_WRAP: number;
  28039. /** Texture is not repeating outside of 0..1 UVs */
  28040. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28041. /** Texture is repeating outside of 0..1 UVs */
  28042. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28043. /** Texture is repeating and mirrored */
  28044. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28045. /** ALPHA */
  28046. static readonly TEXTUREFORMAT_ALPHA: number;
  28047. /** LUMINANCE */
  28048. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28049. /** LUMINANCE_ALPHA */
  28050. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28051. /** RGB */
  28052. static readonly TEXTUREFORMAT_RGB: number;
  28053. /** RGBA */
  28054. static readonly TEXTUREFORMAT_RGBA: number;
  28055. /** RED */
  28056. static readonly TEXTUREFORMAT_RED: number;
  28057. /** RED (2nd reference) */
  28058. static readonly TEXTUREFORMAT_R: number;
  28059. /** RG */
  28060. static readonly TEXTUREFORMAT_RG: number;
  28061. /** RED_INTEGER */
  28062. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28063. /** RED_INTEGER (2nd reference) */
  28064. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28065. /** RG_INTEGER */
  28066. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28067. /** RGB_INTEGER */
  28068. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28069. /** RGBA_INTEGER */
  28070. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28071. /** UNSIGNED_BYTE */
  28072. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28073. /** UNSIGNED_BYTE (2nd reference) */
  28074. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28075. /** FLOAT */
  28076. static readonly TEXTURETYPE_FLOAT: number;
  28077. /** HALF_FLOAT */
  28078. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28079. /** BYTE */
  28080. static readonly TEXTURETYPE_BYTE: number;
  28081. /** SHORT */
  28082. static readonly TEXTURETYPE_SHORT: number;
  28083. /** UNSIGNED_SHORT */
  28084. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28085. /** INT */
  28086. static readonly TEXTURETYPE_INT: number;
  28087. /** UNSIGNED_INT */
  28088. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28089. /** UNSIGNED_SHORT_4_4_4_4 */
  28090. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28091. /** UNSIGNED_SHORT_5_5_5_1 */
  28092. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28093. /** UNSIGNED_SHORT_5_6_5 */
  28094. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28095. /** UNSIGNED_INT_2_10_10_10_REV */
  28096. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28097. /** UNSIGNED_INT_24_8 */
  28098. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28099. /** UNSIGNED_INT_10F_11F_11F_REV */
  28100. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28101. /** UNSIGNED_INT_5_9_9_9_REV */
  28102. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28103. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28104. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28105. /** nearest is mag = nearest and min = nearest and mip = linear */
  28106. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28107. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28108. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28109. /** Trilinear is mag = linear and min = linear and mip = linear */
  28110. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28111. /** nearest is mag = nearest and min = nearest and mip = linear */
  28112. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28113. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28114. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28115. /** Trilinear is mag = linear and min = linear and mip = linear */
  28116. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28117. /** mag = nearest and min = nearest and mip = nearest */
  28118. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28119. /** mag = nearest and min = linear and mip = nearest */
  28120. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28121. /** mag = nearest and min = linear and mip = linear */
  28122. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28123. /** mag = nearest and min = linear and mip = none */
  28124. static readonly TEXTURE_NEAREST_LINEAR: number;
  28125. /** mag = nearest and min = nearest and mip = none */
  28126. static readonly TEXTURE_NEAREST_NEAREST: number;
  28127. /** mag = linear and min = nearest and mip = nearest */
  28128. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28129. /** mag = linear and min = nearest and mip = linear */
  28130. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28131. /** mag = linear and min = linear and mip = none */
  28132. static readonly TEXTURE_LINEAR_LINEAR: number;
  28133. /** mag = linear and min = nearest and mip = none */
  28134. static readonly TEXTURE_LINEAR_NEAREST: number;
  28135. /** Explicit coordinates mode */
  28136. static readonly TEXTURE_EXPLICIT_MODE: number;
  28137. /** Spherical coordinates mode */
  28138. static readonly TEXTURE_SPHERICAL_MODE: number;
  28139. /** Planar coordinates mode */
  28140. static readonly TEXTURE_PLANAR_MODE: number;
  28141. /** Cubic coordinates mode */
  28142. static readonly TEXTURE_CUBIC_MODE: number;
  28143. /** Projection coordinates mode */
  28144. static readonly TEXTURE_PROJECTION_MODE: number;
  28145. /** Skybox coordinates mode */
  28146. static readonly TEXTURE_SKYBOX_MODE: number;
  28147. /** Inverse Cubic coordinates mode */
  28148. static readonly TEXTURE_INVCUBIC_MODE: number;
  28149. /** Equirectangular coordinates mode */
  28150. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28151. /** Equirectangular Fixed coordinates mode */
  28152. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28153. /** Equirectangular Fixed Mirrored coordinates mode */
  28154. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28155. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28156. static readonly SCALEMODE_FLOOR: number;
  28157. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28158. static readonly SCALEMODE_NEAREST: number;
  28159. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28160. static readonly SCALEMODE_CEILING: number;
  28161. /**
  28162. * Returns the current npm package of the sdk
  28163. */
  28164. static readonly NpmPackage: string;
  28165. /**
  28166. * Returns the current version of the framework
  28167. */
  28168. static readonly Version: string;
  28169. /**
  28170. * Returns a string describing the current engine
  28171. */
  28172. readonly description: string;
  28173. /**
  28174. * Gets or sets the epsilon value used by collision engine
  28175. */
  28176. static CollisionsEpsilon: number;
  28177. /**
  28178. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28179. */
  28180. static ShadersRepository: string;
  28181. /**
  28182. * Method called to create the default loading screen.
  28183. * This can be overriden in your own app.
  28184. * @param canvas The rendering canvas element
  28185. * @returns The loading screen
  28186. */
  28187. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28188. /**
  28189. * Method called to create the default rescale post process on each engine.
  28190. */
  28191. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28192. /**
  28193. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28194. */
  28195. forcePOTTextures: boolean;
  28196. /**
  28197. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28198. */
  28199. isFullscreen: boolean;
  28200. /**
  28201. * Gets a boolean indicating if the pointer is currently locked
  28202. */
  28203. isPointerLock: boolean;
  28204. /**
  28205. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28206. */
  28207. cullBackFaces: boolean;
  28208. /**
  28209. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28210. */
  28211. renderEvenInBackground: boolean;
  28212. /**
  28213. * Gets or sets a boolean indicating that cache can be kept between frames
  28214. */
  28215. preventCacheWipeBetweenFrames: boolean;
  28216. /**
  28217. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28218. **/
  28219. enableOfflineSupport: boolean;
  28220. /**
  28221. * 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)
  28222. **/
  28223. disableManifestCheck: boolean;
  28224. /**
  28225. * Gets the list of created scenes
  28226. */
  28227. scenes: Scene[];
  28228. /**
  28229. * Event raised when a new scene is created
  28230. */
  28231. onNewSceneAddedObservable: Observable<Scene>;
  28232. /**
  28233. * Gets the list of created postprocesses
  28234. */
  28235. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28236. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28237. validateShaderPrograms: boolean;
  28238. /**
  28239. * Observable event triggered each time the rendering canvas is resized
  28240. */
  28241. onResizeObservable: Observable<Engine>;
  28242. /**
  28243. * Observable event triggered each time the canvas loses focus
  28244. */
  28245. onCanvasBlurObservable: Observable<Engine>;
  28246. /**
  28247. * Observable event triggered each time the canvas gains focus
  28248. */
  28249. onCanvasFocusObservable: Observable<Engine>;
  28250. /**
  28251. * Observable event triggered each time the canvas receives pointerout event
  28252. */
  28253. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28254. /**
  28255. * Observable event triggered before each texture is initialized
  28256. */
  28257. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28258. /**
  28259. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28260. */
  28261. disableUniformBuffers: boolean;
  28262. /** @hidden */
  28263. _uniformBuffers: UniformBuffer[];
  28264. /**
  28265. * Gets a boolean indicating that the engine supports uniform buffers
  28266. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28267. */
  28268. readonly supportsUniformBuffers: boolean;
  28269. /**
  28270. * Observable raised when the engine begins a new frame
  28271. */
  28272. onBeginFrameObservable: Observable<Engine>;
  28273. /**
  28274. * If set, will be used to request the next animation frame for the render loop
  28275. */
  28276. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28277. /**
  28278. * Observable raised when the engine ends the current frame
  28279. */
  28280. onEndFrameObservable: Observable<Engine>;
  28281. /**
  28282. * Observable raised when the engine is about to compile a shader
  28283. */
  28284. onBeforeShaderCompilationObservable: Observable<Engine>;
  28285. /**
  28286. * Observable raised when the engine has jsut compiled a shader
  28287. */
  28288. onAfterShaderCompilationObservable: Observable<Engine>;
  28289. /** @hidden */
  28290. _gl: WebGLRenderingContext;
  28291. private _renderingCanvas;
  28292. private _windowIsBackground;
  28293. private _webGLVersion;
  28294. protected _highPrecisionShadersAllowed: boolean;
  28295. /** @hidden */
  28296. readonly _shouldUseHighPrecisionShader: boolean;
  28297. /**
  28298. * Gets a boolean indicating that only power of 2 textures are supported
  28299. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28300. */
  28301. readonly needPOTTextures: boolean;
  28302. /** @hidden */
  28303. _badOS: boolean;
  28304. /** @hidden */
  28305. _badDesktopOS: boolean;
  28306. /**
  28307. * Gets the audio engine
  28308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28309. * @ignorenaming
  28310. */
  28311. static audioEngine: IAudioEngine;
  28312. /**
  28313. * Default AudioEngine factory responsible of creating the Audio Engine.
  28314. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28315. */
  28316. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28317. /**
  28318. * Default offline support factory responsible of creating a tool used to store data locally.
  28319. * By default, this will create a Database object if the workload has been embedded.
  28320. */
  28321. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28322. private _onFocus;
  28323. private _onBlur;
  28324. private _onCanvasPointerOut;
  28325. private _onCanvasBlur;
  28326. private _onCanvasFocus;
  28327. private _onFullscreenChange;
  28328. private _onPointerLockChange;
  28329. private _hardwareScalingLevel;
  28330. /** @hidden */
  28331. _caps: EngineCapabilities;
  28332. private _pointerLockRequested;
  28333. private _isStencilEnable;
  28334. private _colorWrite;
  28335. private _loadingScreen;
  28336. /** @hidden */
  28337. _drawCalls: PerfCounter;
  28338. private _glVersion;
  28339. private _glRenderer;
  28340. private _glVendor;
  28341. private _videoTextureSupported;
  28342. private _renderingQueueLaunched;
  28343. private _activeRenderLoops;
  28344. private _deterministicLockstep;
  28345. private _lockstepMaxSteps;
  28346. /**
  28347. * Observable signaled when a context lost event is raised
  28348. */
  28349. onContextLostObservable: Observable<Engine>;
  28350. /**
  28351. * Observable signaled when a context restored event is raised
  28352. */
  28353. onContextRestoredObservable: Observable<Engine>;
  28354. private _onContextLost;
  28355. private _onContextRestored;
  28356. private _contextWasLost;
  28357. /** @hidden */
  28358. _doNotHandleContextLost: boolean;
  28359. /**
  28360. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28361. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28362. */
  28363. doNotHandleContextLost: boolean;
  28364. private _performanceMonitor;
  28365. private _fps;
  28366. private _deltaTime;
  28367. /**
  28368. * Turn this value on if you want to pause FPS computation when in background
  28369. */
  28370. disablePerformanceMonitorInBackground: boolean;
  28371. /**
  28372. * Gets the performance monitor attached to this engine
  28373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28374. */
  28375. readonly performanceMonitor: PerformanceMonitor;
  28376. /**
  28377. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28378. */
  28379. disableVertexArrayObjects: boolean;
  28380. /** @hidden */
  28381. protected _depthCullingState: _DepthCullingState;
  28382. /** @hidden */
  28383. protected _stencilState: _StencilState;
  28384. /** @hidden */
  28385. protected _alphaState: _AlphaState;
  28386. /** @hidden */
  28387. protected _alphaMode: number;
  28388. /** @hidden */
  28389. _internalTexturesCache: InternalTexture[];
  28390. /** @hidden */
  28391. protected _activeChannel: number;
  28392. private _currentTextureChannel;
  28393. /** @hidden */
  28394. protected _boundTexturesCache: {
  28395. [key: string]: Nullable<InternalTexture>;
  28396. };
  28397. /** @hidden */
  28398. protected _currentEffect: Nullable<Effect>;
  28399. /** @hidden */
  28400. protected _currentProgram: Nullable<WebGLProgram>;
  28401. private _compiledEffects;
  28402. private _vertexAttribArraysEnabled;
  28403. /** @hidden */
  28404. protected _cachedViewport: Nullable<Viewport>;
  28405. private _cachedVertexArrayObject;
  28406. /** @hidden */
  28407. protected _cachedVertexBuffers: any;
  28408. /** @hidden */
  28409. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28410. /** @hidden */
  28411. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28412. /** @hidden */
  28413. _currentRenderTarget: Nullable<InternalTexture>;
  28414. private _uintIndicesCurrentlySet;
  28415. private _currentBoundBuffer;
  28416. /** @hidden */
  28417. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28418. private _currentBufferPointers;
  28419. private _currentInstanceLocations;
  28420. private _currentInstanceBuffers;
  28421. private _textureUnits;
  28422. /** @hidden */
  28423. _workingCanvas: Nullable<HTMLCanvasElement>;
  28424. /** @hidden */
  28425. _workingContext: Nullable<CanvasRenderingContext2D>;
  28426. private _rescalePostProcess;
  28427. private _dummyFramebuffer;
  28428. private _externalData;
  28429. /** @hidden */
  28430. _bindedRenderFunction: any;
  28431. private _vaoRecordInProgress;
  28432. private _mustWipeVertexAttributes;
  28433. private _emptyTexture;
  28434. private _emptyCubeTexture;
  28435. private _emptyTexture3D;
  28436. /** @hidden */
  28437. _frameHandler: number;
  28438. private _nextFreeTextureSlots;
  28439. private _maxSimultaneousTextures;
  28440. private _activeRequests;
  28441. private _texturesSupported;
  28442. /** @hidden */
  28443. _textureFormatInUse: Nullable<string>;
  28444. /**
  28445. * Gets the list of texture formats supported
  28446. */
  28447. readonly texturesSupported: Array<string>;
  28448. /**
  28449. * Gets the list of texture formats in use
  28450. */
  28451. readonly textureFormatInUse: Nullable<string>;
  28452. /**
  28453. * Gets the current viewport
  28454. */
  28455. readonly currentViewport: Nullable<Viewport>;
  28456. /**
  28457. * Gets the default empty texture
  28458. */
  28459. readonly emptyTexture: InternalTexture;
  28460. /**
  28461. * Gets the default empty 3D texture
  28462. */
  28463. readonly emptyTexture3D: InternalTexture;
  28464. /**
  28465. * Gets the default empty cube texture
  28466. */
  28467. readonly emptyCubeTexture: InternalTexture;
  28468. /**
  28469. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28470. */
  28471. readonly premultipliedAlpha: boolean;
  28472. /**
  28473. * Creates a new engine
  28474. * @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
  28475. * @param antialias defines enable antialiasing (default: false)
  28476. * @param options defines further options to be sent to the getContext() function
  28477. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28478. */
  28479. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28480. /**
  28481. * Initializes a webVR display and starts listening to display change events
  28482. * The onVRDisplayChangedObservable will be notified upon these changes
  28483. * @returns The onVRDisplayChangedObservable
  28484. */
  28485. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28486. /** @hidden */
  28487. _prepareVRComponent(): void;
  28488. /** @hidden */
  28489. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28490. /** @hidden */
  28491. _submitVRFrame(): void;
  28492. /**
  28493. * Call this function to leave webVR mode
  28494. * Will do nothing if webVR is not supported or if there is no webVR device
  28495. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28496. */
  28497. disableVR(): void;
  28498. /**
  28499. * Gets a boolean indicating that the system is in VR mode and is presenting
  28500. * @returns true if VR mode is engaged
  28501. */
  28502. isVRPresenting(): boolean;
  28503. /** @hidden */
  28504. _requestVRFrame(): void;
  28505. private _disableTouchAction;
  28506. private _rebuildInternalTextures;
  28507. private _rebuildEffects;
  28508. /**
  28509. * Gets a boolean indicating if all created effects are ready
  28510. * @returns true if all effects are ready
  28511. */
  28512. areAllEffectsReady(): boolean;
  28513. private _rebuildBuffers;
  28514. private _initGLContext;
  28515. /**
  28516. * Gets version of the current webGL context
  28517. */
  28518. readonly webGLVersion: number;
  28519. /**
  28520. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28521. */
  28522. readonly isStencilEnable: boolean;
  28523. /** @hidden */
  28524. _prepareWorkingCanvas(): void;
  28525. /**
  28526. * Reset the texture cache to empty state
  28527. */
  28528. resetTextureCache(): void;
  28529. /**
  28530. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28531. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28532. * @returns true if engine is in deterministic lock step mode
  28533. */
  28534. isDeterministicLockStep(): boolean;
  28535. /**
  28536. * Gets the max steps when engine is running in deterministic lock step
  28537. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28538. * @returns the max steps
  28539. */
  28540. getLockstepMaxSteps(): number;
  28541. /**
  28542. * Gets an object containing information about the current webGL context
  28543. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28544. */
  28545. getGlInfo(): {
  28546. vendor: string;
  28547. renderer: string;
  28548. version: string;
  28549. };
  28550. /**
  28551. * Gets current aspect ratio
  28552. * @param camera defines the camera to use to get the aspect ratio
  28553. * @param useScreen defines if screen size must be used (or the current render target if any)
  28554. * @returns a number defining the aspect ratio
  28555. */
  28556. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28557. /**
  28558. * Gets current screen aspect ratio
  28559. * @returns a number defining the aspect ratio
  28560. */
  28561. getScreenAspectRatio(): number;
  28562. /**
  28563. * Gets the current render width
  28564. * @param useScreen defines if screen size must be used (or the current render target if any)
  28565. * @returns a number defining the current render width
  28566. */
  28567. getRenderWidth(useScreen?: boolean): number;
  28568. /**
  28569. * Gets the current render height
  28570. * @param useScreen defines if screen size must be used (or the current render target if any)
  28571. * @returns a number defining the current render height
  28572. */
  28573. getRenderHeight(useScreen?: boolean): number;
  28574. /**
  28575. * Gets the HTML canvas attached with the current webGL context
  28576. * @returns a HTML canvas
  28577. */
  28578. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28579. /**
  28580. * Gets the client rect of the HTML canvas attached with the current webGL context
  28581. * @returns a client rectanglee
  28582. */
  28583. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28584. /**
  28585. * Defines the hardware scaling level.
  28586. * By default the hardware scaling level is computed from the window device ratio.
  28587. * 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.
  28588. * @param level defines the level to use
  28589. */
  28590. setHardwareScalingLevel(level: number): void;
  28591. /**
  28592. * Gets the current hardware scaling level.
  28593. * By default the hardware scaling level is computed from the window device ratio.
  28594. * 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.
  28595. * @returns a number indicating the current hardware scaling level
  28596. */
  28597. getHardwareScalingLevel(): number;
  28598. /**
  28599. * Gets the list of loaded textures
  28600. * @returns an array containing all loaded textures
  28601. */
  28602. getLoadedTexturesCache(): InternalTexture[];
  28603. /**
  28604. * Gets the object containing all engine capabilities
  28605. * @returns the EngineCapabilities object
  28606. */
  28607. getCaps(): EngineCapabilities;
  28608. /**
  28609. * Gets the current depth function
  28610. * @returns a number defining the depth function
  28611. */
  28612. getDepthFunction(): Nullable<number>;
  28613. /**
  28614. * Sets the current depth function
  28615. * @param depthFunc defines the function to use
  28616. */
  28617. setDepthFunction(depthFunc: number): void;
  28618. /**
  28619. * Sets the current depth function to GREATER
  28620. */
  28621. setDepthFunctionToGreater(): void;
  28622. /**
  28623. * Sets the current depth function to GEQUAL
  28624. */
  28625. setDepthFunctionToGreaterOrEqual(): void;
  28626. /**
  28627. * Sets the current depth function to LESS
  28628. */
  28629. setDepthFunctionToLess(): void;
  28630. private _cachedStencilBuffer;
  28631. private _cachedStencilFunction;
  28632. private _cachedStencilMask;
  28633. private _cachedStencilOperationPass;
  28634. private _cachedStencilOperationFail;
  28635. private _cachedStencilOperationDepthFail;
  28636. private _cachedStencilReference;
  28637. /**
  28638. * Caches the the state of the stencil buffer
  28639. */
  28640. cacheStencilState(): void;
  28641. /**
  28642. * Restores the state of the stencil buffer
  28643. */
  28644. restoreStencilState(): void;
  28645. /**
  28646. * Sets the current depth function to LEQUAL
  28647. */
  28648. setDepthFunctionToLessOrEqual(): void;
  28649. /**
  28650. * Gets a boolean indicating if stencil buffer is enabled
  28651. * @returns the current stencil buffer state
  28652. */
  28653. getStencilBuffer(): boolean;
  28654. /**
  28655. * Enable or disable the stencil buffer
  28656. * @param enable defines if the stencil buffer must be enabled or disabled
  28657. */
  28658. setStencilBuffer(enable: boolean): void;
  28659. /**
  28660. * Gets the current stencil mask
  28661. * @returns a number defining the new stencil mask to use
  28662. */
  28663. getStencilMask(): number;
  28664. /**
  28665. * Sets the current stencil mask
  28666. * @param mask defines the new stencil mask to use
  28667. */
  28668. setStencilMask(mask: number): void;
  28669. /**
  28670. * Gets the current stencil function
  28671. * @returns a number defining the stencil function to use
  28672. */
  28673. getStencilFunction(): number;
  28674. /**
  28675. * Gets the current stencil reference value
  28676. * @returns a number defining the stencil reference value to use
  28677. */
  28678. getStencilFunctionReference(): number;
  28679. /**
  28680. * Gets the current stencil mask
  28681. * @returns a number defining the stencil mask to use
  28682. */
  28683. getStencilFunctionMask(): number;
  28684. /**
  28685. * Sets the current stencil function
  28686. * @param stencilFunc defines the new stencil function to use
  28687. */
  28688. setStencilFunction(stencilFunc: number): void;
  28689. /**
  28690. * Sets the current stencil reference
  28691. * @param reference defines the new stencil reference to use
  28692. */
  28693. setStencilFunctionReference(reference: number): void;
  28694. /**
  28695. * Sets the current stencil mask
  28696. * @param mask defines the new stencil mask to use
  28697. */
  28698. setStencilFunctionMask(mask: number): void;
  28699. /**
  28700. * Gets the current stencil operation when stencil fails
  28701. * @returns a number defining stencil operation to use when stencil fails
  28702. */
  28703. getStencilOperationFail(): number;
  28704. /**
  28705. * Gets the current stencil operation when depth fails
  28706. * @returns a number defining stencil operation to use when depth fails
  28707. */
  28708. getStencilOperationDepthFail(): number;
  28709. /**
  28710. * Gets the current stencil operation when stencil passes
  28711. * @returns a number defining stencil operation to use when stencil passes
  28712. */
  28713. getStencilOperationPass(): number;
  28714. /**
  28715. * Sets the stencil operation to use when stencil fails
  28716. * @param operation defines the stencil operation to use when stencil fails
  28717. */
  28718. setStencilOperationFail(operation: number): void;
  28719. /**
  28720. * Sets the stencil operation to use when depth fails
  28721. * @param operation defines the stencil operation to use when depth fails
  28722. */
  28723. setStencilOperationDepthFail(operation: number): void;
  28724. /**
  28725. * Sets the stencil operation to use when stencil passes
  28726. * @param operation defines the stencil operation to use when stencil passes
  28727. */
  28728. setStencilOperationPass(operation: number): void;
  28729. /**
  28730. * Sets a boolean indicating if the dithering state is enabled or disabled
  28731. * @param value defines the dithering state
  28732. */
  28733. setDitheringState(value: boolean): void;
  28734. /**
  28735. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28736. * @param value defines the rasterizer state
  28737. */
  28738. setRasterizerState(value: boolean): void;
  28739. /**
  28740. * stop executing a render loop function and remove it from the execution array
  28741. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28742. */
  28743. stopRenderLoop(renderFunction?: () => void): void;
  28744. /** @hidden */
  28745. _renderLoop(): void;
  28746. /**
  28747. * Register and execute a render loop. The engine can have more than one render function
  28748. * @param renderFunction defines the function to continuously execute
  28749. */
  28750. runRenderLoop(renderFunction: () => void): void;
  28751. /**
  28752. * Toggle full screen mode
  28753. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28754. */
  28755. switchFullscreen(requestPointerLock: boolean): void;
  28756. /**
  28757. * Enters full screen mode
  28758. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28759. */
  28760. enterFullscreen(requestPointerLock: boolean): void;
  28761. /**
  28762. * Exits full screen mode
  28763. */
  28764. exitFullscreen(): void;
  28765. /**
  28766. * Clear the current render buffer or the current render target (if any is set up)
  28767. * @param color defines the color to use
  28768. * @param backBuffer defines if the back buffer must be cleared
  28769. * @param depth defines if the depth buffer must be cleared
  28770. * @param stencil defines if the stencil buffer must be cleared
  28771. */
  28772. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28773. /**
  28774. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28775. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28776. * @param y defines the y-coordinate of the corner of the clear rectangle
  28777. * @param width defines the width of the clear rectangle
  28778. * @param height defines the height of the clear rectangle
  28779. * @param clearColor defines the clear color
  28780. */
  28781. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28782. /**
  28783. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28784. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28785. * @param y defines the y-coordinate of the corner of the clear rectangle
  28786. * @param width defines the width of the clear rectangle
  28787. * @param height defines the height of the clear rectangle
  28788. */
  28789. enableScissor(x: number, y: number, width: number, height: number): void;
  28790. /**
  28791. * Disable previously set scissor test rectangle
  28792. */
  28793. disableScissor(): void;
  28794. private _viewportCached;
  28795. /** @hidden */
  28796. _viewport(x: number, y: number, width: number, height: number): void;
  28797. /**
  28798. * Set the WebGL's viewport
  28799. * @param viewport defines the viewport element to be used
  28800. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28801. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28802. */
  28803. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28804. /**
  28805. * Directly set the WebGL Viewport
  28806. * @param x defines the x coordinate of the viewport (in screen space)
  28807. * @param y defines the y coordinate of the viewport (in screen space)
  28808. * @param width defines the width of the viewport (in screen space)
  28809. * @param height defines the height of the viewport (in screen space)
  28810. * @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
  28811. */
  28812. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28813. /**
  28814. * Begin a new frame
  28815. */
  28816. beginFrame(): void;
  28817. /**
  28818. * Enf the current frame
  28819. */
  28820. endFrame(): void;
  28821. /**
  28822. * Resize the view according to the canvas' size
  28823. */
  28824. resize(): void;
  28825. /**
  28826. * Force a specific size of the canvas
  28827. * @param width defines the new canvas' width
  28828. * @param height defines the new canvas' height
  28829. */
  28830. setSize(width: number, height: number): void;
  28831. /**
  28832. * Binds the frame buffer to the specified texture.
  28833. * @param texture The texture to render to or null for the default canvas
  28834. * @param faceIndex The face of the texture to render to in case of cube texture
  28835. * @param requiredWidth The width of the target to render to
  28836. * @param requiredHeight The height of the target to render to
  28837. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28838. * @param depthStencilTexture The depth stencil texture to use to render
  28839. * @param lodLevel defines le lod level to bind to the frame buffer
  28840. */
  28841. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28842. /** @hidden */
  28843. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28844. /**
  28845. * Unbind the current render target texture from the webGL context
  28846. * @param texture defines the render target texture to unbind
  28847. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28848. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28849. */
  28850. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28851. /**
  28852. * Force the mipmap generation for the given render target texture
  28853. * @param texture defines the render target texture to use
  28854. */
  28855. generateMipMapsForCubemap(texture: InternalTexture): void;
  28856. /**
  28857. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28858. */
  28859. flushFramebuffer(): void;
  28860. /**
  28861. * Unbind the current render target and bind the default framebuffer
  28862. */
  28863. restoreDefaultFramebuffer(): void;
  28864. /**
  28865. * Create an uniform buffer
  28866. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28867. * @param elements defines the content of the uniform buffer
  28868. * @returns the webGL uniform buffer
  28869. */
  28870. createUniformBuffer(elements: FloatArray): DataBuffer;
  28871. /**
  28872. * Create a dynamic uniform buffer
  28873. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28874. * @param elements defines the content of the uniform buffer
  28875. * @returns the webGL uniform buffer
  28876. */
  28877. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28878. /**
  28879. * Update an existing uniform buffer
  28880. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28881. * @param uniformBuffer defines the target uniform buffer
  28882. * @param elements defines the content to update
  28883. * @param offset defines the offset in the uniform buffer where update should start
  28884. * @param count defines the size of the data to update
  28885. */
  28886. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28887. private _resetVertexBufferBinding;
  28888. /**
  28889. * Creates a vertex buffer
  28890. * @param data the data for the vertex buffer
  28891. * @returns the new WebGL static buffer
  28892. */
  28893. createVertexBuffer(data: DataArray): DataBuffer;
  28894. /**
  28895. * Creates a dynamic vertex buffer
  28896. * @param data the data for the dynamic vertex buffer
  28897. * @returns the new WebGL dynamic buffer
  28898. */
  28899. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28900. /**
  28901. * Update a dynamic index buffer
  28902. * @param indexBuffer defines the target index buffer
  28903. * @param indices defines the data to update
  28904. * @param offset defines the offset in the target index buffer where update should start
  28905. */
  28906. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28907. /**
  28908. * Updates a dynamic vertex buffer.
  28909. * @param vertexBuffer the vertex buffer to update
  28910. * @param data the data used to update the vertex buffer
  28911. * @param byteOffset the byte offset of the data
  28912. * @param byteLength the byte length of the data
  28913. */
  28914. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28915. private _resetIndexBufferBinding;
  28916. /**
  28917. * Creates a new index buffer
  28918. * @param indices defines the content of the index buffer
  28919. * @param updatable defines if the index buffer must be updatable
  28920. * @returns a new webGL buffer
  28921. */
  28922. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28923. /**
  28924. * Bind a webGL buffer to the webGL context
  28925. * @param buffer defines the buffer to bind
  28926. */
  28927. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28928. /**
  28929. * Bind an uniform buffer to the current webGL context
  28930. * @param buffer defines the buffer to bind
  28931. */
  28932. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28933. /**
  28934. * Bind a buffer to the current webGL context at a given location
  28935. * @param buffer defines the buffer to bind
  28936. * @param location defines the index where to bind the buffer
  28937. */
  28938. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28939. /**
  28940. * Bind a specific block at a given index in a specific shader program
  28941. * @param pipelineContext defines the pipeline context to use
  28942. * @param blockName defines the block name
  28943. * @param index defines the index where to bind the block
  28944. */
  28945. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28946. private bindIndexBuffer;
  28947. private bindBuffer;
  28948. /**
  28949. * update the bound buffer with the given data
  28950. * @param data defines the data to update
  28951. */
  28952. updateArrayBuffer(data: Float32Array): void;
  28953. private _vertexAttribPointer;
  28954. private _bindIndexBufferWithCache;
  28955. private _bindVertexBuffersAttributes;
  28956. /**
  28957. * Records a vertex array object
  28958. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28959. * @param vertexBuffers defines the list of vertex buffers to store
  28960. * @param indexBuffer defines the index buffer to store
  28961. * @param effect defines the effect to store
  28962. * @returns the new vertex array object
  28963. */
  28964. recordVertexArrayObject(vertexBuffers: {
  28965. [key: string]: VertexBuffer;
  28966. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28967. /**
  28968. * Bind a specific vertex array object
  28969. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28970. * @param vertexArrayObject defines the vertex array object to bind
  28971. * @param indexBuffer defines the index buffer to bind
  28972. */
  28973. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28974. /**
  28975. * Bind webGl buffers directly to the webGL context
  28976. * @param vertexBuffer defines the vertex buffer to bind
  28977. * @param indexBuffer defines the index buffer to bind
  28978. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28979. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28980. * @param effect defines the effect associated with the vertex buffer
  28981. */
  28982. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28983. private _unbindVertexArrayObject;
  28984. /**
  28985. * Bind a list of vertex buffers to the webGL context
  28986. * @param vertexBuffers defines the list of vertex buffers to bind
  28987. * @param indexBuffer defines the index buffer to bind
  28988. * @param effect defines the effect associated with the vertex buffers
  28989. */
  28990. bindBuffers(vertexBuffers: {
  28991. [key: string]: Nullable<VertexBuffer>;
  28992. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28993. /**
  28994. * Unbind all instance attributes
  28995. */
  28996. unbindInstanceAttributes(): void;
  28997. /**
  28998. * Release and free the memory of a vertex array object
  28999. * @param vao defines the vertex array object to delete
  29000. */
  29001. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29002. /** @hidden */
  29003. _releaseBuffer(buffer: DataBuffer): boolean;
  29004. /**
  29005. * Creates a webGL buffer to use with instanciation
  29006. * @param capacity defines the size of the buffer
  29007. * @returns the webGL buffer
  29008. */
  29009. createInstancesBuffer(capacity: number): DataBuffer;
  29010. /**
  29011. * Delete a webGL buffer used with instanciation
  29012. * @param buffer defines the webGL buffer to delete
  29013. */
  29014. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29015. /**
  29016. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29017. * @param instancesBuffer defines the webGL buffer to update and bind
  29018. * @param data defines the data to store in the buffer
  29019. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29020. */
  29021. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29022. /**
  29023. * Apply all cached states (depth, culling, stencil and alpha)
  29024. */
  29025. applyStates(): void;
  29026. /**
  29027. * Send a draw order
  29028. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29029. * @param indexStart defines the starting index
  29030. * @param indexCount defines the number of index to draw
  29031. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29032. */
  29033. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29034. /**
  29035. * Draw a list of points
  29036. * @param verticesStart defines the index of first vertex to draw
  29037. * @param verticesCount defines the count of vertices to draw
  29038. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29039. */
  29040. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29041. /**
  29042. * Draw a list of unindexed primitives
  29043. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29044. * @param verticesStart defines the index of first vertex to draw
  29045. * @param verticesCount defines the count of vertices to draw
  29046. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29047. */
  29048. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29049. /**
  29050. * Draw a list of indexed primitives
  29051. * @param fillMode defines the primitive to use
  29052. * @param indexStart defines the starting index
  29053. * @param indexCount defines the number of index to draw
  29054. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29055. */
  29056. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29057. /**
  29058. * Draw a list of unindexed primitives
  29059. * @param fillMode defines the primitive to use
  29060. * @param verticesStart defines the index of first vertex to draw
  29061. * @param verticesCount defines the count of vertices to draw
  29062. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29063. */
  29064. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29065. private _drawMode;
  29066. /** @hidden */
  29067. _releaseEffect(effect: Effect): void;
  29068. /** @hidden */
  29069. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29070. /**
  29071. * Create a new effect (used to store vertex/fragment shaders)
  29072. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29073. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29074. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29075. * @param samplers defines an array of string used to represent textures
  29076. * @param defines defines the string containing the defines to use to compile the shaders
  29077. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29078. * @param onCompiled defines a function to call when the effect creation is successful
  29079. * @param onError defines a function to call when the effect creation has failed
  29080. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29081. * @returns the new Effect
  29082. */
  29083. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29084. private _compileShader;
  29085. private _compileRawShader;
  29086. /**
  29087. * Directly creates a webGL program
  29088. * @param pipelineContext defines the pipeline context to attach to
  29089. * @param vertexCode defines the vertex shader code to use
  29090. * @param fragmentCode defines the fragment shader code to use
  29091. * @param context defines the webGL context to use (if not set, the current one will be used)
  29092. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29093. * @returns the new webGL program
  29094. */
  29095. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29096. /**
  29097. * Creates a webGL program
  29098. * @param pipelineContext defines the pipeline context to attach to
  29099. * @param vertexCode defines the vertex shader code to use
  29100. * @param fragmentCode defines the fragment shader code to use
  29101. * @param defines defines the string containing the defines to use to compile the shaders
  29102. * @param context defines the webGL context to use (if not set, the current one will be used)
  29103. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29104. * @returns the new webGL program
  29105. */
  29106. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29107. /**
  29108. * Creates a new pipeline context
  29109. * @returns the new pipeline
  29110. */
  29111. createPipelineContext(): WebGLPipelineContext;
  29112. private _createShaderProgram;
  29113. private _finalizePipelineContext;
  29114. /** @hidden */
  29115. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29116. /** @hidden */
  29117. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29118. /** @hidden */
  29119. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29120. /**
  29121. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29122. * @param pipelineContext defines the pipeline context to use
  29123. * @param uniformsNames defines the list of uniform names
  29124. * @returns an array of webGL uniform locations
  29125. */
  29126. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29127. /**
  29128. * Gets the lsit of active attributes for a given webGL program
  29129. * @param pipelineContext defines the pipeline context to use
  29130. * @param attributesNames defines the list of attribute names to get
  29131. * @returns an array of indices indicating the offset of each attribute
  29132. */
  29133. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29134. /**
  29135. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29136. * @param effect defines the effect to activate
  29137. */
  29138. enableEffect(effect: Nullable<Effect>): void;
  29139. /**
  29140. * Set the value of an uniform to an array of int32
  29141. * @param uniform defines the webGL uniform location where to store the value
  29142. * @param array defines the array of int32 to store
  29143. */
  29144. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29145. /**
  29146. * Set the value of an uniform to an array of int32 (stored as vec2)
  29147. * @param uniform defines the webGL uniform location where to store the value
  29148. * @param array defines the array of int32 to store
  29149. */
  29150. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29151. /**
  29152. * Set the value of an uniform to an array of int32 (stored as vec3)
  29153. * @param uniform defines the webGL uniform location where to store the value
  29154. * @param array defines the array of int32 to store
  29155. */
  29156. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29157. /**
  29158. * Set the value of an uniform to an array of int32 (stored as vec4)
  29159. * @param uniform defines the webGL uniform location where to store the value
  29160. * @param array defines the array of int32 to store
  29161. */
  29162. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29163. /**
  29164. * Set the value of an uniform to an array of float32
  29165. * @param uniform defines the webGL uniform location where to store the value
  29166. * @param array defines the array of float32 to store
  29167. */
  29168. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29169. /**
  29170. * Set the value of an uniform to an array of float32 (stored as vec2)
  29171. * @param uniform defines the webGL uniform location where to store the value
  29172. * @param array defines the array of float32 to store
  29173. */
  29174. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29175. /**
  29176. * Set the value of an uniform to an array of float32 (stored as vec3)
  29177. * @param uniform defines the webGL uniform location where to store the value
  29178. * @param array defines the array of float32 to store
  29179. */
  29180. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29181. /**
  29182. * Set the value of an uniform to an array of float32 (stored as vec4)
  29183. * @param uniform defines the webGL uniform location where to store the value
  29184. * @param array defines the array of float32 to store
  29185. */
  29186. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29187. /**
  29188. * Set the value of an uniform to an array of number
  29189. * @param uniform defines the webGL uniform location where to store the value
  29190. * @param array defines the array of number to store
  29191. */
  29192. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29193. /**
  29194. * Set the value of an uniform to an array of number (stored as vec2)
  29195. * @param uniform defines the webGL uniform location where to store the value
  29196. * @param array defines the array of number to store
  29197. */
  29198. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29199. /**
  29200. * Set the value of an uniform to an array of number (stored as vec3)
  29201. * @param uniform defines the webGL uniform location where to store the value
  29202. * @param array defines the array of number to store
  29203. */
  29204. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29205. /**
  29206. * Set the value of an uniform to an array of number (stored as vec4)
  29207. * @param uniform defines the webGL uniform location where to store the value
  29208. * @param array defines the array of number to store
  29209. */
  29210. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29211. /**
  29212. * Set the value of an uniform to an array of float32 (stored as matrices)
  29213. * @param uniform defines the webGL uniform location where to store the value
  29214. * @param matrices defines the array of float32 to store
  29215. */
  29216. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29217. /**
  29218. * Set the value of an uniform to a matrix
  29219. * @param uniform defines the webGL uniform location where to store the value
  29220. * @param matrix defines the matrix to store
  29221. */
  29222. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29223. /**
  29224. * Set the value of an uniform to a matrix (3x3)
  29225. * @param uniform defines the webGL uniform location where to store the value
  29226. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29227. */
  29228. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29229. /**
  29230. * Set the value of an uniform to a matrix (2x2)
  29231. * @param uniform defines the webGL uniform location where to store the value
  29232. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29233. */
  29234. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29235. /**
  29236. * Set the value of an uniform to a number (int)
  29237. * @param uniform defines the webGL uniform location where to store the value
  29238. * @param value defines the int number to store
  29239. */
  29240. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29241. /**
  29242. * Set the value of an uniform to a number (float)
  29243. * @param uniform defines the webGL uniform location where to store the value
  29244. * @param value defines the float number to store
  29245. */
  29246. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29247. /**
  29248. * Set the value of an uniform to a vec2
  29249. * @param uniform defines the webGL uniform location where to store the value
  29250. * @param x defines the 1st component of the value
  29251. * @param y defines the 2nd component of the value
  29252. */
  29253. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29254. /**
  29255. * Set the value of an uniform to a vec3
  29256. * @param uniform defines the webGL uniform location where to store the value
  29257. * @param x defines the 1st component of the value
  29258. * @param y defines the 2nd component of the value
  29259. * @param z defines the 3rd component of the value
  29260. */
  29261. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29262. /**
  29263. * Set the value of an uniform to a boolean
  29264. * @param uniform defines the webGL uniform location where to store the value
  29265. * @param bool defines the boolean to store
  29266. */
  29267. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29268. /**
  29269. * Set the value of an uniform to a vec4
  29270. * @param uniform defines the webGL uniform location where to store the value
  29271. * @param x defines the 1st component of the value
  29272. * @param y defines the 2nd component of the value
  29273. * @param z defines the 3rd component of the value
  29274. * @param w defines the 4th component of the value
  29275. */
  29276. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29277. /**
  29278. * Set the value of an uniform to a Color3
  29279. * @param uniform defines the webGL uniform location where to store the value
  29280. * @param color3 defines the color to store
  29281. */
  29282. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29283. /**
  29284. * Set the value of an uniform to a Color3 and an alpha value
  29285. * @param uniform defines the webGL uniform location where to store the value
  29286. * @param color3 defines the color to store
  29287. * @param alpha defines the alpha component to store
  29288. */
  29289. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29290. /**
  29291. * Sets a Color4 on a uniform variable
  29292. * @param uniform defines the uniform location
  29293. * @param color4 defines the value to be set
  29294. */
  29295. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29296. /**
  29297. * Set various states to the webGL context
  29298. * @param culling defines backface culling state
  29299. * @param zOffset defines the value to apply to zOffset (0 by default)
  29300. * @param force defines if states must be applied even if cache is up to date
  29301. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29302. */
  29303. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29304. /**
  29305. * Set the z offset to apply to current rendering
  29306. * @param value defines the offset to apply
  29307. */
  29308. setZOffset(value: number): void;
  29309. /**
  29310. * Gets the current value of the zOffset
  29311. * @returns the current zOffset state
  29312. */
  29313. getZOffset(): number;
  29314. /**
  29315. * Enable or disable depth buffering
  29316. * @param enable defines the state to set
  29317. */
  29318. setDepthBuffer(enable: boolean): void;
  29319. /**
  29320. * Gets a boolean indicating if depth writing is enabled
  29321. * @returns the current depth writing state
  29322. */
  29323. getDepthWrite(): boolean;
  29324. /**
  29325. * Enable or disable depth writing
  29326. * @param enable defines the state to set
  29327. */
  29328. setDepthWrite(enable: boolean): void;
  29329. /**
  29330. * Enable or disable color writing
  29331. * @param enable defines the state to set
  29332. */
  29333. setColorWrite(enable: boolean): void;
  29334. /**
  29335. * Gets a boolean indicating if color writing is enabled
  29336. * @returns the current color writing state
  29337. */
  29338. getColorWrite(): boolean;
  29339. /**
  29340. * Sets alpha constants used by some alpha blending modes
  29341. * @param r defines the red component
  29342. * @param g defines the green component
  29343. * @param b defines the blue component
  29344. * @param a defines the alpha component
  29345. */
  29346. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29347. /**
  29348. * Sets the current alpha mode
  29349. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29350. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29351. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29352. */
  29353. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29354. /**
  29355. * Gets the current alpha mode
  29356. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29357. * @returns the current alpha mode
  29358. */
  29359. getAlphaMode(): number;
  29360. /**
  29361. * Clears the list of texture accessible through engine.
  29362. * This can help preventing texture load conflict due to name collision.
  29363. */
  29364. clearInternalTexturesCache(): void;
  29365. /**
  29366. * Force the entire cache to be cleared
  29367. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29368. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29369. */
  29370. wipeCaches(bruteForce?: boolean): void;
  29371. /**
  29372. * Set the compressed texture format to use, based on the formats you have, and the formats
  29373. * supported by the hardware / browser.
  29374. *
  29375. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29376. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29377. * to API arguments needed to compressed textures. This puts the burden on the container
  29378. * generator to house the arcane code for determining these for current & future formats.
  29379. *
  29380. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29381. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29382. *
  29383. * Note: The result of this call is not taken into account when a texture is base64.
  29384. *
  29385. * @param formatsAvailable defines the list of those format families you have created
  29386. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29387. *
  29388. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29389. * @returns The extension selected.
  29390. */
  29391. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29392. /** @hidden */
  29393. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29394. min: number;
  29395. mag: number;
  29396. };
  29397. /** @hidden */
  29398. _createTexture(): WebGLTexture;
  29399. /**
  29400. * Usually called from Texture.ts.
  29401. * Passed information to create a WebGLTexture
  29402. * @param urlArg defines a value which contains one of the following:
  29403. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29404. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29405. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29406. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29407. * @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)
  29408. * @param scene needed for loading to the correct scene
  29409. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29410. * @param onLoad optional callback to be called upon successful completion
  29411. * @param onError optional callback to be called upon failure
  29412. * @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
  29413. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29414. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29415. * @param forcedExtension defines the extension to use to pick the right loader
  29416. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29417. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29418. */
  29419. 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;
  29420. private _rescaleTexture;
  29421. private _unpackFlipYCached;
  29422. /**
  29423. * In case you are sharing the context with other applications, it might
  29424. * be interested to not cache the unpack flip y state to ensure a consistent
  29425. * value would be set.
  29426. */
  29427. enableUnpackFlipYCached: boolean;
  29428. /** @hidden */
  29429. _unpackFlipY(value: boolean): void;
  29430. /** @hidden */
  29431. _getUnpackAlignement(): number;
  29432. /**
  29433. * Creates a dynamic texture
  29434. * @param width defines the width of the texture
  29435. * @param height defines the height of the texture
  29436. * @param generateMipMaps defines if the engine should generate the mip levels
  29437. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29438. * @returns the dynamic texture inside an InternalTexture
  29439. */
  29440. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29441. /**
  29442. * Update the sampling mode of a given texture
  29443. * @param samplingMode defines the required sampling mode
  29444. * @param texture defines the texture to update
  29445. */
  29446. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29447. /**
  29448. * Update the content of a dynamic texture
  29449. * @param texture defines the texture to update
  29450. * @param canvas defines the canvas containing the source
  29451. * @param invertY defines if data must be stored with Y axis inverted
  29452. * @param premulAlpha defines if alpha is stored as premultiplied
  29453. * @param format defines the format of the data
  29454. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29455. */
  29456. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29457. /**
  29458. * Update a video texture
  29459. * @param texture defines the texture to update
  29460. * @param video defines the video element to use
  29461. * @param invertY defines if data must be stored with Y axis inverted
  29462. */
  29463. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29464. /**
  29465. * Updates a depth texture Comparison Mode and Function.
  29466. * If the comparison Function is equal to 0, the mode will be set to none.
  29467. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29468. * @param texture The texture to set the comparison function for
  29469. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29470. */
  29471. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29472. /** @hidden */
  29473. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29474. width: number;
  29475. height: number;
  29476. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29477. /**
  29478. * Creates a depth stencil texture.
  29479. * This is only available in WebGL 2 or with the depth texture extension available.
  29480. * @param size The size of face edge in the texture.
  29481. * @param options The options defining the texture.
  29482. * @returns The texture
  29483. */
  29484. createDepthStencilTexture(size: number | {
  29485. width: number;
  29486. height: number;
  29487. }, options: DepthTextureCreationOptions): InternalTexture;
  29488. /**
  29489. * Creates a depth stencil texture.
  29490. * This is only available in WebGL 2 or with the depth texture extension available.
  29491. * @param size The size of face edge in the texture.
  29492. * @param options The options defining the texture.
  29493. * @returns The texture
  29494. */
  29495. private _createDepthStencilTexture;
  29496. /**
  29497. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29498. * @param renderTarget The render target to set the frame buffer for
  29499. */
  29500. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29501. /**
  29502. * Creates a new render target texture
  29503. * @param size defines the size of the texture
  29504. * @param options defines the options used to create the texture
  29505. * @returns a new render target texture stored in an InternalTexture
  29506. */
  29507. createRenderTargetTexture(size: number | {
  29508. width: number;
  29509. height: number;
  29510. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29511. /** @hidden */
  29512. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29513. /**
  29514. * Updates the sample count of a render target texture
  29515. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29516. * @param texture defines the texture to update
  29517. * @param samples defines the sample count to set
  29518. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29519. */
  29520. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29521. /** @hidden */
  29522. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29523. /** @hidden */
  29524. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29525. /** @hidden */
  29526. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29527. /** @hidden */
  29528. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29529. /**
  29530. * @hidden
  29531. */
  29532. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29533. private _prepareWebGLTextureContinuation;
  29534. private _prepareWebGLTexture;
  29535. /** @hidden */
  29536. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29537. /** @hidden */
  29538. _releaseFramebufferObjects(texture: InternalTexture): void;
  29539. /** @hidden */
  29540. _releaseTexture(texture: InternalTexture): void;
  29541. private setProgram;
  29542. private _boundUniforms;
  29543. /**
  29544. * Binds an effect to the webGL context
  29545. * @param effect defines the effect to bind
  29546. */
  29547. bindSamplers(effect: Effect): void;
  29548. private _activateCurrentTexture;
  29549. /** @hidden */
  29550. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29551. /** @hidden */
  29552. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29553. /**
  29554. * Sets a texture to the webGL context from a postprocess
  29555. * @param channel defines the channel to use
  29556. * @param postProcess defines the source postprocess
  29557. */
  29558. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29559. /**
  29560. * Binds the output of the passed in post process to the texture channel specified
  29561. * @param channel The channel the texture should be bound to
  29562. * @param postProcess The post process which's output should be bound
  29563. */
  29564. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29565. /**
  29566. * Unbind all textures from the webGL context
  29567. */
  29568. unbindAllTextures(): void;
  29569. /**
  29570. * Sets a texture to the according uniform.
  29571. * @param channel The texture channel
  29572. * @param uniform The uniform to set
  29573. * @param texture The texture to apply
  29574. */
  29575. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29576. /**
  29577. * Sets a depth stencil texture from a render target to the according uniform.
  29578. * @param channel The texture channel
  29579. * @param uniform The uniform to set
  29580. * @param texture The render target texture containing the depth stencil texture to apply
  29581. */
  29582. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29583. private _bindSamplerUniformToChannel;
  29584. private _getTextureWrapMode;
  29585. private _setTexture;
  29586. /**
  29587. * Sets an array of texture to the webGL context
  29588. * @param channel defines the channel where the texture array must be set
  29589. * @param uniform defines the associated uniform location
  29590. * @param textures defines the array of textures to bind
  29591. */
  29592. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29593. /** @hidden */
  29594. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29595. private _setTextureParameterFloat;
  29596. private _setTextureParameterInteger;
  29597. /**
  29598. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29599. * @param x defines the x coordinate of the rectangle where pixels must be read
  29600. * @param y defines the y coordinate of the rectangle where pixels must be read
  29601. * @param width defines the width of the rectangle where pixels must be read
  29602. * @param height defines the height of the rectangle where pixels must be read
  29603. * @returns a Uint8Array containing RGBA colors
  29604. */
  29605. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29606. /**
  29607. * Add an externaly attached data from its key.
  29608. * This method call will fail and return false, if such key already exists.
  29609. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29610. * @param key the unique key that identifies the data
  29611. * @param data the data object to associate to the key for this Engine instance
  29612. * @return true if no such key were already present and the data was added successfully, false otherwise
  29613. */
  29614. addExternalData<T>(key: string, data: T): boolean;
  29615. /**
  29616. * Get an externaly attached data from its key
  29617. * @param key the unique key that identifies the data
  29618. * @return the associated data, if present (can be null), or undefined if not present
  29619. */
  29620. getExternalData<T>(key: string): T;
  29621. /**
  29622. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29623. * @param key the unique key that identifies the data
  29624. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29625. * @return the associated data, can be null if the factory returned null.
  29626. */
  29627. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29628. /**
  29629. * Remove an externaly attached data from the Engine instance
  29630. * @param key the unique key that identifies the data
  29631. * @return true if the data was successfully removed, false if it doesn't exist
  29632. */
  29633. removeExternalData(key: string): boolean;
  29634. /**
  29635. * Unbind all vertex attributes from the webGL context
  29636. */
  29637. unbindAllAttributes(): void;
  29638. /**
  29639. * 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
  29640. */
  29641. releaseEffects(): void;
  29642. /**
  29643. * Dispose and release all associated resources
  29644. */
  29645. dispose(): void;
  29646. /**
  29647. * Display the loading screen
  29648. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29649. */
  29650. displayLoadingUI(): void;
  29651. /**
  29652. * Hide the loading screen
  29653. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29654. */
  29655. hideLoadingUI(): void;
  29656. /**
  29657. * Gets the current loading screen object
  29658. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29659. */
  29660. /**
  29661. * Sets the current loading screen object
  29662. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29663. */
  29664. loadingScreen: ILoadingScreen;
  29665. /**
  29666. * Sets the current loading screen text
  29667. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29668. */
  29669. loadingUIText: string;
  29670. /**
  29671. * Sets the current loading screen background color
  29672. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29673. */
  29674. loadingUIBackgroundColor: string;
  29675. /**
  29676. * Attach a new callback raised when context lost event is fired
  29677. * @param callback defines the callback to call
  29678. */
  29679. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29680. /**
  29681. * Attach a new callback raised when context restored event is fired
  29682. * @param callback defines the callback to call
  29683. */
  29684. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29685. /**
  29686. * Gets the source code of the vertex shader associated with a specific webGL program
  29687. * @param program defines the program to use
  29688. * @returns a string containing the source code of the vertex shader associated with the program
  29689. */
  29690. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29691. /**
  29692. * Gets the source code of the fragment shader associated with a specific webGL program
  29693. * @param program defines the program to use
  29694. * @returns a string containing the source code of the fragment shader associated with the program
  29695. */
  29696. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29697. /**
  29698. * Get the current error code of the webGL context
  29699. * @returns the error code
  29700. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29701. */
  29702. getError(): number;
  29703. /**
  29704. * Gets the current framerate
  29705. * @returns a number representing the framerate
  29706. */
  29707. getFps(): number;
  29708. /**
  29709. * Gets the time spent between current and previous frame
  29710. * @returns a number representing the delta time in ms
  29711. */
  29712. getDeltaTime(): number;
  29713. private _measureFps;
  29714. /** @hidden */
  29715. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29716. private _canRenderToFloatFramebuffer;
  29717. private _canRenderToHalfFloatFramebuffer;
  29718. private _canRenderToFramebuffer;
  29719. /** @hidden */
  29720. _getWebGLTextureType(type: number): number;
  29721. /** @hidden */
  29722. _getInternalFormat(format: number): number;
  29723. /** @hidden */
  29724. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29725. /** @hidden */
  29726. _getRGBAMultiSampleBufferFormat(type: number): number;
  29727. /** @hidden */
  29728. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  29729. /** @hidden */
  29730. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29731. /**
  29732. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29733. * @returns true if the engine can be created
  29734. * @ignorenaming
  29735. */
  29736. static isSupported(): boolean;
  29737. }
  29738. }
  29739. declare module "babylonjs/Materials/effect" {
  29740. import { Observable } from "babylonjs/Misc/observable";
  29741. import { Nullable } from "babylonjs/types";
  29742. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29743. import { IDisposable } from "babylonjs/scene";
  29744. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29745. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29746. import { Engine } from "babylonjs/Engines/engine";
  29747. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29748. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29749. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29750. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29752. /**
  29753. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29754. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29755. */
  29756. export class EffectFallbacks {
  29757. private _defines;
  29758. private _currentRank;
  29759. private _maxRank;
  29760. private _mesh;
  29761. /**
  29762. * Removes the fallback from the bound mesh.
  29763. */
  29764. unBindMesh(): void;
  29765. /**
  29766. * Adds a fallback on the specified property.
  29767. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29768. * @param define The name of the define in the shader
  29769. */
  29770. addFallback(rank: number, define: string): void;
  29771. /**
  29772. * Sets the mesh to use CPU skinning when needing to fallback.
  29773. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29774. * @param mesh The mesh to use the fallbacks.
  29775. */
  29776. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29777. /**
  29778. * Checks to see if more fallbacks are still availible.
  29779. */
  29780. readonly isMoreFallbacks: boolean;
  29781. /**
  29782. * Removes the defines that shoould be removed when falling back.
  29783. * @param currentDefines defines the current define statements for the shader.
  29784. * @param effect defines the current effect we try to compile
  29785. * @returns The resulting defines with defines of the current rank removed.
  29786. */
  29787. reduce(currentDefines: string, effect: Effect): string;
  29788. }
  29789. /**
  29790. * Options to be used when creating an effect.
  29791. */
  29792. export class EffectCreationOptions {
  29793. /**
  29794. * Atrributes that will be used in the shader.
  29795. */
  29796. attributes: string[];
  29797. /**
  29798. * Uniform varible names that will be set in the shader.
  29799. */
  29800. uniformsNames: string[];
  29801. /**
  29802. * Uniform buffer varible names that will be set in the shader.
  29803. */
  29804. uniformBuffersNames: string[];
  29805. /**
  29806. * Sampler texture variable names that will be set in the shader.
  29807. */
  29808. samplers: string[];
  29809. /**
  29810. * Define statements that will be set in the shader.
  29811. */
  29812. defines: any;
  29813. /**
  29814. * Possible fallbacks for this effect to improve performance when needed.
  29815. */
  29816. fallbacks: Nullable<EffectFallbacks>;
  29817. /**
  29818. * Callback that will be called when the shader is compiled.
  29819. */
  29820. onCompiled: Nullable<(effect: Effect) => void>;
  29821. /**
  29822. * Callback that will be called if an error occurs during shader compilation.
  29823. */
  29824. onError: Nullable<(effect: Effect, errors: string) => void>;
  29825. /**
  29826. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29827. */
  29828. indexParameters: any;
  29829. /**
  29830. * Max number of lights that can be used in the shader.
  29831. */
  29832. maxSimultaneousLights: number;
  29833. /**
  29834. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29835. */
  29836. transformFeedbackVaryings: Nullable<string[]>;
  29837. }
  29838. /**
  29839. * Effect containing vertex and fragment shader that can be executed on an object.
  29840. */
  29841. export class Effect implements IDisposable {
  29842. /**
  29843. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29844. */
  29845. static ShadersRepository: string;
  29846. /**
  29847. * Name of the effect.
  29848. */
  29849. name: any;
  29850. /**
  29851. * String container all the define statements that should be set on the shader.
  29852. */
  29853. defines: string;
  29854. /**
  29855. * Callback that will be called when the shader is compiled.
  29856. */
  29857. onCompiled: Nullable<(effect: Effect) => void>;
  29858. /**
  29859. * Callback that will be called if an error occurs during shader compilation.
  29860. */
  29861. onError: Nullable<(effect: Effect, errors: string) => void>;
  29862. /**
  29863. * Callback that will be called when effect is bound.
  29864. */
  29865. onBind: Nullable<(effect: Effect) => void>;
  29866. /**
  29867. * Unique ID of the effect.
  29868. */
  29869. uniqueId: number;
  29870. /**
  29871. * Observable that will be called when the shader is compiled.
  29872. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29873. */
  29874. onCompileObservable: Observable<Effect>;
  29875. /**
  29876. * Observable that will be called if an error occurs during shader compilation.
  29877. */
  29878. onErrorObservable: Observable<Effect>;
  29879. /** @hidden */
  29880. _onBindObservable: Nullable<Observable<Effect>>;
  29881. /**
  29882. * Observable that will be called when effect is bound.
  29883. */
  29884. readonly onBindObservable: Observable<Effect>;
  29885. /** @hidden */
  29886. _bonesComputationForcedToCPU: boolean;
  29887. private static _uniqueIdSeed;
  29888. private _engine;
  29889. private _uniformBuffersNames;
  29890. private _uniformsNames;
  29891. private _samplerList;
  29892. private _samplers;
  29893. private _isReady;
  29894. private _compilationError;
  29895. private _attributesNames;
  29896. private _attributes;
  29897. private _uniforms;
  29898. /**
  29899. * Key for the effect.
  29900. * @hidden
  29901. */
  29902. _key: string;
  29903. private _indexParameters;
  29904. private _fallbacks;
  29905. private _vertexSourceCode;
  29906. private _fragmentSourceCode;
  29907. private _vertexSourceCodeOverride;
  29908. private _fragmentSourceCodeOverride;
  29909. private _transformFeedbackVaryings;
  29910. /**
  29911. * Compiled shader to webGL program.
  29912. * @hidden
  29913. */
  29914. _pipelineContext: IPipelineContext;
  29915. private _valueCache;
  29916. private static _baseCache;
  29917. /**
  29918. * Instantiates an effect.
  29919. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29920. * @param baseName Name of the effect.
  29921. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29922. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29923. * @param samplers List of sampler variables that will be passed to the shader.
  29924. * @param engine Engine to be used to render the effect
  29925. * @param defines Define statements to be added to the shader.
  29926. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29927. * @param onCompiled Callback that will be called when the shader is compiled.
  29928. * @param onError Callback that will be called if an error occurs during shader compilation.
  29929. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29930. */
  29931. 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);
  29932. /**
  29933. * Unique key for this effect
  29934. */
  29935. readonly key: string;
  29936. /**
  29937. * If the effect has been compiled and prepared.
  29938. * @returns if the effect is compiled and prepared.
  29939. */
  29940. isReady(): boolean;
  29941. /**
  29942. * The engine the effect was initialized with.
  29943. * @returns the engine.
  29944. */
  29945. getEngine(): Engine;
  29946. /**
  29947. * The pipeline context for this effect
  29948. * @returns the associated pipeline context
  29949. */
  29950. getPipelineContext(): IPipelineContext;
  29951. /**
  29952. * The set of names of attribute variables for the shader.
  29953. * @returns An array of attribute names.
  29954. */
  29955. getAttributesNames(): string[];
  29956. /**
  29957. * Returns the attribute at the given index.
  29958. * @param index The index of the attribute.
  29959. * @returns The location of the attribute.
  29960. */
  29961. getAttributeLocation(index: number): number;
  29962. /**
  29963. * Returns the attribute based on the name of the variable.
  29964. * @param name of the attribute to look up.
  29965. * @returns the attribute location.
  29966. */
  29967. getAttributeLocationByName(name: string): number;
  29968. /**
  29969. * The number of attributes.
  29970. * @returns the numnber of attributes.
  29971. */
  29972. getAttributesCount(): number;
  29973. /**
  29974. * Gets the index of a uniform variable.
  29975. * @param uniformName of the uniform to look up.
  29976. * @returns the index.
  29977. */
  29978. getUniformIndex(uniformName: string): number;
  29979. /**
  29980. * Returns the attribute based on the name of the variable.
  29981. * @param uniformName of the uniform to look up.
  29982. * @returns the location of the uniform.
  29983. */
  29984. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29985. /**
  29986. * Returns an array of sampler variable names
  29987. * @returns The array of sampler variable neames.
  29988. */
  29989. getSamplers(): string[];
  29990. /**
  29991. * The error from the last compilation.
  29992. * @returns the error string.
  29993. */
  29994. getCompilationError(): string;
  29995. /**
  29996. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29997. * @param func The callback to be used.
  29998. */
  29999. executeWhenCompiled(func: (effect: Effect) => void): void;
  30000. private _checkIsReady;
  30001. /** @hidden */
  30002. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30003. /** @hidden */
  30004. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30005. /** @hidden */
  30006. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30007. private _processShaderConversion;
  30008. private _processIncludes;
  30009. private _processPrecision;
  30010. /**
  30011. * Recompiles the webGL program
  30012. * @param vertexSourceCode The source code for the vertex shader.
  30013. * @param fragmentSourceCode The source code for the fragment shader.
  30014. * @param onCompiled Callback called when completed.
  30015. * @param onError Callback called on error.
  30016. * @hidden
  30017. */
  30018. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30019. /**
  30020. * Prepares the effect
  30021. * @hidden
  30022. */
  30023. _prepareEffect(): void;
  30024. /**
  30025. * Checks if the effect is supported. (Must be called after compilation)
  30026. */
  30027. readonly isSupported: boolean;
  30028. /**
  30029. * Binds a texture to the engine to be used as output of the shader.
  30030. * @param channel Name of the output variable.
  30031. * @param texture Texture to bind.
  30032. * @hidden
  30033. */
  30034. _bindTexture(channel: string, texture: InternalTexture): void;
  30035. /**
  30036. * Sets a texture on the engine to be used in the shader.
  30037. * @param channel Name of the sampler variable.
  30038. * @param texture Texture to set.
  30039. */
  30040. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30041. /**
  30042. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30043. * @param channel Name of the sampler variable.
  30044. * @param texture Texture to set.
  30045. */
  30046. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30047. /**
  30048. * Sets an array of textures on the engine to be used in the shader.
  30049. * @param channel Name of the variable.
  30050. * @param textures Textures to set.
  30051. */
  30052. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30053. /**
  30054. * 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)
  30055. * @param channel Name of the sampler variable.
  30056. * @param postProcess Post process to get the input texture from.
  30057. */
  30058. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30059. /**
  30060. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30061. * 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)
  30062. * @param channel Name of the sampler variable.
  30063. * @param postProcess Post process to get the output texture from.
  30064. */
  30065. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30066. /** @hidden */
  30067. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30068. /** @hidden */
  30069. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30070. /** @hidden */
  30071. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30072. /** @hidden */
  30073. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30074. /**
  30075. * Binds a buffer to a uniform.
  30076. * @param buffer Buffer to bind.
  30077. * @param name Name of the uniform variable to bind to.
  30078. */
  30079. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30080. /**
  30081. * Binds block to a uniform.
  30082. * @param blockName Name of the block to bind.
  30083. * @param index Index to bind.
  30084. */
  30085. bindUniformBlock(blockName: string, index: number): void;
  30086. /**
  30087. * Sets an interger value on a uniform variable.
  30088. * @param uniformName Name of the variable.
  30089. * @param value Value to be set.
  30090. * @returns this effect.
  30091. */
  30092. setInt(uniformName: string, value: number): Effect;
  30093. /**
  30094. * Sets an int array on a uniform variable.
  30095. * @param uniformName Name of the variable.
  30096. * @param array array to be set.
  30097. * @returns this effect.
  30098. */
  30099. setIntArray(uniformName: string, array: Int32Array): Effect;
  30100. /**
  30101. * 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)
  30102. * @param uniformName Name of the variable.
  30103. * @param array array to be set.
  30104. * @returns this effect.
  30105. */
  30106. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30107. /**
  30108. * 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)
  30109. * @param uniformName Name of the variable.
  30110. * @param array array to be set.
  30111. * @returns this effect.
  30112. */
  30113. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30114. /**
  30115. * 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)
  30116. * @param uniformName Name of the variable.
  30117. * @param array array to be set.
  30118. * @returns this effect.
  30119. */
  30120. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30121. /**
  30122. * Sets an float array on a uniform variable.
  30123. * @param uniformName Name of the variable.
  30124. * @param array array to be set.
  30125. * @returns this effect.
  30126. */
  30127. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30128. /**
  30129. * 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)
  30130. * @param uniformName Name of the variable.
  30131. * @param array array to be set.
  30132. * @returns this effect.
  30133. */
  30134. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30135. /**
  30136. * 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)
  30137. * @param uniformName Name of the variable.
  30138. * @param array array to be set.
  30139. * @returns this effect.
  30140. */
  30141. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30142. /**
  30143. * 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)
  30144. * @param uniformName Name of the variable.
  30145. * @param array array to be set.
  30146. * @returns this effect.
  30147. */
  30148. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30149. /**
  30150. * Sets an array on a uniform variable.
  30151. * @param uniformName Name of the variable.
  30152. * @param array array to be set.
  30153. * @returns this effect.
  30154. */
  30155. setArray(uniformName: string, array: number[]): Effect;
  30156. /**
  30157. * 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)
  30158. * @param uniformName Name of the variable.
  30159. * @param array array to be set.
  30160. * @returns this effect.
  30161. */
  30162. setArray2(uniformName: string, array: number[]): Effect;
  30163. /**
  30164. * 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)
  30165. * @param uniformName Name of the variable.
  30166. * @param array array to be set.
  30167. * @returns this effect.
  30168. */
  30169. setArray3(uniformName: string, array: number[]): Effect;
  30170. /**
  30171. * 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)
  30172. * @param uniformName Name of the variable.
  30173. * @param array array to be set.
  30174. * @returns this effect.
  30175. */
  30176. setArray4(uniformName: string, array: number[]): Effect;
  30177. /**
  30178. * Sets matrices on a uniform variable.
  30179. * @param uniformName Name of the variable.
  30180. * @param matrices matrices to be set.
  30181. * @returns this effect.
  30182. */
  30183. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30184. /**
  30185. * Sets matrix on a uniform variable.
  30186. * @param uniformName Name of the variable.
  30187. * @param matrix matrix to be set.
  30188. * @returns this effect.
  30189. */
  30190. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30191. /**
  30192. * 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)
  30193. * @param uniformName Name of the variable.
  30194. * @param matrix matrix to be set.
  30195. * @returns this effect.
  30196. */
  30197. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30198. /**
  30199. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30200. * @param uniformName Name of the variable.
  30201. * @param matrix matrix to be set.
  30202. * @returns this effect.
  30203. */
  30204. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30205. /**
  30206. * Sets a float on a uniform variable.
  30207. * @param uniformName Name of the variable.
  30208. * @param value value to be set.
  30209. * @returns this effect.
  30210. */
  30211. setFloat(uniformName: string, value: number): Effect;
  30212. /**
  30213. * Sets a boolean on a uniform variable.
  30214. * @param uniformName Name of the variable.
  30215. * @param bool value to be set.
  30216. * @returns this effect.
  30217. */
  30218. setBool(uniformName: string, bool: boolean): Effect;
  30219. /**
  30220. * Sets a Vector2 on a uniform variable.
  30221. * @param uniformName Name of the variable.
  30222. * @param vector2 vector2 to be set.
  30223. * @returns this effect.
  30224. */
  30225. setVector2(uniformName: string, vector2: Vector2): Effect;
  30226. /**
  30227. * Sets a float2 on a uniform variable.
  30228. * @param uniformName Name of the variable.
  30229. * @param x First float in float2.
  30230. * @param y Second float in float2.
  30231. * @returns this effect.
  30232. */
  30233. setFloat2(uniformName: string, x: number, y: number): Effect;
  30234. /**
  30235. * Sets a Vector3 on a uniform variable.
  30236. * @param uniformName Name of the variable.
  30237. * @param vector3 Value to be set.
  30238. * @returns this effect.
  30239. */
  30240. setVector3(uniformName: string, vector3: Vector3): Effect;
  30241. /**
  30242. * Sets a float3 on a uniform variable.
  30243. * @param uniformName Name of the variable.
  30244. * @param x First float in float3.
  30245. * @param y Second float in float3.
  30246. * @param z Third float in float3.
  30247. * @returns this effect.
  30248. */
  30249. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30250. /**
  30251. * Sets a Vector4 on a uniform variable.
  30252. * @param uniformName Name of the variable.
  30253. * @param vector4 Value to be set.
  30254. * @returns this effect.
  30255. */
  30256. setVector4(uniformName: string, vector4: Vector4): Effect;
  30257. /**
  30258. * Sets a float4 on a uniform variable.
  30259. * @param uniformName Name of the variable.
  30260. * @param x First float in float4.
  30261. * @param y Second float in float4.
  30262. * @param z Third float in float4.
  30263. * @param w Fourth float in float4.
  30264. * @returns this effect.
  30265. */
  30266. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30267. /**
  30268. * Sets a Color3 on a uniform variable.
  30269. * @param uniformName Name of the variable.
  30270. * @param color3 Value to be set.
  30271. * @returns this effect.
  30272. */
  30273. setColor3(uniformName: string, color3: Color3): Effect;
  30274. /**
  30275. * Sets a Color4 on a uniform variable.
  30276. * @param uniformName Name of the variable.
  30277. * @param color3 Value to be set.
  30278. * @param alpha Alpha value to be set.
  30279. * @returns this effect.
  30280. */
  30281. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30282. /**
  30283. * Sets a Color4 on a uniform variable
  30284. * @param uniformName defines the name of the variable
  30285. * @param color4 defines the value to be set
  30286. * @returns this effect.
  30287. */
  30288. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30289. /** Release all associated resources */
  30290. dispose(): void;
  30291. /**
  30292. * This function will add a new shader to the shader store
  30293. * @param name the name of the shader
  30294. * @param pixelShader optional pixel shader content
  30295. * @param vertexShader optional vertex shader content
  30296. */
  30297. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30298. /**
  30299. * Store of each shader (The can be looked up using effect.key)
  30300. */
  30301. static ShadersStore: {
  30302. [key: string]: string;
  30303. };
  30304. /**
  30305. * Store of each included file for a shader (The can be looked up using effect.key)
  30306. */
  30307. static IncludesShadersStore: {
  30308. [key: string]: string;
  30309. };
  30310. /**
  30311. * Resets the cache of effects.
  30312. */
  30313. static ResetCache(): void;
  30314. }
  30315. }
  30316. declare module "babylonjs/Materials/colorCurves" {
  30317. import { Effect } from "babylonjs/Materials/effect";
  30318. /**
  30319. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30320. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30321. * 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;
  30322. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30323. */
  30324. export class ColorCurves {
  30325. private _dirty;
  30326. private _tempColor;
  30327. private _globalCurve;
  30328. private _highlightsCurve;
  30329. private _midtonesCurve;
  30330. private _shadowsCurve;
  30331. private _positiveCurve;
  30332. private _negativeCurve;
  30333. private _globalHue;
  30334. private _globalDensity;
  30335. private _globalSaturation;
  30336. private _globalExposure;
  30337. /**
  30338. * Gets the global Hue value.
  30339. * 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).
  30340. */
  30341. /**
  30342. * Sets the global Hue value.
  30343. * 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).
  30344. */
  30345. globalHue: number;
  30346. /**
  30347. * Gets the global Density value.
  30348. * 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.
  30349. * Values less than zero provide a filter of opposite hue.
  30350. */
  30351. /**
  30352. * Sets the global Density value.
  30353. * 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.
  30354. * Values less than zero provide a filter of opposite hue.
  30355. */
  30356. globalDensity: number;
  30357. /**
  30358. * Gets the global Saturation value.
  30359. * 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.
  30360. */
  30361. /**
  30362. * Sets the global Saturation value.
  30363. * 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.
  30364. */
  30365. globalSaturation: number;
  30366. /**
  30367. * Gets the global Exposure value.
  30368. * 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.
  30369. */
  30370. /**
  30371. * Sets the global Exposure value.
  30372. * 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.
  30373. */
  30374. globalExposure: number;
  30375. private _highlightsHue;
  30376. private _highlightsDensity;
  30377. private _highlightsSaturation;
  30378. private _highlightsExposure;
  30379. /**
  30380. * Gets the highlights Hue value.
  30381. * 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).
  30382. */
  30383. /**
  30384. * Sets the highlights Hue value.
  30385. * 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).
  30386. */
  30387. highlightsHue: number;
  30388. /**
  30389. * Gets the highlights Density value.
  30390. * 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.
  30391. * Values less than zero provide a filter of opposite hue.
  30392. */
  30393. /**
  30394. * Sets the highlights Density value.
  30395. * 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.
  30396. * Values less than zero provide a filter of opposite hue.
  30397. */
  30398. highlightsDensity: number;
  30399. /**
  30400. * Gets the highlights Saturation value.
  30401. * 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.
  30402. */
  30403. /**
  30404. * Sets the highlights Saturation value.
  30405. * 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.
  30406. */
  30407. highlightsSaturation: number;
  30408. /**
  30409. * Gets the highlights Exposure value.
  30410. * 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.
  30411. */
  30412. /**
  30413. * Sets the highlights Exposure value.
  30414. * 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.
  30415. */
  30416. highlightsExposure: number;
  30417. private _midtonesHue;
  30418. private _midtonesDensity;
  30419. private _midtonesSaturation;
  30420. private _midtonesExposure;
  30421. /**
  30422. * Gets the midtones Hue value.
  30423. * 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).
  30424. */
  30425. /**
  30426. * Sets the midtones Hue value.
  30427. * 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).
  30428. */
  30429. midtonesHue: number;
  30430. /**
  30431. * Gets the midtones Density value.
  30432. * 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.
  30433. * Values less than zero provide a filter of opposite hue.
  30434. */
  30435. /**
  30436. * Sets the midtones Density value.
  30437. * 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.
  30438. * Values less than zero provide a filter of opposite hue.
  30439. */
  30440. midtonesDensity: number;
  30441. /**
  30442. * Gets the midtones Saturation value.
  30443. * 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.
  30444. */
  30445. /**
  30446. * Sets the midtones Saturation value.
  30447. * 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.
  30448. */
  30449. midtonesSaturation: number;
  30450. /**
  30451. * Gets the midtones Exposure value.
  30452. * 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.
  30453. */
  30454. /**
  30455. * Sets the midtones Exposure value.
  30456. * 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.
  30457. */
  30458. midtonesExposure: number;
  30459. private _shadowsHue;
  30460. private _shadowsDensity;
  30461. private _shadowsSaturation;
  30462. private _shadowsExposure;
  30463. /**
  30464. * Gets the shadows Hue value.
  30465. * 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).
  30466. */
  30467. /**
  30468. * Sets the shadows Hue value.
  30469. * 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).
  30470. */
  30471. shadowsHue: number;
  30472. /**
  30473. * Gets the shadows Density value.
  30474. * 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.
  30475. * Values less than zero provide a filter of opposite hue.
  30476. */
  30477. /**
  30478. * Sets the shadows Density value.
  30479. * 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.
  30480. * Values less than zero provide a filter of opposite hue.
  30481. */
  30482. shadowsDensity: number;
  30483. /**
  30484. * Gets the shadows Saturation value.
  30485. * 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.
  30486. */
  30487. /**
  30488. * Sets the shadows Saturation value.
  30489. * 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.
  30490. */
  30491. shadowsSaturation: number;
  30492. /**
  30493. * Gets the shadows Exposure value.
  30494. * 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.
  30495. */
  30496. /**
  30497. * Sets the shadows Exposure value.
  30498. * 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.
  30499. */
  30500. shadowsExposure: number;
  30501. /**
  30502. * Returns the class name
  30503. * @returns The class name
  30504. */
  30505. getClassName(): string;
  30506. /**
  30507. * Binds the color curves to the shader.
  30508. * @param colorCurves The color curve to bind
  30509. * @param effect The effect to bind to
  30510. * @param positiveUniform The positive uniform shader parameter
  30511. * @param neutralUniform The neutral uniform shader parameter
  30512. * @param negativeUniform The negative uniform shader parameter
  30513. */
  30514. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30515. /**
  30516. * Prepare the list of uniforms associated with the ColorCurves effects.
  30517. * @param uniformsList The list of uniforms used in the effect
  30518. */
  30519. static PrepareUniforms(uniformsList: string[]): void;
  30520. /**
  30521. * Returns color grading data based on a hue, density, saturation and exposure value.
  30522. * @param filterHue The hue of the color filter.
  30523. * @param filterDensity The density of the color filter.
  30524. * @param saturation The saturation.
  30525. * @param exposure The exposure.
  30526. * @param result The result data container.
  30527. */
  30528. private getColorGradingDataToRef;
  30529. /**
  30530. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30531. * @param value The input slider value in range [-100,100].
  30532. * @returns Adjusted value.
  30533. */
  30534. private static applyColorGradingSliderNonlinear;
  30535. /**
  30536. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30537. * @param hue The hue (H) input.
  30538. * @param saturation The saturation (S) input.
  30539. * @param brightness The brightness (B) input.
  30540. * @result An RGBA color represented as Vector4.
  30541. */
  30542. private static fromHSBToRef;
  30543. /**
  30544. * Returns a value clamped between min and max
  30545. * @param value The value to clamp
  30546. * @param min The minimum of value
  30547. * @param max The maximum of value
  30548. * @returns The clamped value.
  30549. */
  30550. private static clamp;
  30551. /**
  30552. * Clones the current color curve instance.
  30553. * @return The cloned curves
  30554. */
  30555. clone(): ColorCurves;
  30556. /**
  30557. * Serializes the current color curve instance to a json representation.
  30558. * @return a JSON representation
  30559. */
  30560. serialize(): any;
  30561. /**
  30562. * Parses the color curve from a json representation.
  30563. * @param source the JSON source to parse
  30564. * @return The parsed curves
  30565. */
  30566. static Parse(source: any): ColorCurves;
  30567. }
  30568. }
  30569. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30570. import { Observable } from "babylonjs/Misc/observable";
  30571. import { Nullable } from "babylonjs/types";
  30572. import { Color4 } from "babylonjs/Maths/math";
  30573. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30574. import { Effect } from "babylonjs/Materials/effect";
  30575. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30576. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30577. /**
  30578. * Interface to follow in your material defines to integrate easily the
  30579. * Image proccessing functions.
  30580. * @hidden
  30581. */
  30582. export interface IImageProcessingConfigurationDefines {
  30583. IMAGEPROCESSING: boolean;
  30584. VIGNETTE: boolean;
  30585. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30586. VIGNETTEBLENDMODEOPAQUE: boolean;
  30587. TONEMAPPING: boolean;
  30588. TONEMAPPING_ACES: boolean;
  30589. CONTRAST: boolean;
  30590. EXPOSURE: boolean;
  30591. COLORCURVES: boolean;
  30592. COLORGRADING: boolean;
  30593. COLORGRADING3D: boolean;
  30594. SAMPLER3DGREENDEPTH: boolean;
  30595. SAMPLER3DBGRMAP: boolean;
  30596. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30597. }
  30598. /**
  30599. * @hidden
  30600. */
  30601. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30602. IMAGEPROCESSING: boolean;
  30603. VIGNETTE: boolean;
  30604. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30605. VIGNETTEBLENDMODEOPAQUE: boolean;
  30606. TONEMAPPING: boolean;
  30607. TONEMAPPING_ACES: boolean;
  30608. CONTRAST: boolean;
  30609. COLORCURVES: boolean;
  30610. COLORGRADING: boolean;
  30611. COLORGRADING3D: boolean;
  30612. SAMPLER3DGREENDEPTH: boolean;
  30613. SAMPLER3DBGRMAP: boolean;
  30614. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30615. EXPOSURE: boolean;
  30616. constructor();
  30617. }
  30618. /**
  30619. * This groups together the common properties used for image processing either in direct forward pass
  30620. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30621. * or not.
  30622. */
  30623. export class ImageProcessingConfiguration {
  30624. /**
  30625. * Default tone mapping applied in BabylonJS.
  30626. */
  30627. static readonly TONEMAPPING_STANDARD: number;
  30628. /**
  30629. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30630. * to other engines rendering to increase portability.
  30631. */
  30632. static readonly TONEMAPPING_ACES: number;
  30633. /**
  30634. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30635. */
  30636. colorCurves: Nullable<ColorCurves>;
  30637. private _colorCurvesEnabled;
  30638. /**
  30639. * Gets wether the color curves effect is enabled.
  30640. */
  30641. /**
  30642. * Sets wether the color curves effect is enabled.
  30643. */
  30644. colorCurvesEnabled: boolean;
  30645. private _colorGradingTexture;
  30646. /**
  30647. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30648. */
  30649. /**
  30650. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30651. */
  30652. colorGradingTexture: Nullable<BaseTexture>;
  30653. private _colorGradingEnabled;
  30654. /**
  30655. * Gets wether the color grading effect is enabled.
  30656. */
  30657. /**
  30658. * Sets wether the color grading effect is enabled.
  30659. */
  30660. colorGradingEnabled: boolean;
  30661. private _colorGradingWithGreenDepth;
  30662. /**
  30663. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30664. */
  30665. /**
  30666. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30667. */
  30668. colorGradingWithGreenDepth: boolean;
  30669. private _colorGradingBGR;
  30670. /**
  30671. * Gets wether the color grading texture contains BGR values.
  30672. */
  30673. /**
  30674. * Sets wether the color grading texture contains BGR values.
  30675. */
  30676. colorGradingBGR: boolean;
  30677. /** @hidden */
  30678. _exposure: number;
  30679. /**
  30680. * Gets the Exposure used in the effect.
  30681. */
  30682. /**
  30683. * Sets the Exposure used in the effect.
  30684. */
  30685. exposure: number;
  30686. private _toneMappingEnabled;
  30687. /**
  30688. * Gets wether the tone mapping effect is enabled.
  30689. */
  30690. /**
  30691. * Sets wether the tone mapping effect is enabled.
  30692. */
  30693. toneMappingEnabled: boolean;
  30694. private _toneMappingType;
  30695. /**
  30696. * Gets the type of tone mapping effect.
  30697. */
  30698. /**
  30699. * Sets the type of tone mapping effect used in BabylonJS.
  30700. */
  30701. toneMappingType: number;
  30702. protected _contrast: number;
  30703. /**
  30704. * Gets the contrast used in the effect.
  30705. */
  30706. /**
  30707. * Sets the contrast used in the effect.
  30708. */
  30709. contrast: number;
  30710. /**
  30711. * Vignette stretch size.
  30712. */
  30713. vignetteStretch: number;
  30714. /**
  30715. * Vignette centre X Offset.
  30716. */
  30717. vignetteCentreX: number;
  30718. /**
  30719. * Vignette centre Y Offset.
  30720. */
  30721. vignetteCentreY: number;
  30722. /**
  30723. * Vignette weight or intensity of the vignette effect.
  30724. */
  30725. vignetteWeight: number;
  30726. /**
  30727. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30728. * if vignetteEnabled is set to true.
  30729. */
  30730. vignetteColor: Color4;
  30731. /**
  30732. * Camera field of view used by the Vignette effect.
  30733. */
  30734. vignetteCameraFov: number;
  30735. private _vignetteBlendMode;
  30736. /**
  30737. * Gets the vignette blend mode allowing different kind of effect.
  30738. */
  30739. /**
  30740. * Sets the vignette blend mode allowing different kind of effect.
  30741. */
  30742. vignetteBlendMode: number;
  30743. private _vignetteEnabled;
  30744. /**
  30745. * Gets wether the vignette effect is enabled.
  30746. */
  30747. /**
  30748. * Sets wether the vignette effect is enabled.
  30749. */
  30750. vignetteEnabled: boolean;
  30751. private _applyByPostProcess;
  30752. /**
  30753. * Gets wether the image processing is applied through a post process or not.
  30754. */
  30755. /**
  30756. * Sets wether the image processing is applied through a post process or not.
  30757. */
  30758. applyByPostProcess: boolean;
  30759. private _isEnabled;
  30760. /**
  30761. * Gets wether the image processing is enabled or not.
  30762. */
  30763. /**
  30764. * Sets wether the image processing is enabled or not.
  30765. */
  30766. isEnabled: boolean;
  30767. /**
  30768. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30769. */
  30770. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30771. /**
  30772. * Method called each time the image processing information changes requires to recompile the effect.
  30773. */
  30774. protected _updateParameters(): void;
  30775. /**
  30776. * Gets the current class name.
  30777. * @return "ImageProcessingConfiguration"
  30778. */
  30779. getClassName(): string;
  30780. /**
  30781. * Prepare the list of uniforms associated with the Image Processing effects.
  30782. * @param uniforms The list of uniforms used in the effect
  30783. * @param defines the list of defines currently in use
  30784. */
  30785. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30786. /**
  30787. * Prepare the list of samplers associated with the Image Processing effects.
  30788. * @param samplersList The list of uniforms used in the effect
  30789. * @param defines the list of defines currently in use
  30790. */
  30791. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30792. /**
  30793. * Prepare the list of defines associated to the shader.
  30794. * @param defines the list of defines to complete
  30795. * @param forPostProcess Define if we are currently in post process mode or not
  30796. */
  30797. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30798. /**
  30799. * Returns true if all the image processing information are ready.
  30800. * @returns True if ready, otherwise, false
  30801. */
  30802. isReady(): boolean;
  30803. /**
  30804. * Binds the image processing to the shader.
  30805. * @param effect The effect to bind to
  30806. * @param aspectRatio Define the current aspect ratio of the effect
  30807. */
  30808. bind(effect: Effect, aspectRatio?: number): void;
  30809. /**
  30810. * Clones the current image processing instance.
  30811. * @return The cloned image processing
  30812. */
  30813. clone(): ImageProcessingConfiguration;
  30814. /**
  30815. * Serializes the current image processing instance to a json representation.
  30816. * @return a JSON representation
  30817. */
  30818. serialize(): any;
  30819. /**
  30820. * Parses the image processing from a json representation.
  30821. * @param source the JSON source to parse
  30822. * @return The parsed image processing
  30823. */
  30824. static Parse(source: any): ImageProcessingConfiguration;
  30825. private static _VIGNETTEMODE_MULTIPLY;
  30826. private static _VIGNETTEMODE_OPAQUE;
  30827. /**
  30828. * Used to apply the vignette as a mix with the pixel color.
  30829. */
  30830. static readonly VIGNETTEMODE_MULTIPLY: number;
  30831. /**
  30832. * Used to apply the vignette as a replacement of the pixel color.
  30833. */
  30834. static readonly VIGNETTEMODE_OPAQUE: number;
  30835. }
  30836. }
  30837. declare module "babylonjs/Materials/fresnelParameters" {
  30838. import { Color3 } from "babylonjs/Maths/math";
  30839. /**
  30840. * This represents all the required information to add a fresnel effect on a material:
  30841. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30842. */
  30843. export class FresnelParameters {
  30844. private _isEnabled;
  30845. /**
  30846. * Define if the fresnel effect is enable or not.
  30847. */
  30848. isEnabled: boolean;
  30849. /**
  30850. * Define the color used on edges (grazing angle)
  30851. */
  30852. leftColor: Color3;
  30853. /**
  30854. * Define the color used on center
  30855. */
  30856. rightColor: Color3;
  30857. /**
  30858. * Define bias applied to computed fresnel term
  30859. */
  30860. bias: number;
  30861. /**
  30862. * Defined the power exponent applied to fresnel term
  30863. */
  30864. power: number;
  30865. /**
  30866. * Clones the current fresnel and its valuues
  30867. * @returns a clone fresnel configuration
  30868. */
  30869. clone(): FresnelParameters;
  30870. /**
  30871. * Serializes the current fresnel parameters to a JSON representation.
  30872. * @return the JSON serialization
  30873. */
  30874. serialize(): any;
  30875. /**
  30876. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30877. * @param parsedFresnelParameters Define the JSON representation
  30878. * @returns the parsed parameters
  30879. */
  30880. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30881. }
  30882. }
  30883. declare module "babylonjs/Misc/decorators" {
  30884. import { Nullable } from "babylonjs/types";
  30885. import { Scene } from "babylonjs/scene";
  30886. import { IAnimatable } from "babylonjs/Misc/tools";
  30887. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30888. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30889. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30890. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30891. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30892. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30893. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30894. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30895. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30896. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30897. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30898. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30899. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30900. /**
  30901. * Decorator used to define property that can be serialized as reference to a camera
  30902. * @param sourceName defines the name of the property to decorate
  30903. */
  30904. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30905. /**
  30906. * Class used to help serialization objects
  30907. */
  30908. export class SerializationHelper {
  30909. /** hidden */
  30910. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30911. /** hidden */
  30912. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30913. /** hidden */
  30914. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30915. /** hidden */
  30916. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30917. /**
  30918. * Appends the serialized animations from the source animations
  30919. * @param source Source containing the animations
  30920. * @param destination Target to store the animations
  30921. */
  30922. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30923. /**
  30924. * Static function used to serialized a specific entity
  30925. * @param entity defines the entity to serialize
  30926. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30927. * @returns a JSON compatible object representing the serialization of the entity
  30928. */
  30929. static Serialize<T>(entity: T, serializationObject?: any): any;
  30930. /**
  30931. * Creates a new entity from a serialization data object
  30932. * @param creationFunction defines a function used to instanciated the new entity
  30933. * @param source defines the source serialization data
  30934. * @param scene defines the hosting scene
  30935. * @param rootUrl defines the root url for resources
  30936. * @returns a new entity
  30937. */
  30938. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30939. /**
  30940. * Clones an object
  30941. * @param creationFunction defines the function used to instanciate the new object
  30942. * @param source defines the source object
  30943. * @returns the cloned object
  30944. */
  30945. static Clone<T>(creationFunction: () => T, source: T): T;
  30946. /**
  30947. * Instanciates a new object based on a source one (some data will be shared between both object)
  30948. * @param creationFunction defines the function used to instanciate the new object
  30949. * @param source defines the source object
  30950. * @returns the new object
  30951. */
  30952. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30953. }
  30954. }
  30955. declare module "babylonjs/Cameras/camera" {
  30956. import { SmartArray } from "babylonjs/Misc/smartArray";
  30957. import { Observable } from "babylonjs/Misc/observable";
  30958. import { Nullable } from "babylonjs/types";
  30959. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30960. import { Scene } from "babylonjs/scene";
  30961. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30962. import { Node } from "babylonjs/node";
  30963. import { Mesh } from "babylonjs/Meshes/mesh";
  30964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30965. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30966. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30967. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30968. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30969. import { Ray } from "babylonjs/Culling/ray";
  30970. /**
  30971. * This is the base class of all the camera used in the application.
  30972. * @see http://doc.babylonjs.com/features/cameras
  30973. */
  30974. export class Camera extends Node {
  30975. /** @hidden */
  30976. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30977. /**
  30978. * This is the default projection mode used by the cameras.
  30979. * It helps recreating a feeling of perspective and better appreciate depth.
  30980. * This is the best way to simulate real life cameras.
  30981. */
  30982. static readonly PERSPECTIVE_CAMERA: number;
  30983. /**
  30984. * This helps creating camera with an orthographic mode.
  30985. * 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.
  30986. */
  30987. static readonly ORTHOGRAPHIC_CAMERA: number;
  30988. /**
  30989. * This is the default FOV mode for perspective cameras.
  30990. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30991. */
  30992. static readonly FOVMODE_VERTICAL_FIXED: number;
  30993. /**
  30994. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30995. */
  30996. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30997. /**
  30998. * This specifies ther is no need for a camera rig.
  30999. * Basically only one eye is rendered corresponding to the camera.
  31000. */
  31001. static readonly RIG_MODE_NONE: number;
  31002. /**
  31003. * Simulates a camera Rig with one blue eye and one red eye.
  31004. * This can be use with 3d blue and red glasses.
  31005. */
  31006. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31007. /**
  31008. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31009. */
  31010. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31011. /**
  31012. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31013. */
  31014. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31015. /**
  31016. * Defines that both eyes of the camera will be rendered over under each other.
  31017. */
  31018. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31019. /**
  31020. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31021. */
  31022. static readonly RIG_MODE_VR: number;
  31023. /**
  31024. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31025. */
  31026. static readonly RIG_MODE_WEBVR: number;
  31027. /**
  31028. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31029. */
  31030. static readonly RIG_MODE_CUSTOM: number;
  31031. /**
  31032. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31033. */
  31034. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31035. /**
  31036. * Define the input manager associated with the camera.
  31037. */
  31038. inputs: CameraInputsManager<Camera>;
  31039. /** @hidden */
  31040. _position: Vector3;
  31041. /**
  31042. * Define the current local position of the camera in the scene
  31043. */
  31044. position: Vector3;
  31045. /**
  31046. * The vector the camera should consider as up.
  31047. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31048. */
  31049. upVector: Vector3;
  31050. /**
  31051. * Define the current limit on the left side for an orthographic camera
  31052. * In scene unit
  31053. */
  31054. orthoLeft: Nullable<number>;
  31055. /**
  31056. * Define the current limit on the right side for an orthographic camera
  31057. * In scene unit
  31058. */
  31059. orthoRight: Nullable<number>;
  31060. /**
  31061. * Define the current limit on the bottom side for an orthographic camera
  31062. * In scene unit
  31063. */
  31064. orthoBottom: Nullable<number>;
  31065. /**
  31066. * Define the current limit on the top side for an orthographic camera
  31067. * In scene unit
  31068. */
  31069. orthoTop: Nullable<number>;
  31070. /**
  31071. * Field Of View is set in Radians. (default is 0.8)
  31072. */
  31073. fov: number;
  31074. /**
  31075. * Define the minimum distance the camera can see from.
  31076. * This is important to note that the depth buffer are not infinite and the closer it starts
  31077. * the more your scene might encounter depth fighting issue.
  31078. */
  31079. minZ: number;
  31080. /**
  31081. * Define the maximum distance the camera can see to.
  31082. * This is important to note that the depth buffer are not infinite and the further it end
  31083. * the more your scene might encounter depth fighting issue.
  31084. */
  31085. maxZ: number;
  31086. /**
  31087. * Define the default inertia of the camera.
  31088. * This helps giving a smooth feeling to the camera movement.
  31089. */
  31090. inertia: number;
  31091. /**
  31092. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31093. */
  31094. mode: number;
  31095. /**
  31096. * Define wether the camera is intermediate.
  31097. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31098. */
  31099. isIntermediate: boolean;
  31100. /**
  31101. * Define the viewport of the camera.
  31102. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31103. */
  31104. viewport: Viewport;
  31105. /**
  31106. * Restricts the camera to viewing objects with the same layerMask.
  31107. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31108. */
  31109. layerMask: number;
  31110. /**
  31111. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31112. */
  31113. fovMode: number;
  31114. /**
  31115. * Rig mode of the camera.
  31116. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31117. * This is normally controlled byt the camera themselves as internal use.
  31118. */
  31119. cameraRigMode: number;
  31120. /**
  31121. * Defines the distance between both "eyes" in case of a RIG
  31122. */
  31123. interaxialDistance: number;
  31124. /**
  31125. * Defines if stereoscopic rendering is done side by side or over under.
  31126. */
  31127. isStereoscopicSideBySide: boolean;
  31128. /**
  31129. * 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
  31130. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31131. * else in the scene.
  31132. */
  31133. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31134. /**
  31135. * When set, the camera will render to this render target instead of the default canvas
  31136. */
  31137. outputRenderTarget: Nullable<RenderTargetTexture>;
  31138. /**
  31139. * Observable triggered when the camera view matrix has changed.
  31140. */
  31141. onViewMatrixChangedObservable: Observable<Camera>;
  31142. /**
  31143. * Observable triggered when the camera Projection matrix has changed.
  31144. */
  31145. onProjectionMatrixChangedObservable: Observable<Camera>;
  31146. /**
  31147. * Observable triggered when the inputs have been processed.
  31148. */
  31149. onAfterCheckInputsObservable: Observable<Camera>;
  31150. /**
  31151. * Observable triggered when reset has been called and applied to the camera.
  31152. */
  31153. onRestoreStateObservable: Observable<Camera>;
  31154. /** @hidden */
  31155. _cameraRigParams: any;
  31156. /** @hidden */
  31157. _rigCameras: Camera[];
  31158. /** @hidden */
  31159. _rigPostProcess: Nullable<PostProcess>;
  31160. protected _webvrViewMatrix: Matrix;
  31161. /** @hidden */
  31162. _skipRendering: boolean;
  31163. /** @hidden */
  31164. _projectionMatrix: Matrix;
  31165. /** @hidden */
  31166. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31167. /** @hidden */
  31168. _activeMeshes: SmartArray<AbstractMesh>;
  31169. protected _globalPosition: Vector3;
  31170. /** hidden */
  31171. _computedViewMatrix: Matrix;
  31172. private _doNotComputeProjectionMatrix;
  31173. private _transformMatrix;
  31174. private _frustumPlanes;
  31175. private _refreshFrustumPlanes;
  31176. private _storedFov;
  31177. private _stateStored;
  31178. /**
  31179. * Instantiates a new camera object.
  31180. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31181. * @see http://doc.babylonjs.com/features/cameras
  31182. * @param name Defines the name of the camera in the scene
  31183. * @param position Defines the position of the camera
  31184. * @param scene Defines the scene the camera belongs too
  31185. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31186. */
  31187. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31188. /**
  31189. * Store current camera state (fov, position, etc..)
  31190. * @returns the camera
  31191. */
  31192. storeState(): Camera;
  31193. /**
  31194. * Restores the camera state values if it has been stored. You must call storeState() first
  31195. */
  31196. protected _restoreStateValues(): boolean;
  31197. /**
  31198. * Restored camera state. You must call storeState() first.
  31199. * @returns true if restored and false otherwise
  31200. */
  31201. restoreState(): boolean;
  31202. /**
  31203. * Gets the class name of the camera.
  31204. * @returns the class name
  31205. */
  31206. getClassName(): string;
  31207. /** @hidden */
  31208. readonly _isCamera: boolean;
  31209. /**
  31210. * Gets a string representation of the camera useful for debug purpose.
  31211. * @param fullDetails Defines that a more verboe level of logging is required
  31212. * @returns the string representation
  31213. */
  31214. toString(fullDetails?: boolean): string;
  31215. /**
  31216. * Gets the current world space position of the camera.
  31217. */
  31218. readonly globalPosition: Vector3;
  31219. /**
  31220. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31221. * @returns the active meshe list
  31222. */
  31223. getActiveMeshes(): SmartArray<AbstractMesh>;
  31224. /**
  31225. * Check wether a mesh is part of the current active mesh list of the camera
  31226. * @param mesh Defines the mesh to check
  31227. * @returns true if active, false otherwise
  31228. */
  31229. isActiveMesh(mesh: Mesh): boolean;
  31230. /**
  31231. * Is this camera ready to be used/rendered
  31232. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31233. * @return true if the camera is ready
  31234. */
  31235. isReady(completeCheck?: boolean): boolean;
  31236. /** @hidden */
  31237. _initCache(): void;
  31238. /** @hidden */
  31239. _updateCache(ignoreParentClass?: boolean): void;
  31240. /** @hidden */
  31241. _isSynchronized(): boolean;
  31242. /** @hidden */
  31243. _isSynchronizedViewMatrix(): boolean;
  31244. /** @hidden */
  31245. _isSynchronizedProjectionMatrix(): boolean;
  31246. /**
  31247. * Attach the input controls to a specific dom element to get the input from.
  31248. * @param element Defines the element the controls should be listened from
  31249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31250. */
  31251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31252. /**
  31253. * Detach the current controls from the specified dom element.
  31254. * @param element Defines the element to stop listening the inputs from
  31255. */
  31256. detachControl(element: HTMLElement): void;
  31257. /**
  31258. * Update the camera state according to the different inputs gathered during the frame.
  31259. */
  31260. update(): void;
  31261. /** @hidden */
  31262. _checkInputs(): void;
  31263. /** @hidden */
  31264. readonly rigCameras: Camera[];
  31265. /**
  31266. * Gets the post process used by the rig cameras
  31267. */
  31268. readonly rigPostProcess: Nullable<PostProcess>;
  31269. /**
  31270. * Internal, gets the first post proces.
  31271. * @returns the first post process to be run on this camera.
  31272. */
  31273. _getFirstPostProcess(): Nullable<PostProcess>;
  31274. private _cascadePostProcessesToRigCams;
  31275. /**
  31276. * Attach a post process to the camera.
  31277. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31278. * @param postProcess The post process to attach to the camera
  31279. * @param insertAt The position of the post process in case several of them are in use in the scene
  31280. * @returns the position the post process has been inserted at
  31281. */
  31282. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31283. /**
  31284. * Detach a post process to the camera.
  31285. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31286. * @param postProcess The post process to detach from the camera
  31287. */
  31288. detachPostProcess(postProcess: PostProcess): void;
  31289. /**
  31290. * Gets the current world matrix of the camera
  31291. */
  31292. getWorldMatrix(): Matrix;
  31293. /** @hidden */
  31294. _getViewMatrix(): Matrix;
  31295. /**
  31296. * Gets the current view matrix of the camera.
  31297. * @param force forces the camera to recompute the matrix without looking at the cached state
  31298. * @returns the view matrix
  31299. */
  31300. getViewMatrix(force?: boolean): Matrix;
  31301. /**
  31302. * Freeze the projection matrix.
  31303. * It will prevent the cache check of the camera projection compute and can speed up perf
  31304. * if no parameter of the camera are meant to change
  31305. * @param projection Defines manually a projection if necessary
  31306. */
  31307. freezeProjectionMatrix(projection?: Matrix): void;
  31308. /**
  31309. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31310. */
  31311. unfreezeProjectionMatrix(): void;
  31312. /**
  31313. * Gets the current projection matrix of the camera.
  31314. * @param force forces the camera to recompute the matrix without looking at the cached state
  31315. * @returns the projection matrix
  31316. */
  31317. getProjectionMatrix(force?: boolean): Matrix;
  31318. /**
  31319. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31320. * @returns a Matrix
  31321. */
  31322. getTransformationMatrix(): Matrix;
  31323. private _updateFrustumPlanes;
  31324. /**
  31325. * Checks if a cullable object (mesh...) is in the camera frustum
  31326. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31327. * @param target The object to check
  31328. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31329. * @returns true if the object is in frustum otherwise false
  31330. */
  31331. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31332. /**
  31333. * Checks if a cullable object (mesh...) is in the camera frustum
  31334. * Unlike isInFrustum this cheks the full bounding box
  31335. * @param target The object to check
  31336. * @returns true if the object is in frustum otherwise false
  31337. */
  31338. isCompletelyInFrustum(target: ICullable): boolean;
  31339. /**
  31340. * Gets a ray in the forward direction from the camera.
  31341. * @param length Defines the length of the ray to create
  31342. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31343. * @param origin Defines the start point of the ray which defaults to the camera position
  31344. * @returns the forward ray
  31345. */
  31346. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31347. /**
  31348. * Releases resources associated with this node.
  31349. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31350. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31351. */
  31352. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31353. /** @hidden */
  31354. _isLeftCamera: boolean;
  31355. /**
  31356. * Gets the left camera of a rig setup in case of Rigged Camera
  31357. */
  31358. readonly isLeftCamera: boolean;
  31359. /** @hidden */
  31360. _isRightCamera: boolean;
  31361. /**
  31362. * Gets the right camera of a rig setup in case of Rigged Camera
  31363. */
  31364. readonly isRightCamera: boolean;
  31365. /**
  31366. * Gets the left camera of a rig setup in case of Rigged Camera
  31367. */
  31368. readonly leftCamera: Nullable<FreeCamera>;
  31369. /**
  31370. * Gets the right camera of a rig setup in case of Rigged Camera
  31371. */
  31372. readonly rightCamera: Nullable<FreeCamera>;
  31373. /**
  31374. * Gets the left camera target of a rig setup in case of Rigged Camera
  31375. * @returns the target position
  31376. */
  31377. getLeftTarget(): Nullable<Vector3>;
  31378. /**
  31379. * Gets the right camera target of a rig setup in case of Rigged Camera
  31380. * @returns the target position
  31381. */
  31382. getRightTarget(): Nullable<Vector3>;
  31383. /**
  31384. * @hidden
  31385. */
  31386. setCameraRigMode(mode: number, rigParams: any): void;
  31387. /** @hidden */
  31388. static _setStereoscopicRigMode(camera: Camera): void;
  31389. /** @hidden */
  31390. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31391. /** @hidden */
  31392. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31393. /** @hidden */
  31394. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31395. /** @hidden */
  31396. _getVRProjectionMatrix(): Matrix;
  31397. protected _updateCameraRotationMatrix(): void;
  31398. protected _updateWebVRCameraRotationMatrix(): void;
  31399. /**
  31400. * This function MUST be overwritten by the different WebVR cameras available.
  31401. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31402. * @hidden
  31403. */
  31404. _getWebVRProjectionMatrix(): Matrix;
  31405. /**
  31406. * This function MUST be overwritten by the different WebVR cameras available.
  31407. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31408. * @hidden
  31409. */
  31410. _getWebVRViewMatrix(): Matrix;
  31411. /** @hidden */
  31412. setCameraRigParameter(name: string, value: any): void;
  31413. /**
  31414. * needs to be overridden by children so sub has required properties to be copied
  31415. * @hidden
  31416. */
  31417. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31418. /**
  31419. * May need to be overridden by children
  31420. * @hidden
  31421. */
  31422. _updateRigCameras(): void;
  31423. /** @hidden */
  31424. _setupInputs(): void;
  31425. /**
  31426. * Serialiaze the camera setup to a json represention
  31427. * @returns the JSON representation
  31428. */
  31429. serialize(): any;
  31430. /**
  31431. * Clones the current camera.
  31432. * @param name The cloned camera name
  31433. * @returns the cloned camera
  31434. */
  31435. clone(name: string): Camera;
  31436. /**
  31437. * Gets the direction of the camera relative to a given local axis.
  31438. * @param localAxis Defines the reference axis to provide a relative direction.
  31439. * @return the direction
  31440. */
  31441. getDirection(localAxis: Vector3): Vector3;
  31442. /**
  31443. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31444. * @param localAxis Defines the reference axis to provide a relative direction.
  31445. * @param result Defines the vector to store the result in
  31446. */
  31447. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31448. /**
  31449. * Gets a camera constructor for a given camera type
  31450. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31451. * @param name The name of the camera the result will be able to instantiate
  31452. * @param scene The scene the result will construct the camera in
  31453. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31454. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31455. * @returns a factory method to construc the camera
  31456. */
  31457. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31458. /**
  31459. * Compute the world matrix of the camera.
  31460. * @returns the camera workd matrix
  31461. */
  31462. computeWorldMatrix(): Matrix;
  31463. /**
  31464. * Parse a JSON and creates the camera from the parsed information
  31465. * @param parsedCamera The JSON to parse
  31466. * @param scene The scene to instantiate the camera in
  31467. * @returns the newly constructed camera
  31468. */
  31469. static Parse(parsedCamera: any, scene: Scene): Camera;
  31470. }
  31471. }
  31472. declare module "babylonjs/Misc/tools" {
  31473. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31474. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31475. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31476. import { Observable } from "babylonjs/Misc/observable";
  31477. import { DomManagement } from "babylonjs/Misc/domManagement";
  31478. import { WebRequest } from "babylonjs/Misc/webRequest";
  31479. import { Camera } from "babylonjs/Cameras/camera";
  31480. import { Engine } from "babylonjs/Engines/engine";
  31481. import { Animation } from "babylonjs/Animations/animation";
  31482. /**
  31483. * Interface for any object that can request an animation frame
  31484. */
  31485. export interface ICustomAnimationFrameRequester {
  31486. /**
  31487. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31488. */
  31489. renderFunction?: Function;
  31490. /**
  31491. * Called to request the next frame to render to
  31492. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31493. */
  31494. requestAnimationFrame: Function;
  31495. /**
  31496. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31497. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31498. */
  31499. requestID?: number;
  31500. }
  31501. /**
  31502. * Interface containing an array of animations
  31503. */
  31504. export interface IAnimatable {
  31505. /**
  31506. * Array of animations
  31507. */
  31508. animations: Nullable<Array<Animation>>;
  31509. }
  31510. /** Interface used by value gradients (color, factor, ...) */
  31511. export interface IValueGradient {
  31512. /**
  31513. * Gets or sets the gradient value (between 0 and 1)
  31514. */
  31515. gradient: number;
  31516. }
  31517. /** Class used to store color4 gradient */
  31518. export class ColorGradient implements IValueGradient {
  31519. /**
  31520. * Gets or sets the gradient value (between 0 and 1)
  31521. */
  31522. gradient: number;
  31523. /**
  31524. * Gets or sets first associated color
  31525. */
  31526. color1: Color4;
  31527. /**
  31528. * Gets or sets second associated color
  31529. */
  31530. color2?: Color4;
  31531. /**
  31532. * Will get a color picked randomly between color1 and color2.
  31533. * If color2 is undefined then color1 will be used
  31534. * @param result defines the target Color4 to store the result in
  31535. */
  31536. getColorToRef(result: Color4): void;
  31537. }
  31538. /** Class used to store color 3 gradient */
  31539. export class Color3Gradient implements IValueGradient {
  31540. /**
  31541. * Gets or sets the gradient value (between 0 and 1)
  31542. */
  31543. gradient: number;
  31544. /**
  31545. * Gets or sets the associated color
  31546. */
  31547. color: Color3;
  31548. }
  31549. /** Class used to store factor gradient */
  31550. export class FactorGradient implements IValueGradient {
  31551. /**
  31552. * Gets or sets the gradient value (between 0 and 1)
  31553. */
  31554. gradient: number;
  31555. /**
  31556. * Gets or sets first associated factor
  31557. */
  31558. factor1: number;
  31559. /**
  31560. * Gets or sets second associated factor
  31561. */
  31562. factor2?: number;
  31563. /**
  31564. * Will get a number picked randomly between factor1 and factor2.
  31565. * If factor2 is undefined then factor1 will be used
  31566. * @returns the picked number
  31567. */
  31568. getFactor(): number;
  31569. }
  31570. /**
  31571. * @ignore
  31572. * Application error to support additional information when loading a file
  31573. */
  31574. export class LoadFileError extends Error {
  31575. /** defines the optional web request */
  31576. request?: WebRequest | undefined;
  31577. private static _setPrototypeOf;
  31578. /**
  31579. * Creates a new LoadFileError
  31580. * @param message defines the message of the error
  31581. * @param request defines the optional web request
  31582. */
  31583. constructor(message: string,
  31584. /** defines the optional web request */
  31585. request?: WebRequest | undefined);
  31586. }
  31587. /**
  31588. * Class used to define a retry strategy when error happens while loading assets
  31589. */
  31590. export class RetryStrategy {
  31591. /**
  31592. * Function used to defines an exponential back off strategy
  31593. * @param maxRetries defines the maximum number of retries (3 by default)
  31594. * @param baseInterval defines the interval between retries
  31595. * @returns the strategy function to use
  31596. */
  31597. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31598. }
  31599. /**
  31600. * File request interface
  31601. */
  31602. export interface IFileRequest {
  31603. /**
  31604. * Raised when the request is complete (success or error).
  31605. */
  31606. onCompleteObservable: Observable<IFileRequest>;
  31607. /**
  31608. * Aborts the request for a file.
  31609. */
  31610. abort: () => void;
  31611. }
  31612. /**
  31613. * Class containing a set of static utilities functions
  31614. */
  31615. export class Tools {
  31616. /**
  31617. * Gets or sets the base URL to use to load assets
  31618. */
  31619. static BaseUrl: string;
  31620. /**
  31621. * Enable/Disable Custom HTTP Request Headers globally.
  31622. * default = false
  31623. * @see CustomRequestHeaders
  31624. */
  31625. static UseCustomRequestHeaders: boolean;
  31626. /**
  31627. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31628. * i.e. when loading files, where the server/service expects an Authorization header
  31629. */
  31630. static CustomRequestHeaders: {
  31631. [key: string]: string;
  31632. };
  31633. /**
  31634. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31635. */
  31636. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31637. /**
  31638. * Default behaviour for cors in the application.
  31639. * It can be a string if the expected behavior is identical in the entire app.
  31640. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31641. */
  31642. static CorsBehavior: string | ((url: string | string[]) => string);
  31643. /**
  31644. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31645. * @ignorenaming
  31646. */
  31647. static UseFallbackTexture: boolean;
  31648. /**
  31649. * Use this object to register external classes like custom textures or material
  31650. * to allow the laoders to instantiate them
  31651. */
  31652. static RegisteredExternalClasses: {
  31653. [key: string]: Object;
  31654. };
  31655. /**
  31656. * Texture content used if a texture cannot loaded
  31657. * @ignorenaming
  31658. */
  31659. static fallbackTexture: string;
  31660. /**
  31661. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31662. * @param u defines the coordinate on X axis
  31663. * @param v defines the coordinate on Y axis
  31664. * @param width defines the width of the source data
  31665. * @param height defines the height of the source data
  31666. * @param pixels defines the source byte array
  31667. * @param color defines the output color
  31668. */
  31669. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31670. /**
  31671. * Interpolates between a and b via alpha
  31672. * @param a The lower value (returned when alpha = 0)
  31673. * @param b The upper value (returned when alpha = 1)
  31674. * @param alpha The interpolation-factor
  31675. * @return The mixed value
  31676. */
  31677. static Mix(a: number, b: number, alpha: number): number;
  31678. /**
  31679. * Tries to instantiate a new object from a given class name
  31680. * @param className defines the class name to instantiate
  31681. * @returns the new object or null if the system was not able to do the instantiation
  31682. */
  31683. static Instantiate(className: string): any;
  31684. /**
  31685. * Provides a slice function that will work even on IE
  31686. * @param data defines the array to slice
  31687. * @param start defines the start of the data (optional)
  31688. * @param end defines the end of the data (optional)
  31689. * @returns the new sliced array
  31690. */
  31691. static Slice<T>(data: T, start?: number, end?: number): T;
  31692. /**
  31693. * Polyfill for setImmediate
  31694. * @param action defines the action to execute after the current execution block
  31695. */
  31696. static SetImmediate(action: () => void): void;
  31697. /**
  31698. * Function indicating if a number is an exponent of 2
  31699. * @param value defines the value to test
  31700. * @returns true if the value is an exponent of 2
  31701. */
  31702. static IsExponentOfTwo(value: number): boolean;
  31703. private static _tmpFloatArray;
  31704. /**
  31705. * Returns the nearest 32-bit single precision float representation of a Number
  31706. * @param value A Number. If the parameter is of a different type, it will get converted
  31707. * to a number or to NaN if it cannot be converted
  31708. * @returns number
  31709. */
  31710. static FloatRound(value: number): number;
  31711. /**
  31712. * Find the next highest power of two.
  31713. * @param x Number to start search from.
  31714. * @return Next highest power of two.
  31715. */
  31716. static CeilingPOT(x: number): number;
  31717. /**
  31718. * Find the next lowest power of two.
  31719. * @param x Number to start search from.
  31720. * @return Next lowest power of two.
  31721. */
  31722. static FloorPOT(x: number): number;
  31723. /**
  31724. * Find the nearest power of two.
  31725. * @param x Number to start search from.
  31726. * @return Next nearest power of two.
  31727. */
  31728. static NearestPOT(x: number): number;
  31729. /**
  31730. * Get the closest exponent of two
  31731. * @param value defines the value to approximate
  31732. * @param max defines the maximum value to return
  31733. * @param mode defines how to define the closest value
  31734. * @returns closest exponent of two of the given value
  31735. */
  31736. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31737. /**
  31738. * Extracts the filename from a path
  31739. * @param path defines the path to use
  31740. * @returns the filename
  31741. */
  31742. static GetFilename(path: string): string;
  31743. /**
  31744. * Extracts the "folder" part of a path (everything before the filename).
  31745. * @param uri The URI to extract the info from
  31746. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31747. * @returns The "folder" part of the path
  31748. */
  31749. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31750. /**
  31751. * Extracts text content from a DOM element hierarchy
  31752. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31753. */
  31754. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31755. /**
  31756. * Convert an angle in radians to degrees
  31757. * @param angle defines the angle to convert
  31758. * @returns the angle in degrees
  31759. */
  31760. static ToDegrees(angle: number): number;
  31761. /**
  31762. * Convert an angle in degrees to radians
  31763. * @param angle defines the angle to convert
  31764. * @returns the angle in radians
  31765. */
  31766. static ToRadians(angle: number): number;
  31767. /**
  31768. * Encode a buffer to a base64 string
  31769. * @param buffer defines the buffer to encode
  31770. * @returns the encoded string
  31771. */
  31772. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31773. /**
  31774. * Extracts minimum and maximum values from a list of indexed positions
  31775. * @param positions defines the positions to use
  31776. * @param indices defines the indices to the positions
  31777. * @param indexStart defines the start index
  31778. * @param indexCount defines the end index
  31779. * @param bias defines bias value to add to the result
  31780. * @return minimum and maximum values
  31781. */
  31782. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31783. minimum: Vector3;
  31784. maximum: Vector3;
  31785. };
  31786. /**
  31787. * Extracts minimum and maximum values from a list of positions
  31788. * @param positions defines the positions to use
  31789. * @param start defines the start index in the positions array
  31790. * @param count defines the number of positions to handle
  31791. * @param bias defines bias value to add to the result
  31792. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31793. * @return minimum and maximum values
  31794. */
  31795. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31796. minimum: Vector3;
  31797. maximum: Vector3;
  31798. };
  31799. /**
  31800. * Returns an array if obj is not an array
  31801. * @param obj defines the object to evaluate as an array
  31802. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31803. * @returns either obj directly if obj is an array or a new array containing obj
  31804. */
  31805. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31806. /**
  31807. * Gets the pointer prefix to use
  31808. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31809. */
  31810. static GetPointerPrefix(): string;
  31811. /**
  31812. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31813. * @param func - the function to be called
  31814. * @param requester - the object that will request the next frame. Falls back to window.
  31815. * @returns frame number
  31816. */
  31817. static QueueNewFrame(func: () => void, requester?: any): number;
  31818. /**
  31819. * Ask the browser to promote the current element to fullscreen rendering mode
  31820. * @param element defines the DOM element to promote
  31821. */
  31822. static RequestFullscreen(element: HTMLElement): void;
  31823. /**
  31824. * Asks the browser to exit fullscreen mode
  31825. */
  31826. static ExitFullscreen(): void;
  31827. /**
  31828. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31829. * @param url define the url we are trying
  31830. * @param element define the dom element where to configure the cors policy
  31831. */
  31832. static SetCorsBehavior(url: string | string[], element: {
  31833. crossOrigin: string | null;
  31834. }): void;
  31835. /**
  31836. * Removes unwanted characters from an url
  31837. * @param url defines the url to clean
  31838. * @returns the cleaned url
  31839. */
  31840. static CleanUrl(url: string): string;
  31841. /**
  31842. * Gets or sets a function used to pre-process url before using them to load assets
  31843. */
  31844. static PreprocessUrl: (url: string) => string;
  31845. /**
  31846. * Loads an image as an HTMLImageElement.
  31847. * @param input url string, ArrayBuffer, or Blob to load
  31848. * @param onLoad callback called when the image successfully loads
  31849. * @param onError callback called when the image fails to load
  31850. * @param offlineProvider offline provider for caching
  31851. * @returns the HTMLImageElement of the loaded image
  31852. */
  31853. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31854. /**
  31855. * Loads a file
  31856. * @param url url string, ArrayBuffer, or Blob to load
  31857. * @param onSuccess callback called when the file successfully loads
  31858. * @param onProgress callback called while file is loading (if the server supports this mode)
  31859. * @param offlineProvider defines the offline provider for caching
  31860. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31861. * @param onError callback called when the file fails to load
  31862. * @returns a file request object
  31863. */
  31864. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  31865. /**
  31866. * Load a script (identified by an url). When the url returns, the
  31867. * content of this file is added into a new script element, attached to the DOM (body element)
  31868. * @param scriptUrl defines the url of the script to laod
  31869. * @param onSuccess defines the callback called when the script is loaded
  31870. * @param onError defines the callback to call if an error occurs
  31871. * @param scriptId defines the id of the script element
  31872. */
  31873. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31874. /**
  31875. * Load an asynchronous script (identified by an url). When the url returns, the
  31876. * content of this file is added into a new script element, attached to the DOM (body element)
  31877. * @param scriptUrl defines the url of the script to laod
  31878. * @param scriptId defines the id of the script element
  31879. * @returns a promise request object
  31880. */
  31881. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31882. /**
  31883. * Loads a file from a blob
  31884. * @param fileToLoad defines the blob to use
  31885. * @param callback defines the callback to call when data is loaded
  31886. * @param progressCallback defines the callback to call during loading process
  31887. * @returns a file request object
  31888. */
  31889. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31890. /**
  31891. * Loads a file
  31892. * @param fileToLoad defines the file to load
  31893. * @param callback defines the callback to call when data is loaded
  31894. * @param progressCallBack defines the callback to call during loading process
  31895. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31896. * @returns a file request object
  31897. */
  31898. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31899. /**
  31900. * Creates a data url from a given string content
  31901. * @param content defines the content to convert
  31902. * @returns the new data url link
  31903. */
  31904. static FileAsURL(content: string): string;
  31905. /**
  31906. * Format the given number to a specific decimal format
  31907. * @param value defines the number to format
  31908. * @param decimals defines the number of decimals to use
  31909. * @returns the formatted string
  31910. */
  31911. static Format(value: number, decimals?: number): string;
  31912. /**
  31913. * Checks if a given vector is inside a specific range
  31914. * @param v defines the vector to test
  31915. * @param min defines the minimum range
  31916. * @param max defines the maximum range
  31917. */
  31918. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31919. /**
  31920. * Tries to copy an object by duplicating every property
  31921. * @param source defines the source object
  31922. * @param destination defines the target object
  31923. * @param doNotCopyList defines a list of properties to avoid
  31924. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31925. */
  31926. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31927. /**
  31928. * Gets a boolean indicating if the given object has no own property
  31929. * @param obj defines the object to test
  31930. * @returns true if object has no own property
  31931. */
  31932. static IsEmpty(obj: any): boolean;
  31933. /**
  31934. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31935. * @param str Source string
  31936. * @param suffix Suffix to search for in the source string
  31937. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31938. */
  31939. static EndsWith(str: string, suffix: string): boolean;
  31940. /**
  31941. * Function used to register events at window level
  31942. * @param events defines the events to register
  31943. */
  31944. static RegisterTopRootEvents(events: {
  31945. name: string;
  31946. handler: Nullable<(e: FocusEvent) => any>;
  31947. }[]): void;
  31948. /**
  31949. * Function used to unregister events from window level
  31950. * @param events defines the events to unregister
  31951. */
  31952. static UnregisterTopRootEvents(events: {
  31953. name: string;
  31954. handler: Nullable<(e: FocusEvent) => any>;
  31955. }[]): void;
  31956. /**
  31957. * @ignore
  31958. */
  31959. static _ScreenshotCanvas: HTMLCanvasElement;
  31960. /**
  31961. * Dumps the current bound framebuffer
  31962. * @param width defines the rendering width
  31963. * @param height defines the rendering height
  31964. * @param engine defines the hosting engine
  31965. * @param successCallback defines the callback triggered once the data are available
  31966. * @param mimeType defines the mime type of the result
  31967. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31968. */
  31969. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31970. /**
  31971. * Converts the canvas data to blob.
  31972. * This acts as a polyfill for browsers not supporting the to blob function.
  31973. * @param canvas Defines the canvas to extract the data from
  31974. * @param successCallback Defines the callback triggered once the data are available
  31975. * @param mimeType Defines the mime type of the result
  31976. */
  31977. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31978. /**
  31979. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31980. * @param successCallback defines the callback triggered once the data are available
  31981. * @param mimeType defines the mime type of the result
  31982. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31983. */
  31984. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31985. /**
  31986. * Downloads a blob in the browser
  31987. * @param blob defines the blob to download
  31988. * @param fileName defines the name of the downloaded file
  31989. */
  31990. static Download(blob: Blob, fileName: string): void;
  31991. /**
  31992. * Captures a screenshot of the current rendering
  31993. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31994. * @param engine defines the rendering engine
  31995. * @param camera defines the source camera
  31996. * @param size This parameter can be set to a single number or to an object with the
  31997. * following (optional) properties: precision, width, height. If a single number is passed,
  31998. * it will be used for both width and height. If an object is passed, the screenshot size
  31999. * will be derived from the parameters. The precision property is a multiplier allowing
  32000. * rendering at a higher or lower resolution
  32001. * @param successCallback defines the callback receives a single parameter which contains the
  32002. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32003. * src parameter of an <img> to display it
  32004. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32005. * Check your browser for supported MIME types
  32006. */
  32007. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32008. /**
  32009. * Generates an image screenshot from the specified camera.
  32010. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32011. * @param engine The engine to use for rendering
  32012. * @param camera The camera to use for rendering
  32013. * @param size This parameter can be set to a single number or to an object with the
  32014. * following (optional) properties: precision, width, height. If a single number is passed,
  32015. * it will be used for both width and height. If an object is passed, the screenshot size
  32016. * will be derived from the parameters. The precision property is a multiplier allowing
  32017. * rendering at a higher or lower resolution
  32018. * @param successCallback The callback receives a single parameter which contains the
  32019. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32020. * src parameter of an <img> to display it
  32021. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32022. * Check your browser for supported MIME types
  32023. * @param samples Texture samples (default: 1)
  32024. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32025. * @param fileName A name for for the downloaded file.
  32026. */
  32027. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32028. /**
  32029. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32030. * Be aware Math.random() could cause collisions, but:
  32031. * "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"
  32032. * @returns a pseudo random id
  32033. */
  32034. static RandomId(): string;
  32035. /**
  32036. * Test if the given uri is a base64 string
  32037. * @param uri The uri to test
  32038. * @return True if the uri is a base64 string or false otherwise
  32039. */
  32040. static IsBase64(uri: string): boolean;
  32041. /**
  32042. * Decode the given base64 uri.
  32043. * @param uri The uri to decode
  32044. * @return The decoded base64 data.
  32045. */
  32046. static DecodeBase64(uri: string): ArrayBuffer;
  32047. /**
  32048. * Gets the absolute url.
  32049. * @param url the input url
  32050. * @return the absolute url
  32051. */
  32052. static GetAbsoluteUrl(url: string): string;
  32053. /**
  32054. * No log
  32055. */
  32056. static readonly NoneLogLevel: number;
  32057. /**
  32058. * Only message logs
  32059. */
  32060. static readonly MessageLogLevel: number;
  32061. /**
  32062. * Only warning logs
  32063. */
  32064. static readonly WarningLogLevel: number;
  32065. /**
  32066. * Only error logs
  32067. */
  32068. static readonly ErrorLogLevel: number;
  32069. /**
  32070. * All logs
  32071. */
  32072. static readonly AllLogLevel: number;
  32073. /**
  32074. * Gets a value indicating the number of loading errors
  32075. * @ignorenaming
  32076. */
  32077. static readonly errorsCount: number;
  32078. /**
  32079. * Callback called when a new log is added
  32080. */
  32081. static OnNewCacheEntry: (entry: string) => void;
  32082. /**
  32083. * Log a message to the console
  32084. * @param message defines the message to log
  32085. */
  32086. static Log(message: string): void;
  32087. /**
  32088. * Write a warning message to the console
  32089. * @param message defines the message to log
  32090. */
  32091. static Warn(message: string): void;
  32092. /**
  32093. * Write an error message to the console
  32094. * @param message defines the message to log
  32095. */
  32096. static Error(message: string): void;
  32097. /**
  32098. * Gets current log cache (list of logs)
  32099. */
  32100. static readonly LogCache: string;
  32101. /**
  32102. * Clears the log cache
  32103. */
  32104. static ClearLogCache(): void;
  32105. /**
  32106. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32107. */
  32108. static LogLevels: number;
  32109. /**
  32110. * Checks if the loaded document was accessed via `file:`-Protocol.
  32111. * @returns boolean
  32112. */
  32113. static IsFileURL(): boolean;
  32114. /**
  32115. * Checks if the window object exists
  32116. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32117. */
  32118. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32119. /**
  32120. * No performance log
  32121. */
  32122. static readonly PerformanceNoneLogLevel: number;
  32123. /**
  32124. * Use user marks to log performance
  32125. */
  32126. static readonly PerformanceUserMarkLogLevel: number;
  32127. /**
  32128. * Log performance to the console
  32129. */
  32130. static readonly PerformanceConsoleLogLevel: number;
  32131. private static _performance;
  32132. /**
  32133. * Sets the current performance log level
  32134. */
  32135. static PerformanceLogLevel: number;
  32136. private static _StartPerformanceCounterDisabled;
  32137. private static _EndPerformanceCounterDisabled;
  32138. private static _StartUserMark;
  32139. private static _EndUserMark;
  32140. private static _StartPerformanceConsole;
  32141. private static _EndPerformanceConsole;
  32142. /**
  32143. * Starts a performance counter
  32144. */
  32145. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32146. /**
  32147. * Ends a specific performance coutner
  32148. */
  32149. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32150. /**
  32151. * Gets either window.performance.now() if supported or Date.now() else
  32152. */
  32153. static readonly Now: number;
  32154. /**
  32155. * This method will return the name of the class used to create the instance of the given object.
  32156. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32157. * @param object the object to get the class name from
  32158. * @param isType defines if the object is actually a type
  32159. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32160. */
  32161. static GetClassName(object: any, isType?: boolean): string;
  32162. /**
  32163. * Gets the first element of an array satisfying a given predicate
  32164. * @param array defines the array to browse
  32165. * @param predicate defines the predicate to use
  32166. * @returns null if not found or the element
  32167. */
  32168. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32169. /**
  32170. * This method will return the name of the full name of the class, including its owning module (if any).
  32171. * 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).
  32172. * @param object the object to get the class name from
  32173. * @param isType defines if the object is actually a type
  32174. * @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.
  32175. * @ignorenaming
  32176. */
  32177. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32178. /**
  32179. * Returns a promise that resolves after the given amount of time.
  32180. * @param delay Number of milliseconds to delay
  32181. * @returns Promise that resolves after the given amount of time
  32182. */
  32183. static DelayAsync(delay: number): Promise<void>;
  32184. /**
  32185. * Gets the current gradient from an array of IValueGradient
  32186. * @param ratio defines the current ratio to get
  32187. * @param gradients defines the array of IValueGradient
  32188. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32189. */
  32190. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32191. }
  32192. /**
  32193. * This class is used to track a performance counter which is number based.
  32194. * The user has access to many properties which give statistics of different nature.
  32195. *
  32196. * The implementer can track two kinds of Performance Counter: time and count.
  32197. * 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.
  32198. * 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.
  32199. */
  32200. export class PerfCounter {
  32201. /**
  32202. * Gets or sets a global boolean to turn on and off all the counters
  32203. */
  32204. static Enabled: boolean;
  32205. /**
  32206. * Returns the smallest value ever
  32207. */
  32208. readonly min: number;
  32209. /**
  32210. * Returns the biggest value ever
  32211. */
  32212. readonly max: number;
  32213. /**
  32214. * Returns the average value since the performance counter is running
  32215. */
  32216. readonly average: number;
  32217. /**
  32218. * Returns the average value of the last second the counter was monitored
  32219. */
  32220. readonly lastSecAverage: number;
  32221. /**
  32222. * Returns the current value
  32223. */
  32224. readonly current: number;
  32225. /**
  32226. * Gets the accumulated total
  32227. */
  32228. readonly total: number;
  32229. /**
  32230. * Gets the total value count
  32231. */
  32232. readonly count: number;
  32233. /**
  32234. * Creates a new counter
  32235. */
  32236. constructor();
  32237. /**
  32238. * Call this method to start monitoring a new frame.
  32239. * 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.
  32240. */
  32241. fetchNewFrame(): void;
  32242. /**
  32243. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32244. * @param newCount the count value to add to the monitored count
  32245. * @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.
  32246. */
  32247. addCount(newCount: number, fetchResult: boolean): void;
  32248. /**
  32249. * Start monitoring this performance counter
  32250. */
  32251. beginMonitoring(): void;
  32252. /**
  32253. * Compute the time lapsed since the previous beginMonitoring() call.
  32254. * @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
  32255. */
  32256. endMonitoring(newFrame?: boolean): void;
  32257. private _fetchResult;
  32258. private _startMonitoringTime;
  32259. private _min;
  32260. private _max;
  32261. private _average;
  32262. private _current;
  32263. private _totalValueCount;
  32264. private _totalAccumulated;
  32265. private _lastSecAverage;
  32266. private _lastSecAccumulated;
  32267. private _lastSecTime;
  32268. private _lastSecValueCount;
  32269. }
  32270. /**
  32271. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32272. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32273. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32274. * @param name The name of the class, case should be preserved
  32275. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32276. */
  32277. export function className(name: string, module?: string): (target: Object) => void;
  32278. /**
  32279. * An implementation of a loop for asynchronous functions.
  32280. */
  32281. export class AsyncLoop {
  32282. /**
  32283. * Defines the number of iterations for the loop
  32284. */
  32285. iterations: number;
  32286. /**
  32287. * Defines the current index of the loop.
  32288. */
  32289. index: number;
  32290. private _done;
  32291. private _fn;
  32292. private _successCallback;
  32293. /**
  32294. * Constructor.
  32295. * @param iterations the number of iterations.
  32296. * @param func the function to run each iteration
  32297. * @param successCallback the callback that will be called upon succesful execution
  32298. * @param offset starting offset.
  32299. */
  32300. constructor(
  32301. /**
  32302. * Defines the number of iterations for the loop
  32303. */
  32304. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32305. /**
  32306. * Execute the next iteration. Must be called after the last iteration was finished.
  32307. */
  32308. executeNext(): void;
  32309. /**
  32310. * Break the loop and run the success callback.
  32311. */
  32312. breakLoop(): void;
  32313. /**
  32314. * Create and run an async loop.
  32315. * @param iterations the number of iterations.
  32316. * @param fn the function to run each iteration
  32317. * @param successCallback the callback that will be called upon succesful execution
  32318. * @param offset starting offset.
  32319. * @returns the created async loop object
  32320. */
  32321. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32322. /**
  32323. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32324. * @param iterations total number of iterations
  32325. * @param syncedIterations number of synchronous iterations in each async iteration.
  32326. * @param fn the function to call each iteration.
  32327. * @param callback a success call back that will be called when iterating stops.
  32328. * @param breakFunction a break condition (optional)
  32329. * @param timeout timeout settings for the setTimeout function. default - 0.
  32330. * @returns the created async loop object
  32331. */
  32332. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32333. }
  32334. }
  32335. declare module "babylonjs/Collisions/collisionCoordinator" {
  32336. import { Nullable } from "babylonjs/types";
  32337. import { Scene } from "babylonjs/scene";
  32338. import { Vector3 } from "babylonjs/Maths/math";
  32339. import { Collider } from "babylonjs/Collisions/collider";
  32340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32341. /** @hidden */
  32342. export interface ICollisionCoordinator {
  32343. createCollider(): Collider;
  32344. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32345. init(scene: Scene): void;
  32346. }
  32347. /** @hidden */
  32348. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32349. private _scene;
  32350. private _scaledPosition;
  32351. private _scaledVelocity;
  32352. private _finalPosition;
  32353. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32354. createCollider(): Collider;
  32355. init(scene: Scene): void;
  32356. private _collideWithWorld;
  32357. }
  32358. }
  32359. declare module "babylonjs/Inputs/scene.inputManager" {
  32360. import { Nullable } from "babylonjs/types";
  32361. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32362. import { Vector2 } from "babylonjs/Maths/math";
  32363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32364. import { Scene } from "babylonjs/scene";
  32365. /**
  32366. * Class used to manage all inputs for the scene.
  32367. */
  32368. export class InputManager {
  32369. /** The distance in pixel that you have to move to prevent some events */
  32370. static DragMovementThreshold: number;
  32371. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32372. static LongPressDelay: number;
  32373. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32374. static DoubleClickDelay: number;
  32375. /** If you need to check double click without raising a single click at first click, enable this flag */
  32376. static ExclusiveDoubleClickMode: boolean;
  32377. private _wheelEventName;
  32378. private _onPointerMove;
  32379. private _onPointerDown;
  32380. private _onPointerUp;
  32381. private _initClickEvent;
  32382. private _initActionManager;
  32383. private _delayedSimpleClick;
  32384. private _delayedSimpleClickTimeout;
  32385. private _previousDelayedSimpleClickTimeout;
  32386. private _meshPickProceed;
  32387. private _previousButtonPressed;
  32388. private _currentPickResult;
  32389. private _previousPickResult;
  32390. private _totalPointersPressed;
  32391. private _doubleClickOccured;
  32392. private _pointerOverMesh;
  32393. private _pickedDownMesh;
  32394. private _pickedUpMesh;
  32395. private _pointerX;
  32396. private _pointerY;
  32397. private _unTranslatedPointerX;
  32398. private _unTranslatedPointerY;
  32399. private _startingPointerPosition;
  32400. private _previousStartingPointerPosition;
  32401. private _startingPointerTime;
  32402. private _previousStartingPointerTime;
  32403. private _pointerCaptures;
  32404. private _onKeyDown;
  32405. private _onKeyUp;
  32406. private _onCanvasFocusObserver;
  32407. private _onCanvasBlurObserver;
  32408. private _scene;
  32409. /**
  32410. * Creates a new InputManager
  32411. * @param scene defines the hosting scene
  32412. */
  32413. constructor(scene: Scene);
  32414. /**
  32415. * Gets the mesh that is currently under the pointer
  32416. */
  32417. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32418. /**
  32419. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32420. */
  32421. readonly unTranslatedPointer: Vector2;
  32422. /**
  32423. * Gets or sets the current on-screen X position of the pointer
  32424. */
  32425. pointerX: number;
  32426. /**
  32427. * Gets or sets the current on-screen Y position of the pointer
  32428. */
  32429. pointerY: number;
  32430. private _updatePointerPosition;
  32431. private _processPointerMove;
  32432. private _setRayOnPointerInfo;
  32433. private _checkPrePointerObservable;
  32434. /**
  32435. * Use this method to simulate a pointer move on a mesh
  32436. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32437. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32438. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32439. */
  32440. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32441. /**
  32442. * Use this method to simulate a pointer down on a mesh
  32443. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32444. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32445. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32446. */
  32447. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32448. private _processPointerDown;
  32449. /** @hidden */
  32450. _isPointerSwiping(): boolean;
  32451. /**
  32452. * Use this method to simulate a pointer up on a mesh
  32453. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32454. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32455. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32456. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32457. */
  32458. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32459. private _processPointerUp;
  32460. /**
  32461. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32462. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32463. * @returns true if the pointer was captured
  32464. */
  32465. isPointerCaptured(pointerId?: number): boolean;
  32466. /**
  32467. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32468. * @param attachUp defines if you want to attach events to pointerup
  32469. * @param attachDown defines if you want to attach events to pointerdown
  32470. * @param attachMove defines if you want to attach events to pointermove
  32471. */
  32472. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32473. /**
  32474. * Detaches all event handlers
  32475. */
  32476. detachControl(): void;
  32477. /**
  32478. * Force the value of meshUnderPointer
  32479. * @param mesh defines the mesh to use
  32480. */
  32481. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32482. /**
  32483. * Gets the mesh under the pointer
  32484. * @returns a Mesh or null if no mesh is under the pointer
  32485. */
  32486. getPointerOverMesh(): Nullable<AbstractMesh>;
  32487. }
  32488. }
  32489. declare module "babylonjs/Animations/animationGroup" {
  32490. import { Animatable } from "babylonjs/Animations/animatable";
  32491. import { Animation } from "babylonjs/Animations/animation";
  32492. import { Scene, IDisposable } from "babylonjs/scene";
  32493. import { Observable } from "babylonjs/Misc/observable";
  32494. import { Nullable } from "babylonjs/types";
  32495. /**
  32496. * This class defines the direct association between an animation and a target
  32497. */
  32498. export class TargetedAnimation {
  32499. /**
  32500. * Animation to perform
  32501. */
  32502. animation: Animation;
  32503. /**
  32504. * Target to animate
  32505. */
  32506. target: any;
  32507. }
  32508. /**
  32509. * Use this class to create coordinated animations on multiple targets
  32510. */
  32511. export class AnimationGroup implements IDisposable {
  32512. /** The name of the animation group */
  32513. name: string;
  32514. private _scene;
  32515. private _targetedAnimations;
  32516. private _animatables;
  32517. private _from;
  32518. private _to;
  32519. private _isStarted;
  32520. private _isPaused;
  32521. private _speedRatio;
  32522. /**
  32523. * Gets or sets the unique id of the node
  32524. */
  32525. uniqueId: number;
  32526. /**
  32527. * This observable will notify when one animation have ended
  32528. */
  32529. onAnimationEndObservable: Observable<TargetedAnimation>;
  32530. /**
  32531. * Observer raised when one animation loops
  32532. */
  32533. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32534. /**
  32535. * This observable will notify when all animations have ended.
  32536. */
  32537. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32538. /**
  32539. * This observable will notify when all animations have paused.
  32540. */
  32541. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32542. /**
  32543. * This observable will notify when all animations are playing.
  32544. */
  32545. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32546. /**
  32547. * Gets the first frame
  32548. */
  32549. readonly from: number;
  32550. /**
  32551. * Gets the last frame
  32552. */
  32553. readonly to: number;
  32554. /**
  32555. * Define if the animations are started
  32556. */
  32557. readonly isStarted: boolean;
  32558. /**
  32559. * Gets a value indicating that the current group is playing
  32560. */
  32561. readonly isPlaying: boolean;
  32562. /**
  32563. * Gets or sets the speed ratio to use for all animations
  32564. */
  32565. /**
  32566. * Gets or sets the speed ratio to use for all animations
  32567. */
  32568. speedRatio: number;
  32569. /**
  32570. * Gets the targeted animations for this animation group
  32571. */
  32572. readonly targetedAnimations: Array<TargetedAnimation>;
  32573. /**
  32574. * returning the list of animatables controlled by this animation group.
  32575. */
  32576. readonly animatables: Array<Animatable>;
  32577. /**
  32578. * Instantiates a new Animation Group.
  32579. * This helps managing several animations at once.
  32580. * @see http://doc.babylonjs.com/how_to/group
  32581. * @param name Defines the name of the group
  32582. * @param scene Defines the scene the group belongs to
  32583. */
  32584. constructor(
  32585. /** The name of the animation group */
  32586. name: string, scene?: Nullable<Scene>);
  32587. /**
  32588. * Add an animation (with its target) in the group
  32589. * @param animation defines the animation we want to add
  32590. * @param target defines the target of the animation
  32591. * @returns the TargetedAnimation object
  32592. */
  32593. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32594. /**
  32595. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32596. * It can add constant keys at begin or end
  32597. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32598. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32599. * @returns the animation group
  32600. */
  32601. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32602. /**
  32603. * Start all animations on given targets
  32604. * @param loop defines if animations must loop
  32605. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32606. * @param from defines the from key (optional)
  32607. * @param to defines the to key (optional)
  32608. * @returns the current animation group
  32609. */
  32610. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32611. /**
  32612. * Pause all animations
  32613. * @returns the animation group
  32614. */
  32615. pause(): AnimationGroup;
  32616. /**
  32617. * Play all animations to initial state
  32618. * This function will start() the animations if they were not started or will restart() them if they were paused
  32619. * @param loop defines if animations must loop
  32620. * @returns the animation group
  32621. */
  32622. play(loop?: boolean): AnimationGroup;
  32623. /**
  32624. * Reset all animations to initial state
  32625. * @returns the animation group
  32626. */
  32627. reset(): AnimationGroup;
  32628. /**
  32629. * Restart animations from key 0
  32630. * @returns the animation group
  32631. */
  32632. restart(): AnimationGroup;
  32633. /**
  32634. * Stop all animations
  32635. * @returns the animation group
  32636. */
  32637. stop(): AnimationGroup;
  32638. /**
  32639. * Set animation weight for all animatables
  32640. * @param weight defines the weight to use
  32641. * @return the animationGroup
  32642. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32643. */
  32644. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32645. /**
  32646. * Synchronize and normalize all animatables with a source animatable
  32647. * @param root defines the root animatable to synchronize with
  32648. * @return the animationGroup
  32649. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32650. */
  32651. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32652. /**
  32653. * Goes to a specific frame in this animation group
  32654. * @param frame the frame number to go to
  32655. * @return the animationGroup
  32656. */
  32657. goToFrame(frame: number): AnimationGroup;
  32658. /**
  32659. * Dispose all associated resources
  32660. */
  32661. dispose(): void;
  32662. private _checkAnimationGroupEnded;
  32663. /**
  32664. * Clone the current animation group and returns a copy
  32665. * @param newName defines the name of the new group
  32666. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32667. * @returns the new aniamtion group
  32668. */
  32669. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32670. /**
  32671. * Returns a new AnimationGroup object parsed from the source provided.
  32672. * @param parsedAnimationGroup defines the source
  32673. * @param scene defines the scene that will receive the animationGroup
  32674. * @returns a new AnimationGroup
  32675. */
  32676. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32677. /**
  32678. * Returns the string "AnimationGroup"
  32679. * @returns "AnimationGroup"
  32680. */
  32681. getClassName(): string;
  32682. /**
  32683. * Creates a detailled string about the object
  32684. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32685. * @returns a string representing the object
  32686. */
  32687. toString(fullDetails?: boolean): string;
  32688. }
  32689. }
  32690. declare module "babylonjs/scene" {
  32691. import { Nullable } from "babylonjs/types";
  32692. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32693. import { Observable } from "babylonjs/Misc/observable";
  32694. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32695. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32696. import { Geometry } from "babylonjs/Meshes/geometry";
  32697. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32698. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32700. import { Mesh } from "babylonjs/Meshes/mesh";
  32701. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32702. import { Bone } from "babylonjs/Bones/bone";
  32703. import { Skeleton } from "babylonjs/Bones/skeleton";
  32704. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32705. import { Camera } from "babylonjs/Cameras/camera";
  32706. import { AbstractScene } from "babylonjs/abstractScene";
  32707. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32708. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32709. import { Material } from "babylonjs/Materials/material";
  32710. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32711. import { Effect } from "babylonjs/Materials/effect";
  32712. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32713. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32714. import { Light } from "babylonjs/Lights/light";
  32715. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32716. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32717. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32718. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32719. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32720. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32721. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32722. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32723. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32724. import { Engine } from "babylonjs/Engines/engine";
  32725. import { Node } from "babylonjs/node";
  32726. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32727. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32728. import { WebRequest } from "babylonjs/Misc/webRequest";
  32729. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32730. import { Ray } from "babylonjs/Culling/ray";
  32731. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32732. import { Animation } from "babylonjs/Animations/animation";
  32733. import { Animatable } from "babylonjs/Animations/animatable";
  32734. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32735. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32736. import { Collider } from "babylonjs/Collisions/collider";
  32737. /**
  32738. * Define an interface for all classes that will hold resources
  32739. */
  32740. export interface IDisposable {
  32741. /**
  32742. * Releases all held resources
  32743. */
  32744. dispose(): void;
  32745. }
  32746. /** Interface defining initialization parameters for Scene class */
  32747. export interface SceneOptions {
  32748. /**
  32749. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32750. * It will improve performance when the number of geometries becomes important.
  32751. */
  32752. useGeometryUniqueIdsMap?: boolean;
  32753. /**
  32754. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32755. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32756. */
  32757. useMaterialMeshMap?: boolean;
  32758. /**
  32759. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32760. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32761. */
  32762. useClonedMeshhMap?: boolean;
  32763. }
  32764. /**
  32765. * Represents a scene to be rendered by the engine.
  32766. * @see http://doc.babylonjs.com/features/scene
  32767. */
  32768. export class Scene extends AbstractScene implements IAnimatable {
  32769. private static _uniqueIdCounter;
  32770. /** The fog is deactivated */
  32771. static readonly FOGMODE_NONE: number;
  32772. /** The fog density is following an exponential function */
  32773. static readonly FOGMODE_EXP: number;
  32774. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32775. static readonly FOGMODE_EXP2: number;
  32776. /** The fog density is following a linear function. */
  32777. static readonly FOGMODE_LINEAR: number;
  32778. /**
  32779. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32780. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32781. */
  32782. static MinDeltaTime: number;
  32783. /**
  32784. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32785. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32786. */
  32787. static MaxDeltaTime: number;
  32788. /**
  32789. * Factory used to create the default material.
  32790. * @param name The name of the material to create
  32791. * @param scene The scene to create the material for
  32792. * @returns The default material
  32793. */
  32794. static DefaultMaterialFactory(scene: Scene): Material;
  32795. /**
  32796. * Factory used to create the a collision coordinator.
  32797. * @returns The collision coordinator
  32798. */
  32799. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32800. /** @hidden */
  32801. _inputManager: InputManager;
  32802. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32803. cameraToUseForPointers: Nullable<Camera>;
  32804. /** @hidden */
  32805. readonly _isScene: boolean;
  32806. /**
  32807. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32808. */
  32809. autoClear: boolean;
  32810. /**
  32811. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32812. */
  32813. autoClearDepthAndStencil: boolean;
  32814. /**
  32815. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32816. */
  32817. clearColor: Color4;
  32818. /**
  32819. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32820. */
  32821. ambientColor: Color3;
  32822. /**
  32823. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32824. * It should only be one of the following (if not the default embedded one):
  32825. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32826. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32827. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32828. * The material properties need to be setup according to the type of texture in use.
  32829. */
  32830. environmentBRDFTexture: BaseTexture;
  32831. /** @hidden */
  32832. protected _environmentTexture: Nullable<BaseTexture>;
  32833. /**
  32834. * Texture used in all pbr material as the reflection texture.
  32835. * As in the majority of the scene they are the same (exception for multi room and so on),
  32836. * this is easier to reference from here than from all the materials.
  32837. */
  32838. /**
  32839. * Texture used in all pbr material as the reflection texture.
  32840. * As in the majority of the scene they are the same (exception for multi room and so on),
  32841. * this is easier to set here than in all the materials.
  32842. */
  32843. environmentTexture: Nullable<BaseTexture>;
  32844. /** @hidden */
  32845. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32846. /**
  32847. * Default image processing configuration used either in the rendering
  32848. * Forward main pass or through the imageProcessingPostProcess if present.
  32849. * As in the majority of the scene they are the same (exception for multi camera),
  32850. * this is easier to reference from here than from all the materials and post process.
  32851. *
  32852. * No setter as we it is a shared configuration, you can set the values instead.
  32853. */
  32854. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32855. private _forceWireframe;
  32856. /**
  32857. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32858. */
  32859. forceWireframe: boolean;
  32860. private _forcePointsCloud;
  32861. /**
  32862. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32863. */
  32864. forcePointsCloud: boolean;
  32865. /**
  32866. * Gets or sets the active clipplane 1
  32867. */
  32868. clipPlane: Nullable<Plane>;
  32869. /**
  32870. * Gets or sets the active clipplane 2
  32871. */
  32872. clipPlane2: Nullable<Plane>;
  32873. /**
  32874. * Gets or sets the active clipplane 3
  32875. */
  32876. clipPlane3: Nullable<Plane>;
  32877. /**
  32878. * Gets or sets the active clipplane 4
  32879. */
  32880. clipPlane4: Nullable<Plane>;
  32881. /**
  32882. * Gets or sets a boolean indicating if animations are enabled
  32883. */
  32884. animationsEnabled: boolean;
  32885. private _animationPropertiesOverride;
  32886. /**
  32887. * Gets or sets the animation properties override
  32888. */
  32889. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32890. /**
  32891. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32892. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32893. */
  32894. useConstantAnimationDeltaTime: boolean;
  32895. /**
  32896. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32897. * Please note that it requires to run a ray cast through the scene on every frame
  32898. */
  32899. constantlyUpdateMeshUnderPointer: boolean;
  32900. /**
  32901. * Defines the HTML cursor to use when hovering over interactive elements
  32902. */
  32903. hoverCursor: string;
  32904. /**
  32905. * Defines the HTML default cursor to use (empty by default)
  32906. */
  32907. defaultCursor: string;
  32908. /**
  32909. * This is used to call preventDefault() on pointer down
  32910. * in order to block unwanted artifacts like system double clicks
  32911. */
  32912. preventDefaultOnPointerDown: boolean;
  32913. /**
  32914. * This is used to call preventDefault() on pointer up
  32915. * in order to block unwanted artifacts like system double clicks
  32916. */
  32917. preventDefaultOnPointerUp: boolean;
  32918. /**
  32919. * Gets or sets user defined metadata
  32920. */
  32921. metadata: any;
  32922. /**
  32923. * For internal use only. Please do not use.
  32924. */
  32925. reservedDataStore: any;
  32926. /**
  32927. * Gets the name of the plugin used to load this scene (null by default)
  32928. */
  32929. loadingPluginName: string;
  32930. /**
  32931. * Use this array to add regular expressions used to disable offline support for specific urls
  32932. */
  32933. disableOfflineSupportExceptionRules: RegExp[];
  32934. /**
  32935. * An event triggered when the scene is disposed.
  32936. */
  32937. onDisposeObservable: Observable<Scene>;
  32938. private _onDisposeObserver;
  32939. /** Sets a function to be executed when this scene is disposed. */
  32940. onDispose: () => void;
  32941. /**
  32942. * An event triggered before rendering the scene (right after animations and physics)
  32943. */
  32944. onBeforeRenderObservable: Observable<Scene>;
  32945. private _onBeforeRenderObserver;
  32946. /** Sets a function to be executed before rendering this scene */
  32947. beforeRender: Nullable<() => void>;
  32948. /**
  32949. * An event triggered after rendering the scene
  32950. */
  32951. onAfterRenderObservable: Observable<Scene>;
  32952. private _onAfterRenderObserver;
  32953. /** Sets a function to be executed after rendering this scene */
  32954. afterRender: Nullable<() => void>;
  32955. /**
  32956. * An event triggered before animating the scene
  32957. */
  32958. onBeforeAnimationsObservable: Observable<Scene>;
  32959. /**
  32960. * An event triggered after animations processing
  32961. */
  32962. onAfterAnimationsObservable: Observable<Scene>;
  32963. /**
  32964. * An event triggered before draw calls are ready to be sent
  32965. */
  32966. onBeforeDrawPhaseObservable: Observable<Scene>;
  32967. /**
  32968. * An event triggered after draw calls have been sent
  32969. */
  32970. onAfterDrawPhaseObservable: Observable<Scene>;
  32971. /**
  32972. * An event triggered when the scene is ready
  32973. */
  32974. onReadyObservable: Observable<Scene>;
  32975. /**
  32976. * An event triggered before rendering a camera
  32977. */
  32978. onBeforeCameraRenderObservable: Observable<Camera>;
  32979. private _onBeforeCameraRenderObserver;
  32980. /** Sets a function to be executed before rendering a camera*/
  32981. beforeCameraRender: () => void;
  32982. /**
  32983. * An event triggered after rendering a camera
  32984. */
  32985. onAfterCameraRenderObservable: Observable<Camera>;
  32986. private _onAfterCameraRenderObserver;
  32987. /** Sets a function to be executed after rendering a camera*/
  32988. afterCameraRender: () => void;
  32989. /**
  32990. * An event triggered when active meshes evaluation is about to start
  32991. */
  32992. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32993. /**
  32994. * An event triggered when active meshes evaluation is done
  32995. */
  32996. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32997. /**
  32998. * An event triggered when particles rendering is about to start
  32999. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33000. */
  33001. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33002. /**
  33003. * An event triggered when particles rendering is done
  33004. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33005. */
  33006. onAfterParticlesRenderingObservable: Observable<Scene>;
  33007. /**
  33008. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33009. */
  33010. onDataLoadedObservable: Observable<Scene>;
  33011. /**
  33012. * An event triggered when a camera is created
  33013. */
  33014. onNewCameraAddedObservable: Observable<Camera>;
  33015. /**
  33016. * An event triggered when a camera is removed
  33017. */
  33018. onCameraRemovedObservable: Observable<Camera>;
  33019. /**
  33020. * An event triggered when a light is created
  33021. */
  33022. onNewLightAddedObservable: Observable<Light>;
  33023. /**
  33024. * An event triggered when a light is removed
  33025. */
  33026. onLightRemovedObservable: Observable<Light>;
  33027. /**
  33028. * An event triggered when a geometry is created
  33029. */
  33030. onNewGeometryAddedObservable: Observable<Geometry>;
  33031. /**
  33032. * An event triggered when a geometry is removed
  33033. */
  33034. onGeometryRemovedObservable: Observable<Geometry>;
  33035. /**
  33036. * An event triggered when a transform node is created
  33037. */
  33038. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33039. /**
  33040. * An event triggered when a transform node is removed
  33041. */
  33042. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33043. /**
  33044. * An event triggered when a mesh is created
  33045. */
  33046. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33047. /**
  33048. * An event triggered when a mesh is removed
  33049. */
  33050. onMeshRemovedObservable: Observable<AbstractMesh>;
  33051. /**
  33052. * An event triggered when a skeleton is created
  33053. */
  33054. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33055. /**
  33056. * An event triggered when a skeleton is removed
  33057. */
  33058. onSkeletonRemovedObservable: Observable<Skeleton>;
  33059. /**
  33060. * An event triggered when a material is created
  33061. */
  33062. onNewMaterialAddedObservable: Observable<Material>;
  33063. /**
  33064. * An event triggered when a material is removed
  33065. */
  33066. onMaterialRemovedObservable: Observable<Material>;
  33067. /**
  33068. * An event triggered when a texture is created
  33069. */
  33070. onNewTextureAddedObservable: Observable<BaseTexture>;
  33071. /**
  33072. * An event triggered when a texture is removed
  33073. */
  33074. onTextureRemovedObservable: Observable<BaseTexture>;
  33075. /**
  33076. * An event triggered when render targets are about to be rendered
  33077. * Can happen multiple times per frame.
  33078. */
  33079. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33080. /**
  33081. * An event triggered when render targets were rendered.
  33082. * Can happen multiple times per frame.
  33083. */
  33084. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33085. /**
  33086. * An event triggered before calculating deterministic simulation step
  33087. */
  33088. onBeforeStepObservable: Observable<Scene>;
  33089. /**
  33090. * An event triggered after calculating deterministic simulation step
  33091. */
  33092. onAfterStepObservable: Observable<Scene>;
  33093. /**
  33094. * An event triggered when the activeCamera property is updated
  33095. */
  33096. onActiveCameraChanged: Observable<Scene>;
  33097. /**
  33098. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33099. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33100. * 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)
  33101. */
  33102. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33103. /**
  33104. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33105. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33106. * 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)
  33107. */
  33108. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33109. /**
  33110. * This Observable will when a mesh has been imported into the scene.
  33111. */
  33112. onMeshImportedObservable: Observable<AbstractMesh>;
  33113. /**
  33114. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33115. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33116. */
  33117. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33118. /** @hidden */
  33119. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33120. /**
  33121. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33122. */
  33123. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33124. /**
  33125. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33126. */
  33127. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33128. /**
  33129. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33130. */
  33131. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33132. /** Callback called when a pointer move is detected */
  33133. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33134. /** Callback called when a pointer down is detected */
  33135. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33136. /** Callback called when a pointer up is detected */
  33137. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33138. /** Callback called when a pointer pick is detected */
  33139. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33140. /**
  33141. * 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).
  33142. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33143. */
  33144. onPrePointerObservable: Observable<PointerInfoPre>;
  33145. /**
  33146. * Observable event triggered each time an input event is received from the rendering canvas
  33147. */
  33148. onPointerObservable: Observable<PointerInfo>;
  33149. /**
  33150. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33151. */
  33152. readonly unTranslatedPointer: Vector2;
  33153. /**
  33154. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33155. */
  33156. static DragMovementThreshold: number;
  33157. /**
  33158. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33159. */
  33160. static LongPressDelay: number;
  33161. /**
  33162. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33163. */
  33164. static DoubleClickDelay: number;
  33165. /** If you need to check double click without raising a single click at first click, enable this flag */
  33166. static ExclusiveDoubleClickMode: boolean;
  33167. /** @hidden */
  33168. _mirroredCameraPosition: Nullable<Vector3>;
  33169. /**
  33170. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33171. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33172. */
  33173. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33174. /**
  33175. * Observable event triggered each time an keyboard event is received from the hosting window
  33176. */
  33177. onKeyboardObservable: Observable<KeyboardInfo>;
  33178. private _useRightHandedSystem;
  33179. /**
  33180. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33181. */
  33182. useRightHandedSystem: boolean;
  33183. private _timeAccumulator;
  33184. private _currentStepId;
  33185. private _currentInternalStep;
  33186. /**
  33187. * Sets the step Id used by deterministic lock step
  33188. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33189. * @param newStepId defines the step Id
  33190. */
  33191. setStepId(newStepId: number): void;
  33192. /**
  33193. * Gets the step Id used by deterministic lock step
  33194. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33195. * @returns the step Id
  33196. */
  33197. getStepId(): number;
  33198. /**
  33199. * Gets the internal step used by deterministic lock step
  33200. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33201. * @returns the internal step
  33202. */
  33203. getInternalStep(): number;
  33204. private _fogEnabled;
  33205. /**
  33206. * Gets or sets a boolean indicating if fog is enabled on this scene
  33207. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33208. * (Default is true)
  33209. */
  33210. fogEnabled: boolean;
  33211. private _fogMode;
  33212. /**
  33213. * Gets or sets the fog mode to use
  33214. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33215. * | mode | value |
  33216. * | --- | --- |
  33217. * | FOGMODE_NONE | 0 |
  33218. * | FOGMODE_EXP | 1 |
  33219. * | FOGMODE_EXP2 | 2 |
  33220. * | FOGMODE_LINEAR | 3 |
  33221. */
  33222. fogMode: number;
  33223. /**
  33224. * Gets or sets the fog color to use
  33225. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33226. * (Default is Color3(0.2, 0.2, 0.3))
  33227. */
  33228. fogColor: Color3;
  33229. /**
  33230. * Gets or sets the fog density to use
  33231. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33232. * (Default is 0.1)
  33233. */
  33234. fogDensity: number;
  33235. /**
  33236. * Gets or sets the fog start distance to use
  33237. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33238. * (Default is 0)
  33239. */
  33240. fogStart: number;
  33241. /**
  33242. * Gets or sets the fog end distance to use
  33243. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33244. * (Default is 1000)
  33245. */
  33246. fogEnd: number;
  33247. private _shadowsEnabled;
  33248. /**
  33249. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33250. */
  33251. shadowsEnabled: boolean;
  33252. private _lightsEnabled;
  33253. /**
  33254. * Gets or sets a boolean indicating if lights are enabled on this scene
  33255. */
  33256. lightsEnabled: boolean;
  33257. /** All of the active cameras added to this scene. */
  33258. activeCameras: Camera[];
  33259. /** @hidden */
  33260. _activeCamera: Nullable<Camera>;
  33261. /** Gets or sets the current active camera */
  33262. activeCamera: Nullable<Camera>;
  33263. private _defaultMaterial;
  33264. /** The default material used on meshes when no material is affected */
  33265. /** The default material used on meshes when no material is affected */
  33266. defaultMaterial: Material;
  33267. private _texturesEnabled;
  33268. /**
  33269. * Gets or sets a boolean indicating if textures are enabled on this scene
  33270. */
  33271. texturesEnabled: boolean;
  33272. /**
  33273. * Gets or sets a boolean indicating if particles are enabled on this scene
  33274. */
  33275. particlesEnabled: boolean;
  33276. /**
  33277. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33278. */
  33279. spritesEnabled: boolean;
  33280. private _skeletonsEnabled;
  33281. /**
  33282. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33283. */
  33284. skeletonsEnabled: boolean;
  33285. /**
  33286. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33287. */
  33288. lensFlaresEnabled: boolean;
  33289. /**
  33290. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33291. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33292. */
  33293. collisionsEnabled: boolean;
  33294. private _collisionCoordinator;
  33295. /** @hidden */
  33296. readonly collisionCoordinator: ICollisionCoordinator;
  33297. /**
  33298. * Defines the gravity applied to this scene (used only for collisions)
  33299. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33300. */
  33301. gravity: Vector3;
  33302. /**
  33303. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33304. */
  33305. postProcessesEnabled: boolean;
  33306. /**
  33307. * The list of postprocesses added to the scene
  33308. */
  33309. postProcesses: PostProcess[];
  33310. /**
  33311. * Gets the current postprocess manager
  33312. */
  33313. postProcessManager: PostProcessManager;
  33314. /**
  33315. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33316. */
  33317. renderTargetsEnabled: boolean;
  33318. /**
  33319. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33320. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33321. */
  33322. dumpNextRenderTargets: boolean;
  33323. /**
  33324. * The list of user defined render targets added to the scene
  33325. */
  33326. customRenderTargets: RenderTargetTexture[];
  33327. /**
  33328. * Defines if texture loading must be delayed
  33329. * If true, textures will only be loaded when they need to be rendered
  33330. */
  33331. useDelayedTextureLoading: boolean;
  33332. /**
  33333. * Gets the list of meshes imported to the scene through SceneLoader
  33334. */
  33335. importedMeshesFiles: String[];
  33336. /**
  33337. * Gets or sets a boolean indicating if probes are enabled on this scene
  33338. */
  33339. probesEnabled: boolean;
  33340. /**
  33341. * Gets or sets the current offline provider to use to store scene data
  33342. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33343. */
  33344. offlineProvider: IOfflineProvider;
  33345. /**
  33346. * Gets or sets the action manager associated with the scene
  33347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33348. */
  33349. actionManager: AbstractActionManager;
  33350. private _meshesForIntersections;
  33351. /**
  33352. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33353. */
  33354. proceduralTexturesEnabled: boolean;
  33355. private _engine;
  33356. private _totalVertices;
  33357. /** @hidden */
  33358. _activeIndices: PerfCounter;
  33359. /** @hidden */
  33360. _activeParticles: PerfCounter;
  33361. /** @hidden */
  33362. _activeBones: PerfCounter;
  33363. private _animationRatio;
  33364. /** @hidden */
  33365. _animationTimeLast: number;
  33366. /** @hidden */
  33367. _animationTime: number;
  33368. /**
  33369. * Gets or sets a general scale for animation speed
  33370. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33371. */
  33372. animationTimeScale: number;
  33373. /** @hidden */
  33374. _cachedMaterial: Nullable<Material>;
  33375. /** @hidden */
  33376. _cachedEffect: Nullable<Effect>;
  33377. /** @hidden */
  33378. _cachedVisibility: Nullable<number>;
  33379. private _renderId;
  33380. private _frameId;
  33381. private _executeWhenReadyTimeoutId;
  33382. private _intermediateRendering;
  33383. private _viewUpdateFlag;
  33384. private _projectionUpdateFlag;
  33385. /** @hidden */
  33386. _toBeDisposed: Nullable<IDisposable>[];
  33387. private _activeRequests;
  33388. /** @hidden */
  33389. _pendingData: any[];
  33390. private _isDisposed;
  33391. /**
  33392. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33393. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33394. */
  33395. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33396. private _activeMeshes;
  33397. private _processedMaterials;
  33398. private _renderTargets;
  33399. /** @hidden */
  33400. _activeParticleSystems: SmartArray<IParticleSystem>;
  33401. private _activeSkeletons;
  33402. private _softwareSkinnedMeshes;
  33403. private _renderingManager;
  33404. /** @hidden */
  33405. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33406. private _transformMatrix;
  33407. private _sceneUbo;
  33408. /** @hidden */
  33409. _viewMatrix: Matrix;
  33410. private _projectionMatrix;
  33411. /** @hidden */
  33412. _forcedViewPosition: Nullable<Vector3>;
  33413. /** @hidden */
  33414. _frustumPlanes: Plane[];
  33415. /**
  33416. * Gets the list of frustum planes (built from the active camera)
  33417. */
  33418. readonly frustumPlanes: Plane[];
  33419. /**
  33420. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33421. * This is useful if there are more lights that the maximum simulteanous authorized
  33422. */
  33423. requireLightSorting: boolean;
  33424. /** @hidden */
  33425. readonly useMaterialMeshMap: boolean;
  33426. /** @hidden */
  33427. readonly useClonedMeshhMap: boolean;
  33428. private _externalData;
  33429. private _uid;
  33430. /**
  33431. * @hidden
  33432. * Backing store of defined scene components.
  33433. */
  33434. _components: ISceneComponent[];
  33435. /**
  33436. * @hidden
  33437. * Backing store of defined scene components.
  33438. */
  33439. _serializableComponents: ISceneSerializableComponent[];
  33440. /**
  33441. * List of components to register on the next registration step.
  33442. */
  33443. private _transientComponents;
  33444. /**
  33445. * Registers the transient components if needed.
  33446. */
  33447. private _registerTransientComponents;
  33448. /**
  33449. * @hidden
  33450. * Add a component to the scene.
  33451. * Note that the ccomponent could be registered on th next frame if this is called after
  33452. * the register component stage.
  33453. * @param component Defines the component to add to the scene
  33454. */
  33455. _addComponent(component: ISceneComponent): void;
  33456. /**
  33457. * @hidden
  33458. * Gets a component from the scene.
  33459. * @param name defines the name of the component to retrieve
  33460. * @returns the component or null if not present
  33461. */
  33462. _getComponent(name: string): Nullable<ISceneComponent>;
  33463. /**
  33464. * @hidden
  33465. * Defines the actions happening before camera updates.
  33466. */
  33467. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33468. /**
  33469. * @hidden
  33470. * Defines the actions happening before clear the canvas.
  33471. */
  33472. _beforeClearStage: Stage<SimpleStageAction>;
  33473. /**
  33474. * @hidden
  33475. * Defines the actions when collecting render targets for the frame.
  33476. */
  33477. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33478. /**
  33479. * @hidden
  33480. * Defines the actions happening for one camera in the frame.
  33481. */
  33482. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33483. /**
  33484. * @hidden
  33485. * Defines the actions happening during the per mesh ready checks.
  33486. */
  33487. _isReadyForMeshStage: Stage<MeshStageAction>;
  33488. /**
  33489. * @hidden
  33490. * Defines the actions happening before evaluate active mesh checks.
  33491. */
  33492. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33493. /**
  33494. * @hidden
  33495. * Defines the actions happening during the evaluate sub mesh checks.
  33496. */
  33497. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33498. /**
  33499. * @hidden
  33500. * Defines the actions happening during the active mesh stage.
  33501. */
  33502. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33503. /**
  33504. * @hidden
  33505. * Defines the actions happening during the per camera render target step.
  33506. */
  33507. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33508. /**
  33509. * @hidden
  33510. * Defines the actions happening just before the active camera is drawing.
  33511. */
  33512. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33513. /**
  33514. * @hidden
  33515. * Defines the actions happening just before a render target is drawing.
  33516. */
  33517. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33518. /**
  33519. * @hidden
  33520. * Defines the actions happening just before a rendering group is drawing.
  33521. */
  33522. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33523. /**
  33524. * @hidden
  33525. * Defines the actions happening just before a mesh is drawing.
  33526. */
  33527. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33528. /**
  33529. * @hidden
  33530. * Defines the actions happening just after a mesh has been drawn.
  33531. */
  33532. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33533. /**
  33534. * @hidden
  33535. * Defines the actions happening just after a rendering group has been drawn.
  33536. */
  33537. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33538. /**
  33539. * @hidden
  33540. * Defines the actions happening just after the active camera has been drawn.
  33541. */
  33542. _afterCameraDrawStage: Stage<CameraStageAction>;
  33543. /**
  33544. * @hidden
  33545. * Defines the actions happening just after a render target has been drawn.
  33546. */
  33547. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33548. /**
  33549. * @hidden
  33550. * Defines the actions happening just after rendering all cameras and computing intersections.
  33551. */
  33552. _afterRenderStage: Stage<SimpleStageAction>;
  33553. /**
  33554. * @hidden
  33555. * Defines the actions happening when a pointer move event happens.
  33556. */
  33557. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33558. /**
  33559. * @hidden
  33560. * Defines the actions happening when a pointer down event happens.
  33561. */
  33562. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33563. /**
  33564. * @hidden
  33565. * Defines the actions happening when a pointer up event happens.
  33566. */
  33567. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33568. /**
  33569. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33570. */
  33571. private geometriesByUniqueId;
  33572. /**
  33573. * Creates a new Scene
  33574. * @param engine defines the engine to use to render this scene
  33575. * @param options defines the scene options
  33576. */
  33577. constructor(engine: Engine, options?: SceneOptions);
  33578. /**
  33579. * Gets a string idenfifying the name of the class
  33580. * @returns "Scene" string
  33581. */
  33582. getClassName(): string;
  33583. private _defaultMeshCandidates;
  33584. /**
  33585. * @hidden
  33586. */
  33587. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33588. private _defaultSubMeshCandidates;
  33589. /**
  33590. * @hidden
  33591. */
  33592. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33593. /**
  33594. * Sets the default candidate providers for the scene.
  33595. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33596. * and getCollidingSubMeshCandidates to their default function
  33597. */
  33598. setDefaultCandidateProviders(): void;
  33599. /**
  33600. * Gets the mesh that is currently under the pointer
  33601. */
  33602. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33603. /**
  33604. * Gets or sets the current on-screen X position of the pointer
  33605. */
  33606. pointerX: number;
  33607. /**
  33608. * Gets or sets the current on-screen Y position of the pointer
  33609. */
  33610. pointerY: number;
  33611. /**
  33612. * Gets the cached material (ie. the latest rendered one)
  33613. * @returns the cached material
  33614. */
  33615. getCachedMaterial(): Nullable<Material>;
  33616. /**
  33617. * Gets the cached effect (ie. the latest rendered one)
  33618. * @returns the cached effect
  33619. */
  33620. getCachedEffect(): Nullable<Effect>;
  33621. /**
  33622. * Gets the cached visibility state (ie. the latest rendered one)
  33623. * @returns the cached visibility state
  33624. */
  33625. getCachedVisibility(): Nullable<number>;
  33626. /**
  33627. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33628. * @param material defines the current material
  33629. * @param effect defines the current effect
  33630. * @param visibility defines the current visibility state
  33631. * @returns true if one parameter is not cached
  33632. */
  33633. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33634. /**
  33635. * Gets the engine associated with the scene
  33636. * @returns an Engine
  33637. */
  33638. getEngine(): Engine;
  33639. /**
  33640. * Gets the total number of vertices rendered per frame
  33641. * @returns the total number of vertices rendered per frame
  33642. */
  33643. getTotalVertices(): number;
  33644. /**
  33645. * Gets the performance counter for total vertices
  33646. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33647. */
  33648. readonly totalVerticesPerfCounter: PerfCounter;
  33649. /**
  33650. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33651. * @returns the total number of active indices rendered per frame
  33652. */
  33653. getActiveIndices(): number;
  33654. /**
  33655. * Gets the performance counter for active indices
  33656. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33657. */
  33658. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33659. /**
  33660. * Gets the total number of active particles rendered per frame
  33661. * @returns the total number of active particles rendered per frame
  33662. */
  33663. getActiveParticles(): number;
  33664. /**
  33665. * Gets the performance counter for active particles
  33666. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33667. */
  33668. readonly activeParticlesPerfCounter: PerfCounter;
  33669. /**
  33670. * Gets the total number of active bones rendered per frame
  33671. * @returns the total number of active bones rendered per frame
  33672. */
  33673. getActiveBones(): number;
  33674. /**
  33675. * Gets the performance counter for active bones
  33676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33677. */
  33678. readonly activeBonesPerfCounter: PerfCounter;
  33679. /**
  33680. * Gets the array of active meshes
  33681. * @returns an array of AbstractMesh
  33682. */
  33683. getActiveMeshes(): SmartArray<AbstractMesh>;
  33684. /**
  33685. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33686. * @returns a number
  33687. */
  33688. getAnimationRatio(): number;
  33689. /**
  33690. * Gets an unique Id for the current render phase
  33691. * @returns a number
  33692. */
  33693. getRenderId(): number;
  33694. /**
  33695. * Gets an unique Id for the current frame
  33696. * @returns a number
  33697. */
  33698. getFrameId(): number;
  33699. /** Call this function if you want to manually increment the render Id*/
  33700. incrementRenderId(): void;
  33701. private _createUbo;
  33702. /**
  33703. * Use this method to simulate a pointer move on a mesh
  33704. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33705. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33706. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33707. * @returns the current scene
  33708. */
  33709. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33710. /**
  33711. * Use this method to simulate a pointer down on a mesh
  33712. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33713. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33714. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33715. * @returns the current scene
  33716. */
  33717. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33718. /**
  33719. * Use this method to simulate a pointer up on a mesh
  33720. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33721. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33722. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33723. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33724. * @returns the current scene
  33725. */
  33726. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33727. /**
  33728. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33729. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33730. * @returns true if the pointer was captured
  33731. */
  33732. isPointerCaptured(pointerId?: number): boolean;
  33733. /**
  33734. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33735. * @param attachUp defines if you want to attach events to pointerup
  33736. * @param attachDown defines if you want to attach events to pointerdown
  33737. * @param attachMove defines if you want to attach events to pointermove
  33738. */
  33739. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33740. /** Detaches all event handlers*/
  33741. detachControl(): void;
  33742. /**
  33743. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33744. * Delay loaded resources are not taking in account
  33745. * @return true if all required resources are ready
  33746. */
  33747. isReady(): boolean;
  33748. /** Resets all cached information relative to material (including effect and visibility) */
  33749. resetCachedMaterial(): void;
  33750. /**
  33751. * Registers a function to be called before every frame render
  33752. * @param func defines the function to register
  33753. */
  33754. registerBeforeRender(func: () => void): void;
  33755. /**
  33756. * Unregisters a function called before every frame render
  33757. * @param func defines the function to unregister
  33758. */
  33759. unregisterBeforeRender(func: () => void): void;
  33760. /**
  33761. * Registers a function to be called after every frame render
  33762. * @param func defines the function to register
  33763. */
  33764. registerAfterRender(func: () => void): void;
  33765. /**
  33766. * Unregisters a function called after every frame render
  33767. * @param func defines the function to unregister
  33768. */
  33769. unregisterAfterRender(func: () => void): void;
  33770. private _executeOnceBeforeRender;
  33771. /**
  33772. * The provided function will run before render once and will be disposed afterwards.
  33773. * A timeout delay can be provided so that the function will be executed in N ms.
  33774. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33775. * @param func The function to be executed.
  33776. * @param timeout optional delay in ms
  33777. */
  33778. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33779. /** @hidden */
  33780. _addPendingData(data: any): void;
  33781. /** @hidden */
  33782. _removePendingData(data: any): void;
  33783. /**
  33784. * Returns the number of items waiting to be loaded
  33785. * @returns the number of items waiting to be loaded
  33786. */
  33787. getWaitingItemsCount(): number;
  33788. /**
  33789. * Returns a boolean indicating if the scene is still loading data
  33790. */
  33791. readonly isLoading: boolean;
  33792. /**
  33793. * Registers a function to be executed when the scene is ready
  33794. * @param {Function} func - the function to be executed
  33795. */
  33796. executeWhenReady(func: () => void): void;
  33797. /**
  33798. * Returns a promise that resolves when the scene is ready
  33799. * @returns A promise that resolves when the scene is ready
  33800. */
  33801. whenReadyAsync(): Promise<void>;
  33802. /** @hidden */
  33803. _checkIsReady(): void;
  33804. /**
  33805. * Gets all animatable attached to the scene
  33806. */
  33807. readonly animatables: Animatable[];
  33808. /**
  33809. * Resets the last animation time frame.
  33810. * Useful to override when animations start running when loading a scene for the first time.
  33811. */
  33812. resetLastAnimationTimeFrame(): void;
  33813. /**
  33814. * Gets the current view matrix
  33815. * @returns a Matrix
  33816. */
  33817. getViewMatrix(): Matrix;
  33818. /**
  33819. * Gets the current projection matrix
  33820. * @returns a Matrix
  33821. */
  33822. getProjectionMatrix(): Matrix;
  33823. /**
  33824. * Gets the current transform matrix
  33825. * @returns a Matrix made of View * Projection
  33826. */
  33827. getTransformMatrix(): Matrix;
  33828. /**
  33829. * Sets the current transform matrix
  33830. * @param viewL defines the View matrix to use
  33831. * @param projectionL defines the Projection matrix to use
  33832. * @param viewR defines the right View matrix to use (if provided)
  33833. * @param projectionR defines the right Projection matrix to use (if provided)
  33834. */
  33835. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33836. /**
  33837. * Gets the uniform buffer used to store scene data
  33838. * @returns a UniformBuffer
  33839. */
  33840. getSceneUniformBuffer(): UniformBuffer;
  33841. /**
  33842. * Gets an unique (relatively to the current scene) Id
  33843. * @returns an unique number for the scene
  33844. */
  33845. getUniqueId(): number;
  33846. /**
  33847. * Add a mesh to the list of scene's meshes
  33848. * @param newMesh defines the mesh to add
  33849. * @param recursive if all child meshes should also be added to the scene
  33850. */
  33851. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33852. /**
  33853. * Remove a mesh for the list of scene's meshes
  33854. * @param toRemove defines the mesh to remove
  33855. * @param recursive if all child meshes should also be removed from the scene
  33856. * @returns the index where the mesh was in the mesh list
  33857. */
  33858. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33859. /**
  33860. * Add a transform node to the list of scene's transform nodes
  33861. * @param newTransformNode defines the transform node to add
  33862. */
  33863. addTransformNode(newTransformNode: TransformNode): void;
  33864. /**
  33865. * Remove a transform node for the list of scene's transform nodes
  33866. * @param toRemove defines the transform node to remove
  33867. * @returns the index where the transform node was in the transform node list
  33868. */
  33869. removeTransformNode(toRemove: TransformNode): number;
  33870. /**
  33871. * Remove a skeleton for the list of scene's skeletons
  33872. * @param toRemove defines the skeleton to remove
  33873. * @returns the index where the skeleton was in the skeleton list
  33874. */
  33875. removeSkeleton(toRemove: Skeleton): number;
  33876. /**
  33877. * Remove a morph target for the list of scene's morph targets
  33878. * @param toRemove defines the morph target to remove
  33879. * @returns the index where the morph target was in the morph target list
  33880. */
  33881. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33882. /**
  33883. * Remove a light for the list of scene's lights
  33884. * @param toRemove defines the light to remove
  33885. * @returns the index where the light was in the light list
  33886. */
  33887. removeLight(toRemove: Light): number;
  33888. /**
  33889. * Remove a camera for the list of scene's cameras
  33890. * @param toRemove defines the camera to remove
  33891. * @returns the index where the camera was in the camera list
  33892. */
  33893. removeCamera(toRemove: Camera): number;
  33894. /**
  33895. * Remove a particle system for the list of scene's particle systems
  33896. * @param toRemove defines the particle system to remove
  33897. * @returns the index where the particle system was in the particle system list
  33898. */
  33899. removeParticleSystem(toRemove: IParticleSystem): number;
  33900. /**
  33901. * Remove a animation for the list of scene's animations
  33902. * @param toRemove defines the animation to remove
  33903. * @returns the index where the animation was in the animation list
  33904. */
  33905. removeAnimation(toRemove: Animation): number;
  33906. /**
  33907. * Will stop the animation of the given target
  33908. * @param target - the target
  33909. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33910. * @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)
  33911. */
  33912. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33913. /**
  33914. * Removes the given animation group from this scene.
  33915. * @param toRemove The animation group to remove
  33916. * @returns The index of the removed animation group
  33917. */
  33918. removeAnimationGroup(toRemove: AnimationGroup): number;
  33919. /**
  33920. * Removes the given multi-material from this scene.
  33921. * @param toRemove The multi-material to remove
  33922. * @returns The index of the removed multi-material
  33923. */
  33924. removeMultiMaterial(toRemove: MultiMaterial): number;
  33925. /**
  33926. * Removes the given material from this scene.
  33927. * @param toRemove The material to remove
  33928. * @returns The index of the removed material
  33929. */
  33930. removeMaterial(toRemove: Material): number;
  33931. /**
  33932. * Removes the given action manager from this scene.
  33933. * @param toRemove The action manager to remove
  33934. * @returns The index of the removed action manager
  33935. */
  33936. removeActionManager(toRemove: AbstractActionManager): number;
  33937. /**
  33938. * Removes the given texture from this scene.
  33939. * @param toRemove The texture to remove
  33940. * @returns The index of the removed texture
  33941. */
  33942. removeTexture(toRemove: BaseTexture): number;
  33943. /**
  33944. * Adds the given light to this scene
  33945. * @param newLight The light to add
  33946. */
  33947. addLight(newLight: Light): void;
  33948. /**
  33949. * Sorts the list list based on light priorities
  33950. */
  33951. sortLightsByPriority(): void;
  33952. /**
  33953. * Adds the given camera to this scene
  33954. * @param newCamera The camera to add
  33955. */
  33956. addCamera(newCamera: Camera): void;
  33957. /**
  33958. * Adds the given skeleton to this scene
  33959. * @param newSkeleton The skeleton to add
  33960. */
  33961. addSkeleton(newSkeleton: Skeleton): void;
  33962. /**
  33963. * Adds the given particle system to this scene
  33964. * @param newParticleSystem The particle system to add
  33965. */
  33966. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33967. /**
  33968. * Adds the given animation to this scene
  33969. * @param newAnimation The animation to add
  33970. */
  33971. addAnimation(newAnimation: Animation): void;
  33972. /**
  33973. * Adds the given animation group to this scene.
  33974. * @param newAnimationGroup The animation group to add
  33975. */
  33976. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33977. /**
  33978. * Adds the given multi-material to this scene
  33979. * @param newMultiMaterial The multi-material to add
  33980. */
  33981. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33982. /**
  33983. * Adds the given material to this scene
  33984. * @param newMaterial The material to add
  33985. */
  33986. addMaterial(newMaterial: Material): void;
  33987. /**
  33988. * Adds the given morph target to this scene
  33989. * @param newMorphTargetManager The morph target to add
  33990. */
  33991. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33992. /**
  33993. * Adds the given geometry to this scene
  33994. * @param newGeometry The geometry to add
  33995. */
  33996. addGeometry(newGeometry: Geometry): void;
  33997. /**
  33998. * Adds the given action manager to this scene
  33999. * @param newActionManager The action manager to add
  34000. */
  34001. addActionManager(newActionManager: AbstractActionManager): void;
  34002. /**
  34003. * Adds the given texture to this scene.
  34004. * @param newTexture The texture to add
  34005. */
  34006. addTexture(newTexture: BaseTexture): void;
  34007. /**
  34008. * Switch active camera
  34009. * @param newCamera defines the new active camera
  34010. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34011. */
  34012. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34013. /**
  34014. * sets the active camera of the scene using its ID
  34015. * @param id defines the camera's ID
  34016. * @return the new active camera or null if none found.
  34017. */
  34018. setActiveCameraByID(id: string): Nullable<Camera>;
  34019. /**
  34020. * sets the active camera of the scene using its name
  34021. * @param name defines the camera's name
  34022. * @returns the new active camera or null if none found.
  34023. */
  34024. setActiveCameraByName(name: string): Nullable<Camera>;
  34025. /**
  34026. * get an animation group using its name
  34027. * @param name defines the material's name
  34028. * @return the animation group or null if none found.
  34029. */
  34030. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34031. /**
  34032. * Get a material using its unique id
  34033. * @param uniqueId defines the material's unique id
  34034. * @return the material or null if none found.
  34035. */
  34036. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34037. /**
  34038. * get a material using its id
  34039. * @param id defines the material's ID
  34040. * @return the material or null if none found.
  34041. */
  34042. getMaterialByID(id: string): Nullable<Material>;
  34043. /**
  34044. * Gets a material using its name
  34045. * @param name defines the material's name
  34046. * @return the material or null if none found.
  34047. */
  34048. getMaterialByName(name: string): Nullable<Material>;
  34049. /**
  34050. * Gets a camera using its id
  34051. * @param id defines the id to look for
  34052. * @returns the camera or null if not found
  34053. */
  34054. getCameraByID(id: string): Nullable<Camera>;
  34055. /**
  34056. * Gets a camera using its unique id
  34057. * @param uniqueId defines the unique id to look for
  34058. * @returns the camera or null if not found
  34059. */
  34060. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34061. /**
  34062. * Gets a camera using its name
  34063. * @param name defines the camera's name
  34064. * @return the camera or null if none found.
  34065. */
  34066. getCameraByName(name: string): Nullable<Camera>;
  34067. /**
  34068. * Gets a bone using its id
  34069. * @param id defines the bone's id
  34070. * @return the bone or null if not found
  34071. */
  34072. getBoneByID(id: string): Nullable<Bone>;
  34073. /**
  34074. * Gets a bone using its id
  34075. * @param name defines the bone's name
  34076. * @return the bone or null if not found
  34077. */
  34078. getBoneByName(name: string): Nullable<Bone>;
  34079. /**
  34080. * Gets a light node using its name
  34081. * @param name defines the the light's name
  34082. * @return the light or null if none found.
  34083. */
  34084. getLightByName(name: string): Nullable<Light>;
  34085. /**
  34086. * Gets a light node using its id
  34087. * @param id defines the light's id
  34088. * @return the light or null if none found.
  34089. */
  34090. getLightByID(id: string): Nullable<Light>;
  34091. /**
  34092. * Gets a light node using its scene-generated unique ID
  34093. * @param uniqueId defines the light's unique id
  34094. * @return the light or null if none found.
  34095. */
  34096. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34097. /**
  34098. * Gets a particle system by id
  34099. * @param id defines the particle system id
  34100. * @return the corresponding system or null if none found
  34101. */
  34102. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34103. /**
  34104. * Gets a geometry using its ID
  34105. * @param id defines the geometry's id
  34106. * @return the geometry or null if none found.
  34107. */
  34108. getGeometryByID(id: string): Nullable<Geometry>;
  34109. private _getGeometryByUniqueID;
  34110. /**
  34111. * Add a new geometry to this scene
  34112. * @param geometry defines the geometry to be added to the scene.
  34113. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34114. * @return a boolean defining if the geometry was added or not
  34115. */
  34116. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34117. /**
  34118. * Removes an existing geometry
  34119. * @param geometry defines the geometry to be removed from the scene
  34120. * @return a boolean defining if the geometry was removed or not
  34121. */
  34122. removeGeometry(geometry: Geometry): boolean;
  34123. /**
  34124. * Gets the list of geometries attached to the scene
  34125. * @returns an array of Geometry
  34126. */
  34127. getGeometries(): Geometry[];
  34128. /**
  34129. * Gets the first added mesh found of a given ID
  34130. * @param id defines the id to search for
  34131. * @return the mesh found or null if not found at all
  34132. */
  34133. getMeshByID(id: string): Nullable<AbstractMesh>;
  34134. /**
  34135. * Gets a list of meshes using their id
  34136. * @param id defines the id to search for
  34137. * @returns a list of meshes
  34138. */
  34139. getMeshesByID(id: string): Array<AbstractMesh>;
  34140. /**
  34141. * Gets the first added transform node found of a given ID
  34142. * @param id defines the id to search for
  34143. * @return the found transform node or null if not found at all.
  34144. */
  34145. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34146. /**
  34147. * Gets a transform node with its auto-generated unique id
  34148. * @param uniqueId efines the unique id to search for
  34149. * @return the found transform node or null if not found at all.
  34150. */
  34151. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34152. /**
  34153. * Gets a list of transform nodes using their id
  34154. * @param id defines the id to search for
  34155. * @returns a list of transform nodes
  34156. */
  34157. getTransformNodesByID(id: string): Array<TransformNode>;
  34158. /**
  34159. * Gets a mesh with its auto-generated unique id
  34160. * @param uniqueId defines the unique id to search for
  34161. * @return the found mesh or null if not found at all.
  34162. */
  34163. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34164. /**
  34165. * Gets a the last added mesh using a given id
  34166. * @param id defines the id to search for
  34167. * @return the found mesh or null if not found at all.
  34168. */
  34169. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34170. /**
  34171. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34172. * @param id defines the id to search for
  34173. * @return the found node or null if not found at all
  34174. */
  34175. getLastEntryByID(id: string): Nullable<Node>;
  34176. /**
  34177. * Gets a node (Mesh, Camera, Light) using a given id
  34178. * @param id defines the id to search for
  34179. * @return the found node or null if not found at all
  34180. */
  34181. getNodeByID(id: string): Nullable<Node>;
  34182. /**
  34183. * Gets a node (Mesh, Camera, Light) using a given name
  34184. * @param name defines the name to search for
  34185. * @return the found node or null if not found at all.
  34186. */
  34187. getNodeByName(name: string): Nullable<Node>;
  34188. /**
  34189. * Gets a mesh using a given name
  34190. * @param name defines the name to search for
  34191. * @return the found mesh or null if not found at all.
  34192. */
  34193. getMeshByName(name: string): Nullable<AbstractMesh>;
  34194. /**
  34195. * Gets a transform node using a given name
  34196. * @param name defines the name to search for
  34197. * @return the found transform node or null if not found at all.
  34198. */
  34199. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34200. /**
  34201. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34202. * @param id defines the id to search for
  34203. * @return the found skeleton or null if not found at all.
  34204. */
  34205. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34206. /**
  34207. * Gets a skeleton using a given auto generated unique id
  34208. * @param uniqueId defines the unique id to search for
  34209. * @return the found skeleton or null if not found at all.
  34210. */
  34211. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34212. /**
  34213. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34214. * @param id defines the id to search for
  34215. * @return the found skeleton or null if not found at all.
  34216. */
  34217. getSkeletonById(id: string): Nullable<Skeleton>;
  34218. /**
  34219. * Gets a skeleton using a given name
  34220. * @param name defines the name to search for
  34221. * @return the found skeleton or null if not found at all.
  34222. */
  34223. getSkeletonByName(name: string): Nullable<Skeleton>;
  34224. /**
  34225. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34226. * @param id defines the id to search for
  34227. * @return the found morph target manager or null if not found at all.
  34228. */
  34229. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34230. /**
  34231. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34232. * @param id defines the id to search for
  34233. * @return the found morph target or null if not found at all.
  34234. */
  34235. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34236. /**
  34237. * Gets a boolean indicating if the given mesh is active
  34238. * @param mesh defines the mesh to look for
  34239. * @returns true if the mesh is in the active list
  34240. */
  34241. isActiveMesh(mesh: AbstractMesh): boolean;
  34242. /**
  34243. * Return a unique id as a string which can serve as an identifier for the scene
  34244. */
  34245. readonly uid: string;
  34246. /**
  34247. * Add an externaly attached data from its key.
  34248. * This method call will fail and return false, if such key already exists.
  34249. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34250. * @param key the unique key that identifies the data
  34251. * @param data the data object to associate to the key for this Engine instance
  34252. * @return true if no such key were already present and the data was added successfully, false otherwise
  34253. */
  34254. addExternalData<T>(key: string, data: T): boolean;
  34255. /**
  34256. * Get an externaly attached data from its key
  34257. * @param key the unique key that identifies the data
  34258. * @return the associated data, if present (can be null), or undefined if not present
  34259. */
  34260. getExternalData<T>(key: string): Nullable<T>;
  34261. /**
  34262. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34263. * @param key the unique key that identifies the data
  34264. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34265. * @return the associated data, can be null if the factory returned null.
  34266. */
  34267. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34268. /**
  34269. * Remove an externaly attached data from the Engine instance
  34270. * @param key the unique key that identifies the data
  34271. * @return true if the data was successfully removed, false if it doesn't exist
  34272. */
  34273. removeExternalData(key: string): boolean;
  34274. private _evaluateSubMesh;
  34275. /**
  34276. * Clear the processed materials smart array preventing retention point in material dispose.
  34277. */
  34278. freeProcessedMaterials(): void;
  34279. private _preventFreeActiveMeshesAndRenderingGroups;
  34280. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34281. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34282. * when disposing several meshes in a row or a hierarchy of meshes.
  34283. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34284. */
  34285. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34286. /**
  34287. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34288. */
  34289. freeActiveMeshes(): void;
  34290. /**
  34291. * Clear the info related to rendering groups preventing retention points during dispose.
  34292. */
  34293. freeRenderingGroups(): void;
  34294. /** @hidden */
  34295. _isInIntermediateRendering(): boolean;
  34296. /**
  34297. * Lambda returning the list of potentially active meshes.
  34298. */
  34299. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34300. /**
  34301. * Lambda returning the list of potentially active sub meshes.
  34302. */
  34303. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34304. /**
  34305. * Lambda returning the list of potentially intersecting sub meshes.
  34306. */
  34307. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34308. /**
  34309. * Lambda returning the list of potentially colliding sub meshes.
  34310. */
  34311. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34312. private _activeMeshesFrozen;
  34313. /**
  34314. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34315. * @returns the current scene
  34316. */
  34317. freezeActiveMeshes(): Scene;
  34318. /**
  34319. * Use this function to restart evaluating active meshes on every frame
  34320. * @returns the current scene
  34321. */
  34322. unfreezeActiveMeshes(): Scene;
  34323. private _evaluateActiveMeshes;
  34324. private _activeMesh;
  34325. /**
  34326. * Update the transform matrix to update from the current active camera
  34327. * @param force defines a boolean used to force the update even if cache is up to date
  34328. */
  34329. updateTransformMatrix(force?: boolean): void;
  34330. private _bindFrameBuffer;
  34331. /** @hidden */
  34332. _allowPostProcessClearColor: boolean;
  34333. /** @hidden */
  34334. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34335. private _processSubCameras;
  34336. private _checkIntersections;
  34337. /** @hidden */
  34338. _advancePhysicsEngineStep(step: number): void;
  34339. /**
  34340. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34341. */
  34342. getDeterministicFrameTime: () => number;
  34343. /** @hidden */
  34344. _animate(): void;
  34345. /** Execute all animations (for a frame) */
  34346. animate(): void;
  34347. /**
  34348. * Render the scene
  34349. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34350. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34351. */
  34352. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34353. /**
  34354. * Freeze all materials
  34355. * A frozen material will not be updatable but should be faster to render
  34356. */
  34357. freezeMaterials(): void;
  34358. /**
  34359. * Unfreeze all materials
  34360. * A frozen material will not be updatable but should be faster to render
  34361. */
  34362. unfreezeMaterials(): void;
  34363. /**
  34364. * Releases all held ressources
  34365. */
  34366. dispose(): void;
  34367. /**
  34368. * Gets if the scene is already disposed
  34369. */
  34370. readonly isDisposed: boolean;
  34371. /**
  34372. * Call this function to reduce memory footprint of the scene.
  34373. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34374. */
  34375. clearCachedVertexData(): void;
  34376. /**
  34377. * This function will remove the local cached buffer data from texture.
  34378. * It will save memory but will prevent the texture from being rebuilt
  34379. */
  34380. cleanCachedTextureBuffer(): void;
  34381. /**
  34382. * Get the world extend vectors with an optional filter
  34383. *
  34384. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34385. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34386. */
  34387. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34388. min: Vector3;
  34389. max: Vector3;
  34390. };
  34391. /**
  34392. * Creates a ray that can be used to pick in the scene
  34393. * @param x defines the x coordinate of the origin (on-screen)
  34394. * @param y defines the y coordinate of the origin (on-screen)
  34395. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34396. * @param camera defines the camera to use for the picking
  34397. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34398. * @returns a Ray
  34399. */
  34400. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34401. /**
  34402. * Creates a ray that can be used to pick in the scene
  34403. * @param x defines the x coordinate of the origin (on-screen)
  34404. * @param y defines the y coordinate of the origin (on-screen)
  34405. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34406. * @param result defines the ray where to store the picking ray
  34407. * @param camera defines the camera to use for the picking
  34408. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34409. * @returns the current scene
  34410. */
  34411. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34412. /**
  34413. * Creates a ray that can be used to pick in the scene
  34414. * @param x defines the x coordinate of the origin (on-screen)
  34415. * @param y defines the y coordinate of the origin (on-screen)
  34416. * @param camera defines the camera to use for the picking
  34417. * @returns a Ray
  34418. */
  34419. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34420. /**
  34421. * Creates a ray that can be used to pick in the scene
  34422. * @param x defines the x coordinate of the origin (on-screen)
  34423. * @param y defines the y coordinate of the origin (on-screen)
  34424. * @param result defines the ray where to store the picking ray
  34425. * @param camera defines the camera to use for the picking
  34426. * @returns the current scene
  34427. */
  34428. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34429. /** Launch a ray to try to pick a mesh in the scene
  34430. * @param x position on screen
  34431. * @param y position on screen
  34432. * @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
  34433. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34434. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34435. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34436. * @returns a PickingInfo
  34437. */
  34438. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34439. /** Use the given ray to pick a mesh in the scene
  34440. * @param ray The ray to use to pick meshes
  34441. * @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
  34442. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34443. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34444. * @returns a PickingInfo
  34445. */
  34446. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34447. /**
  34448. * Launch a ray to try to pick a mesh in the scene
  34449. * @param x X position on screen
  34450. * @param y Y position on screen
  34451. * @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
  34452. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34453. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34454. * @returns an array of PickingInfo
  34455. */
  34456. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34457. /**
  34458. * Launch a ray to try to pick a mesh in the scene
  34459. * @param ray Ray to use
  34460. * @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
  34461. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34462. * @returns an array of PickingInfo
  34463. */
  34464. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34465. /**
  34466. * Force the value of meshUnderPointer
  34467. * @param mesh defines the mesh to use
  34468. */
  34469. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34470. /**
  34471. * Gets the mesh under the pointer
  34472. * @returns a Mesh or null if no mesh is under the pointer
  34473. */
  34474. getPointerOverMesh(): Nullable<AbstractMesh>;
  34475. /** @hidden */
  34476. _rebuildGeometries(): void;
  34477. /** @hidden */
  34478. _rebuildTextures(): void;
  34479. private _getByTags;
  34480. /**
  34481. * Get a list of meshes by tags
  34482. * @param tagsQuery defines the tags query to use
  34483. * @param forEach defines a predicate used to filter results
  34484. * @returns an array of Mesh
  34485. */
  34486. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34487. /**
  34488. * Get a list of cameras by tags
  34489. * @param tagsQuery defines the tags query to use
  34490. * @param forEach defines a predicate used to filter results
  34491. * @returns an array of Camera
  34492. */
  34493. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34494. /**
  34495. * Get a list of lights by tags
  34496. * @param tagsQuery defines the tags query to use
  34497. * @param forEach defines a predicate used to filter results
  34498. * @returns an array of Light
  34499. */
  34500. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34501. /**
  34502. * Get a list of materials by tags
  34503. * @param tagsQuery defines the tags query to use
  34504. * @param forEach defines a predicate used to filter results
  34505. * @returns an array of Material
  34506. */
  34507. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34508. /**
  34509. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34510. * This allowed control for front to back rendering or reversly depending of the special needs.
  34511. *
  34512. * @param renderingGroupId The rendering group id corresponding to its index
  34513. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34514. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34515. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34516. */
  34517. 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;
  34518. /**
  34519. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34520. *
  34521. * @param renderingGroupId The rendering group id corresponding to its index
  34522. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34523. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34524. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34525. */
  34526. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34527. /**
  34528. * Gets the current auto clear configuration for one rendering group of the rendering
  34529. * manager.
  34530. * @param index the rendering group index to get the information for
  34531. * @returns The auto clear setup for the requested rendering group
  34532. */
  34533. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34534. private _blockMaterialDirtyMechanism;
  34535. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34536. blockMaterialDirtyMechanism: boolean;
  34537. /**
  34538. * Will flag all materials as dirty to trigger new shader compilation
  34539. * @param flag defines the flag used to specify which material part must be marked as dirty
  34540. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34541. */
  34542. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34543. /** @hidden */
  34544. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34545. /** @hidden */
  34546. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34547. }
  34548. }
  34549. declare module "babylonjs/assetContainer" {
  34550. import { AbstractScene } from "babylonjs/abstractScene";
  34551. import { Scene } from "babylonjs/scene";
  34552. import { Mesh } from "babylonjs/Meshes/mesh";
  34553. /**
  34554. * Set of assets to keep when moving a scene into an asset container.
  34555. */
  34556. export class KeepAssets extends AbstractScene {
  34557. }
  34558. /**
  34559. * Container with a set of assets that can be added or removed from a scene.
  34560. */
  34561. export class AssetContainer extends AbstractScene {
  34562. /**
  34563. * The scene the AssetContainer belongs to.
  34564. */
  34565. scene: Scene;
  34566. /**
  34567. * Instantiates an AssetContainer.
  34568. * @param scene The scene the AssetContainer belongs to.
  34569. */
  34570. constructor(scene: Scene);
  34571. /**
  34572. * Adds all the assets from the container to the scene.
  34573. */
  34574. addAllToScene(): void;
  34575. /**
  34576. * Removes all the assets in the container from the scene
  34577. */
  34578. removeAllFromScene(): void;
  34579. /**
  34580. * Disposes all the assets in the container
  34581. */
  34582. dispose(): void;
  34583. private _moveAssets;
  34584. /**
  34585. * Removes all the assets contained in the scene and adds them to the container.
  34586. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34587. */
  34588. moveAllFromScene(keepAssets?: KeepAssets): void;
  34589. /**
  34590. * 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.
  34591. * @returns the root mesh
  34592. */
  34593. createRootMesh(): Mesh;
  34594. }
  34595. }
  34596. declare module "babylonjs/abstractScene" {
  34597. import { Scene } from "babylonjs/scene";
  34598. import { Nullable } from "babylonjs/types";
  34599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34600. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34601. import { Geometry } from "babylonjs/Meshes/geometry";
  34602. import { Skeleton } from "babylonjs/Bones/skeleton";
  34603. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34604. import { AssetContainer } from "babylonjs/assetContainer";
  34605. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34606. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34607. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34608. import { Material } from "babylonjs/Materials/material";
  34609. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34610. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34611. import { Camera } from "babylonjs/Cameras/camera";
  34612. import { Light } from "babylonjs/Lights/light";
  34613. import { Node } from "babylonjs/node";
  34614. import { Animation } from "babylonjs/Animations/animation";
  34615. /**
  34616. * Defines how the parser contract is defined.
  34617. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34618. */
  34619. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34620. /**
  34621. * Defines how the individual parser contract is defined.
  34622. * These parser can parse an individual asset
  34623. */
  34624. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34625. /**
  34626. * Base class of the scene acting as a container for the different elements composing a scene.
  34627. * This class is dynamically extended by the different components of the scene increasing
  34628. * flexibility and reducing coupling
  34629. */
  34630. export abstract class AbstractScene {
  34631. /**
  34632. * Stores the list of available parsers in the application.
  34633. */
  34634. private static _BabylonFileParsers;
  34635. /**
  34636. * Stores the list of available individual parsers in the application.
  34637. */
  34638. private static _IndividualBabylonFileParsers;
  34639. /**
  34640. * Adds a parser in the list of available ones
  34641. * @param name Defines the name of the parser
  34642. * @param parser Defines the parser to add
  34643. */
  34644. static AddParser(name: string, parser: BabylonFileParser): void;
  34645. /**
  34646. * Gets a general parser from the list of avaialble ones
  34647. * @param name Defines the name of the parser
  34648. * @returns the requested parser or null
  34649. */
  34650. static GetParser(name: string): Nullable<BabylonFileParser>;
  34651. /**
  34652. * Adds n individual parser in the list of available ones
  34653. * @param name Defines the name of the parser
  34654. * @param parser Defines the parser to add
  34655. */
  34656. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34657. /**
  34658. * Gets an individual parser from the list of avaialble ones
  34659. * @param name Defines the name of the parser
  34660. * @returns the requested parser or null
  34661. */
  34662. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34663. /**
  34664. * Parser json data and populate both a scene and its associated container object
  34665. * @param jsonData Defines the data to parse
  34666. * @param scene Defines the scene to parse the data for
  34667. * @param container Defines the container attached to the parsing sequence
  34668. * @param rootUrl Defines the root url of the data
  34669. */
  34670. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34671. /**
  34672. * Gets the list of root nodes (ie. nodes with no parent)
  34673. */
  34674. rootNodes: Node[];
  34675. /** All of the cameras added to this scene
  34676. * @see http://doc.babylonjs.com/babylon101/cameras
  34677. */
  34678. cameras: Camera[];
  34679. /**
  34680. * All of the lights added to this scene
  34681. * @see http://doc.babylonjs.com/babylon101/lights
  34682. */
  34683. lights: Light[];
  34684. /**
  34685. * All of the (abstract) meshes added to this scene
  34686. */
  34687. meshes: AbstractMesh[];
  34688. /**
  34689. * The list of skeletons added to the scene
  34690. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34691. */
  34692. skeletons: Skeleton[];
  34693. /**
  34694. * All of the particle systems added to this scene
  34695. * @see http://doc.babylonjs.com/babylon101/particles
  34696. */
  34697. particleSystems: IParticleSystem[];
  34698. /**
  34699. * Gets a list of Animations associated with the scene
  34700. */
  34701. animations: Animation[];
  34702. /**
  34703. * All of the animation groups added to this scene
  34704. * @see http://doc.babylonjs.com/how_to/group
  34705. */
  34706. animationGroups: AnimationGroup[];
  34707. /**
  34708. * All of the multi-materials added to this scene
  34709. * @see http://doc.babylonjs.com/how_to/multi_materials
  34710. */
  34711. multiMaterials: MultiMaterial[];
  34712. /**
  34713. * All of the materials added to this scene
  34714. * In the context of a Scene, it is not supposed to be modified manually.
  34715. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34716. * Note also that the order of the Material wihin the array is not significant and might change.
  34717. * @see http://doc.babylonjs.com/babylon101/materials
  34718. */
  34719. materials: Material[];
  34720. /**
  34721. * The list of morph target managers added to the scene
  34722. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34723. */
  34724. morphTargetManagers: MorphTargetManager[];
  34725. /**
  34726. * The list of geometries used in the scene.
  34727. */
  34728. geometries: Geometry[];
  34729. /**
  34730. * All of the tranform nodes added to this scene
  34731. * In the context of a Scene, it is not supposed to be modified manually.
  34732. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34733. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34734. * @see http://doc.babylonjs.com/how_to/transformnode
  34735. */
  34736. transformNodes: TransformNode[];
  34737. /**
  34738. * ActionManagers available on the scene.
  34739. */
  34740. actionManagers: AbstractActionManager[];
  34741. /**
  34742. * Textures to keep.
  34743. */
  34744. textures: BaseTexture[];
  34745. /**
  34746. * Environment texture for the scene
  34747. */
  34748. environmentTexture: Nullable<BaseTexture>;
  34749. }
  34750. }
  34751. declare module "babylonjs/Audio/sound" {
  34752. import { Observable } from "babylonjs/Misc/observable";
  34753. import { Vector3 } from "babylonjs/Maths/math";
  34754. import { Nullable } from "babylonjs/types";
  34755. import { Scene } from "babylonjs/scene";
  34756. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34757. /**
  34758. * Defines a sound that can be played in the application.
  34759. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34761. */
  34762. export class Sound {
  34763. /**
  34764. * The name of the sound in the scene.
  34765. */
  34766. name: string;
  34767. /**
  34768. * Does the sound autoplay once loaded.
  34769. */
  34770. autoplay: boolean;
  34771. /**
  34772. * Does the sound loop after it finishes playing once.
  34773. */
  34774. loop: boolean;
  34775. /**
  34776. * Does the sound use a custom attenuation curve to simulate the falloff
  34777. * happening when the source gets further away from the camera.
  34778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34779. */
  34780. useCustomAttenuation: boolean;
  34781. /**
  34782. * The sound track id this sound belongs to.
  34783. */
  34784. soundTrackId: number;
  34785. /**
  34786. * Is this sound currently played.
  34787. */
  34788. isPlaying: boolean;
  34789. /**
  34790. * Is this sound currently paused.
  34791. */
  34792. isPaused: boolean;
  34793. /**
  34794. * Does this sound enables spatial sound.
  34795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34796. */
  34797. spatialSound: boolean;
  34798. /**
  34799. * Define the reference distance the sound should be heard perfectly.
  34800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34801. */
  34802. refDistance: number;
  34803. /**
  34804. * Define the roll off factor of spatial sounds.
  34805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34806. */
  34807. rolloffFactor: number;
  34808. /**
  34809. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34811. */
  34812. maxDistance: number;
  34813. /**
  34814. * Define the distance attenuation model the sound will follow.
  34815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34816. */
  34817. distanceModel: string;
  34818. /**
  34819. * @hidden
  34820. * Back Compat
  34821. **/
  34822. onended: () => any;
  34823. /**
  34824. * Observable event when the current playing sound finishes.
  34825. */
  34826. onEndedObservable: Observable<Sound>;
  34827. private _panningModel;
  34828. private _playbackRate;
  34829. private _streaming;
  34830. private _startTime;
  34831. private _startOffset;
  34832. private _position;
  34833. /** @hidden */
  34834. _positionInEmitterSpace: boolean;
  34835. private _localDirection;
  34836. private _volume;
  34837. private _isReadyToPlay;
  34838. private _isDirectional;
  34839. private _readyToPlayCallback;
  34840. private _audioBuffer;
  34841. private _soundSource;
  34842. private _streamingSource;
  34843. private _soundPanner;
  34844. private _soundGain;
  34845. private _inputAudioNode;
  34846. private _outputAudioNode;
  34847. private _coneInnerAngle;
  34848. private _coneOuterAngle;
  34849. private _coneOuterGain;
  34850. private _scene;
  34851. private _connectedTransformNode;
  34852. private _customAttenuationFunction;
  34853. private _registerFunc;
  34854. private _isOutputConnected;
  34855. private _htmlAudioElement;
  34856. private _urlType;
  34857. /** @hidden */
  34858. static _SceneComponentInitialization: (scene: Scene) => void;
  34859. /**
  34860. * Create a sound and attach it to a scene
  34861. * @param name Name of your sound
  34862. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34863. * @param scene defines the scene the sound belongs to
  34864. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34865. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34866. */
  34867. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34868. /**
  34869. * Release the sound and its associated resources
  34870. */
  34871. dispose(): void;
  34872. /**
  34873. * Gets if the sounds is ready to be played or not.
  34874. * @returns true if ready, otherwise false
  34875. */
  34876. isReady(): boolean;
  34877. private _soundLoaded;
  34878. /**
  34879. * Sets the data of the sound from an audiobuffer
  34880. * @param audioBuffer The audioBuffer containing the data
  34881. */
  34882. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34883. /**
  34884. * Updates the current sounds options such as maxdistance, loop...
  34885. * @param options A JSON object containing values named as the object properties
  34886. */
  34887. updateOptions(options: any): void;
  34888. private _createSpatialParameters;
  34889. private _updateSpatialParameters;
  34890. /**
  34891. * Switch the panning model to HRTF:
  34892. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34894. */
  34895. switchPanningModelToHRTF(): void;
  34896. /**
  34897. * Switch the panning model to Equal Power:
  34898. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34900. */
  34901. switchPanningModelToEqualPower(): void;
  34902. private _switchPanningModel;
  34903. /**
  34904. * Connect this sound to a sound track audio node like gain...
  34905. * @param soundTrackAudioNode the sound track audio node to connect to
  34906. */
  34907. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34908. /**
  34909. * Transform this sound into a directional source
  34910. * @param coneInnerAngle Size of the inner cone in degree
  34911. * @param coneOuterAngle Size of the outer cone in degree
  34912. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34913. */
  34914. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34915. /**
  34916. * Gets or sets the inner angle for the directional cone.
  34917. */
  34918. /**
  34919. * Gets or sets the inner angle for the directional cone.
  34920. */
  34921. directionalConeInnerAngle: number;
  34922. /**
  34923. * Gets or sets the outer angle for the directional cone.
  34924. */
  34925. /**
  34926. * Gets or sets the outer angle for the directional cone.
  34927. */
  34928. directionalConeOuterAngle: number;
  34929. /**
  34930. * Sets the position of the emitter if spatial sound is enabled
  34931. * @param newPosition Defines the new posisiton
  34932. */
  34933. setPosition(newPosition: Vector3): void;
  34934. /**
  34935. * Sets the local direction of the emitter if spatial sound is enabled
  34936. * @param newLocalDirection Defines the new local direction
  34937. */
  34938. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34939. private _updateDirection;
  34940. /** @hidden */
  34941. updateDistanceFromListener(): void;
  34942. /**
  34943. * Sets a new custom attenuation function for the sound.
  34944. * @param callback Defines the function used for the attenuation
  34945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34946. */
  34947. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34948. /**
  34949. * Play the sound
  34950. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34951. * @param offset (optional) Start the sound setting it at a specific time
  34952. */
  34953. play(time?: number, offset?: number): void;
  34954. private _onended;
  34955. /**
  34956. * Stop the sound
  34957. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34958. */
  34959. stop(time?: number): void;
  34960. /**
  34961. * Put the sound in pause
  34962. */
  34963. pause(): void;
  34964. /**
  34965. * Sets a dedicated volume for this sounds
  34966. * @param newVolume Define the new volume of the sound
  34967. * @param time Define in how long the sound should be at this value
  34968. */
  34969. setVolume(newVolume: number, time?: number): void;
  34970. /**
  34971. * Set the sound play back rate
  34972. * @param newPlaybackRate Define the playback rate the sound should be played at
  34973. */
  34974. setPlaybackRate(newPlaybackRate: number): void;
  34975. /**
  34976. * Gets the volume of the sound.
  34977. * @returns the volume of the sound
  34978. */
  34979. getVolume(): number;
  34980. /**
  34981. * Attach the sound to a dedicated mesh
  34982. * @param transformNode The transform node to connect the sound with
  34983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34984. */
  34985. attachToMesh(transformNode: TransformNode): void;
  34986. /**
  34987. * Detach the sound from the previously attached mesh
  34988. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34989. */
  34990. detachFromMesh(): void;
  34991. private _onRegisterAfterWorldMatrixUpdate;
  34992. /**
  34993. * Clone the current sound in the scene.
  34994. * @returns the new sound clone
  34995. */
  34996. clone(): Nullable<Sound>;
  34997. /**
  34998. * Gets the current underlying audio buffer containing the data
  34999. * @returns the audio buffer
  35000. */
  35001. getAudioBuffer(): Nullable<AudioBuffer>;
  35002. /**
  35003. * Serializes the Sound in a JSON representation
  35004. * @returns the JSON representation of the sound
  35005. */
  35006. serialize(): any;
  35007. /**
  35008. * Parse a JSON representation of a sound to innstantiate in a given scene
  35009. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35010. * @param scene Define the scene the new parsed sound should be created in
  35011. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35012. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35013. * @returns the newly parsed sound
  35014. */
  35015. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35016. }
  35017. }
  35018. declare module "babylonjs/Actions/directAudioActions" {
  35019. import { Action } from "babylonjs/Actions/action";
  35020. import { Condition } from "babylonjs/Actions/condition";
  35021. import { Sound } from "babylonjs/Audio/sound";
  35022. /**
  35023. * This defines an action helpful to play a defined sound on a triggered action.
  35024. */
  35025. export class PlaySoundAction extends Action {
  35026. private _sound;
  35027. /**
  35028. * Instantiate the action
  35029. * @param triggerOptions defines the trigger options
  35030. * @param sound defines the sound to play
  35031. * @param condition defines the trigger related conditions
  35032. */
  35033. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35034. /** @hidden */
  35035. _prepare(): void;
  35036. /**
  35037. * Execute the action and play the sound.
  35038. */
  35039. execute(): void;
  35040. /**
  35041. * Serializes the actions and its related information.
  35042. * @param parent defines the object to serialize in
  35043. * @returns the serialized object
  35044. */
  35045. serialize(parent: any): any;
  35046. }
  35047. /**
  35048. * This defines an action helpful to stop a defined sound on a triggered action.
  35049. */
  35050. export class StopSoundAction extends Action {
  35051. private _sound;
  35052. /**
  35053. * Instantiate the action
  35054. * @param triggerOptions defines the trigger options
  35055. * @param sound defines the sound to stop
  35056. * @param condition defines the trigger related conditions
  35057. */
  35058. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35059. /** @hidden */
  35060. _prepare(): void;
  35061. /**
  35062. * Execute the action and stop the sound.
  35063. */
  35064. execute(): void;
  35065. /**
  35066. * Serializes the actions and its related information.
  35067. * @param parent defines the object to serialize in
  35068. * @returns the serialized object
  35069. */
  35070. serialize(parent: any): any;
  35071. }
  35072. }
  35073. declare module "babylonjs/Actions/interpolateValueAction" {
  35074. import { Action } from "babylonjs/Actions/action";
  35075. import { Condition } from "babylonjs/Actions/condition";
  35076. import { Observable } from "babylonjs/Misc/observable";
  35077. /**
  35078. * This defines an action responsible to change the value of a property
  35079. * by interpolating between its current value and the newly set one once triggered.
  35080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35081. */
  35082. export class InterpolateValueAction extends Action {
  35083. /**
  35084. * Defines the path of the property where the value should be interpolated
  35085. */
  35086. propertyPath: string;
  35087. /**
  35088. * Defines the target value at the end of the interpolation.
  35089. */
  35090. value: any;
  35091. /**
  35092. * Defines the time it will take for the property to interpolate to the value.
  35093. */
  35094. duration: number;
  35095. /**
  35096. * Defines if the other scene animations should be stopped when the action has been triggered
  35097. */
  35098. stopOtherAnimations?: boolean;
  35099. /**
  35100. * Defines a callback raised once the interpolation animation has been done.
  35101. */
  35102. onInterpolationDone?: () => void;
  35103. /**
  35104. * Observable triggered once the interpolation animation has been done.
  35105. */
  35106. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35107. private _target;
  35108. private _effectiveTarget;
  35109. private _property;
  35110. /**
  35111. * Instantiate the action
  35112. * @param triggerOptions defines the trigger options
  35113. * @param target defines the object containing the value to interpolate
  35114. * @param propertyPath defines the path to the property in the target object
  35115. * @param value defines the target value at the end of the interpolation
  35116. * @param duration deines the time it will take for the property to interpolate to the value.
  35117. * @param condition defines the trigger related conditions
  35118. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35119. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35120. */
  35121. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35122. /** @hidden */
  35123. _prepare(): void;
  35124. /**
  35125. * Execute the action starts the value interpolation.
  35126. */
  35127. execute(): void;
  35128. /**
  35129. * Serializes the actions and its related information.
  35130. * @param parent defines the object to serialize in
  35131. * @returns the serialized object
  35132. */
  35133. serialize(parent: any): any;
  35134. }
  35135. }
  35136. declare module "babylonjs/Actions/index" {
  35137. export * from "babylonjs/Actions/action";
  35138. export * from "babylonjs/Actions/actionEvent";
  35139. export * from "babylonjs/Actions/actionManager";
  35140. export * from "babylonjs/Actions/condition";
  35141. export * from "babylonjs/Actions/directActions";
  35142. export * from "babylonjs/Actions/directAudioActions";
  35143. export * from "babylonjs/Actions/interpolateValueAction";
  35144. }
  35145. declare module "babylonjs/Animations/index" {
  35146. export * from "babylonjs/Animations/animatable";
  35147. export * from "babylonjs/Animations/animation";
  35148. export * from "babylonjs/Animations/animationGroup";
  35149. export * from "babylonjs/Animations/animationPropertiesOverride";
  35150. export * from "babylonjs/Animations/easing";
  35151. export * from "babylonjs/Animations/runtimeAnimation";
  35152. export * from "babylonjs/Animations/animationEvent";
  35153. export * from "babylonjs/Animations/animationGroup";
  35154. export * from "babylonjs/Animations/animationKey";
  35155. export * from "babylonjs/Animations/animationRange";
  35156. }
  35157. declare module "babylonjs/Audio/soundTrack" {
  35158. import { Sound } from "babylonjs/Audio/sound";
  35159. import { Analyser } from "babylonjs/Audio/analyser";
  35160. import { Scene } from "babylonjs/scene";
  35161. /**
  35162. * Options allowed during the creation of a sound track.
  35163. */
  35164. export interface ISoundTrackOptions {
  35165. /**
  35166. * The volume the sound track should take during creation
  35167. */
  35168. volume?: number;
  35169. /**
  35170. * Define if the sound track is the main sound track of the scene
  35171. */
  35172. mainTrack?: boolean;
  35173. }
  35174. /**
  35175. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35176. * It will be also used in a future release to apply effects on a specific track.
  35177. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35178. */
  35179. export class SoundTrack {
  35180. /**
  35181. * The unique identifier of the sound track in the scene.
  35182. */
  35183. id: number;
  35184. /**
  35185. * The list of sounds included in the sound track.
  35186. */
  35187. soundCollection: Array<Sound>;
  35188. private _outputAudioNode;
  35189. private _scene;
  35190. private _isMainTrack;
  35191. private _connectedAnalyser;
  35192. private _options;
  35193. private _isInitialized;
  35194. /**
  35195. * Creates a new sound track.
  35196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35197. * @param scene Define the scene the sound track belongs to
  35198. * @param options
  35199. */
  35200. constructor(scene: Scene, options?: ISoundTrackOptions);
  35201. private _initializeSoundTrackAudioGraph;
  35202. /**
  35203. * Release the sound track and its associated resources
  35204. */
  35205. dispose(): void;
  35206. /**
  35207. * Adds a sound to this sound track
  35208. * @param sound define the cound to add
  35209. * @ignoreNaming
  35210. */
  35211. AddSound(sound: Sound): void;
  35212. /**
  35213. * Removes a sound to this sound track
  35214. * @param sound define the cound to remove
  35215. * @ignoreNaming
  35216. */
  35217. RemoveSound(sound: Sound): void;
  35218. /**
  35219. * Set a global volume for the full sound track.
  35220. * @param newVolume Define the new volume of the sound track
  35221. */
  35222. setVolume(newVolume: number): void;
  35223. /**
  35224. * Switch the panning model to HRTF:
  35225. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35227. */
  35228. switchPanningModelToHRTF(): void;
  35229. /**
  35230. * Switch the panning model to Equal Power:
  35231. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35233. */
  35234. switchPanningModelToEqualPower(): void;
  35235. /**
  35236. * Connect the sound track to an audio analyser allowing some amazing
  35237. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35239. * @param analyser The analyser to connect to the engine
  35240. */
  35241. connectToAnalyser(analyser: Analyser): void;
  35242. }
  35243. }
  35244. declare module "babylonjs/Audio/audioSceneComponent" {
  35245. import { Sound } from "babylonjs/Audio/sound";
  35246. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35247. import { Nullable } from "babylonjs/types";
  35248. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35249. import { Scene } from "babylonjs/scene";
  35250. import { AbstractScene } from "babylonjs/abstractScene";
  35251. module "babylonjs/abstractScene" {
  35252. interface AbstractScene {
  35253. /**
  35254. * The list of sounds used in the scene.
  35255. */
  35256. sounds: Nullable<Array<Sound>>;
  35257. }
  35258. }
  35259. module "babylonjs/scene" {
  35260. interface Scene {
  35261. /**
  35262. * @hidden
  35263. * Backing field
  35264. */
  35265. _mainSoundTrack: SoundTrack;
  35266. /**
  35267. * The main sound track played by the scene.
  35268. * It cotains your primary collection of sounds.
  35269. */
  35270. mainSoundTrack: SoundTrack;
  35271. /**
  35272. * The list of sound tracks added to the scene
  35273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35274. */
  35275. soundTracks: Nullable<Array<SoundTrack>>;
  35276. /**
  35277. * Gets a sound using a given name
  35278. * @param name defines the name to search for
  35279. * @return the found sound or null if not found at all.
  35280. */
  35281. getSoundByName(name: string): Nullable<Sound>;
  35282. /**
  35283. * Gets or sets if audio support is enabled
  35284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35285. */
  35286. audioEnabled: boolean;
  35287. /**
  35288. * Gets or sets if audio will be output to headphones
  35289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35290. */
  35291. headphone: boolean;
  35292. }
  35293. }
  35294. /**
  35295. * Defines the sound scene component responsible to manage any sounds
  35296. * in a given scene.
  35297. */
  35298. export class AudioSceneComponent implements ISceneSerializableComponent {
  35299. /**
  35300. * The component name helpfull to identify the component in the list of scene components.
  35301. */
  35302. readonly name: string;
  35303. /**
  35304. * The scene the component belongs to.
  35305. */
  35306. scene: Scene;
  35307. private _audioEnabled;
  35308. /**
  35309. * Gets whether audio is enabled or not.
  35310. * Please use related enable/disable method to switch state.
  35311. */
  35312. readonly audioEnabled: boolean;
  35313. private _headphone;
  35314. /**
  35315. * Gets whether audio is outputing to headphone or not.
  35316. * Please use the according Switch methods to change output.
  35317. */
  35318. readonly headphone: boolean;
  35319. /**
  35320. * Creates a new instance of the component for the given scene
  35321. * @param scene Defines the scene to register the component in
  35322. */
  35323. constructor(scene: Scene);
  35324. /**
  35325. * Registers the component in a given scene
  35326. */
  35327. register(): void;
  35328. /**
  35329. * Rebuilds the elements related to this component in case of
  35330. * context lost for instance.
  35331. */
  35332. rebuild(): void;
  35333. /**
  35334. * Serializes the component data to the specified json object
  35335. * @param serializationObject The object to serialize to
  35336. */
  35337. serialize(serializationObject: any): void;
  35338. /**
  35339. * Adds all the element from the container to the scene
  35340. * @param container the container holding the elements
  35341. */
  35342. addFromContainer(container: AbstractScene): void;
  35343. /**
  35344. * Removes all the elements in the container from the scene
  35345. * @param container contains the elements to remove
  35346. * @param dispose if the removed element should be disposed (default: false)
  35347. */
  35348. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35349. /**
  35350. * Disposes the component and the associated ressources.
  35351. */
  35352. dispose(): void;
  35353. /**
  35354. * Disables audio in the associated scene.
  35355. */
  35356. disableAudio(): void;
  35357. /**
  35358. * Enables audio in the associated scene.
  35359. */
  35360. enableAudio(): void;
  35361. /**
  35362. * Switch audio to headphone output.
  35363. */
  35364. switchAudioModeForHeadphones(): void;
  35365. /**
  35366. * Switch audio to normal speakers.
  35367. */
  35368. switchAudioModeForNormalSpeakers(): void;
  35369. private _afterRender;
  35370. }
  35371. }
  35372. declare module "babylonjs/Audio/weightedsound" {
  35373. import { Sound } from "babylonjs/Audio/sound";
  35374. /**
  35375. * Wraps one or more Sound objects and selects one with random weight for playback.
  35376. */
  35377. export class WeightedSound {
  35378. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35379. loop: boolean;
  35380. private _coneInnerAngle;
  35381. private _coneOuterAngle;
  35382. private _volume;
  35383. /** A Sound is currently playing. */
  35384. isPlaying: boolean;
  35385. /** A Sound is currently paused. */
  35386. isPaused: boolean;
  35387. private _sounds;
  35388. private _weights;
  35389. private _currentIndex?;
  35390. /**
  35391. * Creates a new WeightedSound from the list of sounds given.
  35392. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35393. * @param sounds Array of Sounds that will be selected from.
  35394. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35395. */
  35396. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35397. /**
  35398. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35399. */
  35400. /**
  35401. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35402. */
  35403. directionalConeInnerAngle: number;
  35404. /**
  35405. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35406. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35407. */
  35408. /**
  35409. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35410. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35411. */
  35412. directionalConeOuterAngle: number;
  35413. /**
  35414. * Playback volume.
  35415. */
  35416. /**
  35417. * Playback volume.
  35418. */
  35419. volume: number;
  35420. private _onended;
  35421. /**
  35422. * Suspend playback
  35423. */
  35424. pause(): void;
  35425. /**
  35426. * Stop playback
  35427. */
  35428. stop(): void;
  35429. /**
  35430. * Start playback.
  35431. * @param startOffset Position the clip head at a specific time in seconds.
  35432. */
  35433. play(startOffset?: number): void;
  35434. }
  35435. }
  35436. declare module "babylonjs/Audio/index" {
  35437. export * from "babylonjs/Audio/analyser";
  35438. export * from "babylonjs/Audio/audioEngine";
  35439. export * from "babylonjs/Audio/audioSceneComponent";
  35440. export * from "babylonjs/Audio/sound";
  35441. export * from "babylonjs/Audio/soundTrack";
  35442. export * from "babylonjs/Audio/weightedsound";
  35443. }
  35444. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35445. import { Behavior } from "babylonjs/Behaviors/behavior";
  35446. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35447. import { BackEase } from "babylonjs/Animations/easing";
  35448. /**
  35449. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35450. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35451. */
  35452. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35453. /**
  35454. * Gets the name of the behavior.
  35455. */
  35456. readonly name: string;
  35457. /**
  35458. * The easing function used by animations
  35459. */
  35460. static EasingFunction: BackEase;
  35461. /**
  35462. * The easing mode used by animations
  35463. */
  35464. static EasingMode: number;
  35465. /**
  35466. * The duration of the animation, in milliseconds
  35467. */
  35468. transitionDuration: number;
  35469. /**
  35470. * Length of the distance animated by the transition when lower radius is reached
  35471. */
  35472. lowerRadiusTransitionRange: number;
  35473. /**
  35474. * Length of the distance animated by the transition when upper radius is reached
  35475. */
  35476. upperRadiusTransitionRange: number;
  35477. private _autoTransitionRange;
  35478. /**
  35479. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35480. */
  35481. /**
  35482. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35483. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35484. */
  35485. autoTransitionRange: boolean;
  35486. private _attachedCamera;
  35487. private _onAfterCheckInputsObserver;
  35488. private _onMeshTargetChangedObserver;
  35489. /**
  35490. * Initializes the behavior.
  35491. */
  35492. init(): void;
  35493. /**
  35494. * Attaches the behavior to its arc rotate camera.
  35495. * @param camera Defines the camera to attach the behavior to
  35496. */
  35497. attach(camera: ArcRotateCamera): void;
  35498. /**
  35499. * Detaches the behavior from its current arc rotate camera.
  35500. */
  35501. detach(): void;
  35502. private _radiusIsAnimating;
  35503. private _radiusBounceTransition;
  35504. private _animatables;
  35505. private _cachedWheelPrecision;
  35506. /**
  35507. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35508. * @param radiusLimit The limit to check against.
  35509. * @return Bool to indicate if at limit.
  35510. */
  35511. private _isRadiusAtLimit;
  35512. /**
  35513. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35514. * @param radiusDelta The delta by which to animate to. Can be negative.
  35515. */
  35516. private _applyBoundRadiusAnimation;
  35517. /**
  35518. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35519. */
  35520. protected _clearAnimationLocks(): void;
  35521. /**
  35522. * Stops and removes all animations that have been applied to the camera
  35523. */
  35524. stopAllAnimations(): void;
  35525. }
  35526. }
  35527. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35528. import { Behavior } from "babylonjs/Behaviors/behavior";
  35529. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35530. import { ExponentialEase } from "babylonjs/Animations/easing";
  35531. import { Nullable } from "babylonjs/types";
  35532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35533. import { Vector3 } from "babylonjs/Maths/math";
  35534. /**
  35535. * 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.
  35536. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35537. */
  35538. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35539. /**
  35540. * Gets the name of the behavior.
  35541. */
  35542. readonly name: string;
  35543. private _mode;
  35544. private _radiusScale;
  35545. private _positionScale;
  35546. private _defaultElevation;
  35547. private _elevationReturnTime;
  35548. private _elevationReturnWaitTime;
  35549. private _zoomStopsAnimation;
  35550. private _framingTime;
  35551. /**
  35552. * The easing function used by animations
  35553. */
  35554. static EasingFunction: ExponentialEase;
  35555. /**
  35556. * The easing mode used by animations
  35557. */
  35558. static EasingMode: number;
  35559. /**
  35560. * Sets the current mode used by the behavior
  35561. */
  35562. /**
  35563. * Gets current mode used by the behavior.
  35564. */
  35565. mode: number;
  35566. /**
  35567. * Sets the scale applied to the radius (1 by default)
  35568. */
  35569. /**
  35570. * Gets the scale applied to the radius
  35571. */
  35572. radiusScale: number;
  35573. /**
  35574. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35575. */
  35576. /**
  35577. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35578. */
  35579. positionScale: number;
  35580. /**
  35581. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35582. * behaviour is triggered, in radians.
  35583. */
  35584. /**
  35585. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35586. * behaviour is triggered, in radians.
  35587. */
  35588. defaultElevation: number;
  35589. /**
  35590. * Sets the time (in milliseconds) taken to return to the default beta position.
  35591. * Negative value indicates camera should not return to default.
  35592. */
  35593. /**
  35594. * Gets the time (in milliseconds) taken to return to the default beta position.
  35595. * Negative value indicates camera should not return to default.
  35596. */
  35597. elevationReturnTime: number;
  35598. /**
  35599. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35600. */
  35601. /**
  35602. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35603. */
  35604. elevationReturnWaitTime: number;
  35605. /**
  35606. * Sets the flag that indicates if user zooming should stop animation.
  35607. */
  35608. /**
  35609. * Gets the flag that indicates if user zooming should stop animation.
  35610. */
  35611. zoomStopsAnimation: boolean;
  35612. /**
  35613. * Sets the transition time when framing the mesh, in milliseconds
  35614. */
  35615. /**
  35616. * Gets the transition time when framing the mesh, in milliseconds
  35617. */
  35618. framingTime: number;
  35619. /**
  35620. * Define if the behavior should automatically change the configured
  35621. * camera limits and sensibilities.
  35622. */
  35623. autoCorrectCameraLimitsAndSensibility: boolean;
  35624. private _onPrePointerObservableObserver;
  35625. private _onAfterCheckInputsObserver;
  35626. private _onMeshTargetChangedObserver;
  35627. private _attachedCamera;
  35628. private _isPointerDown;
  35629. private _lastInteractionTime;
  35630. /**
  35631. * Initializes the behavior.
  35632. */
  35633. init(): void;
  35634. /**
  35635. * Attaches the behavior to its arc rotate camera.
  35636. * @param camera Defines the camera to attach the behavior to
  35637. */
  35638. attach(camera: ArcRotateCamera): void;
  35639. /**
  35640. * Detaches the behavior from its current arc rotate camera.
  35641. */
  35642. detach(): void;
  35643. private _animatables;
  35644. private _betaIsAnimating;
  35645. private _betaTransition;
  35646. private _radiusTransition;
  35647. private _vectorTransition;
  35648. /**
  35649. * Targets the given mesh and updates zoom level accordingly.
  35650. * @param mesh The mesh to target.
  35651. * @param radius Optional. If a cached radius position already exists, overrides default.
  35652. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35653. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35654. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35655. */
  35656. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35657. /**
  35658. * Targets the given mesh with its children and updates zoom level accordingly.
  35659. * @param mesh The mesh to target.
  35660. * @param radius Optional. If a cached radius position already exists, overrides default.
  35661. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35662. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35663. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35664. */
  35665. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35666. /**
  35667. * Targets the given meshes with their children and updates zoom level accordingly.
  35668. * @param meshes The mesh to target.
  35669. * @param radius Optional. If a cached radius position already exists, overrides default.
  35670. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35671. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35672. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35673. */
  35674. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35675. /**
  35676. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35677. * @param minimumWorld Determines the smaller position of the bounding box extend
  35678. * @param maximumWorld Determines the bigger position of the bounding box extend
  35679. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35680. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35681. */
  35682. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35683. /**
  35684. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35685. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35686. * frustum width.
  35687. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35688. * to fully enclose the mesh in the viewing frustum.
  35689. */
  35690. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35691. /**
  35692. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35693. * is automatically returned to its default position (expected to be above ground plane).
  35694. */
  35695. private _maintainCameraAboveGround;
  35696. /**
  35697. * Returns the frustum slope based on the canvas ratio and camera FOV
  35698. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35699. */
  35700. private _getFrustumSlope;
  35701. /**
  35702. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35703. */
  35704. private _clearAnimationLocks;
  35705. /**
  35706. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35707. */
  35708. private _applyUserInteraction;
  35709. /**
  35710. * Stops and removes all animations that have been applied to the camera
  35711. */
  35712. stopAllAnimations(): void;
  35713. /**
  35714. * Gets a value indicating if the user is moving the camera
  35715. */
  35716. readonly isUserIsMoving: boolean;
  35717. /**
  35718. * The camera can move all the way towards the mesh.
  35719. */
  35720. static IgnoreBoundsSizeMode: number;
  35721. /**
  35722. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35723. */
  35724. static FitFrustumSidesMode: number;
  35725. }
  35726. }
  35727. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35728. import { Nullable } from "babylonjs/types";
  35729. import { Camera } from "babylonjs/Cameras/camera";
  35730. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35731. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35732. /**
  35733. * Base class for Camera Pointer Inputs.
  35734. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35735. * for example usage.
  35736. */
  35737. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35738. /**
  35739. * Defines the camera the input is attached to.
  35740. */
  35741. abstract camera: Camera;
  35742. /**
  35743. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35744. */
  35745. protected _altKey: boolean;
  35746. protected _ctrlKey: boolean;
  35747. protected _metaKey: boolean;
  35748. protected _shiftKey: boolean;
  35749. /**
  35750. * Which mouse buttons were pressed at time of last mouse event.
  35751. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35752. */
  35753. protected _buttonsPressed: number;
  35754. /**
  35755. * Defines the buttons associated with the input to handle camera move.
  35756. */
  35757. buttons: number[];
  35758. /**
  35759. * Attach the input controls to a specific dom element to get the input from.
  35760. * @param element Defines the element the controls should be listened from
  35761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35762. */
  35763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35764. /**
  35765. * Detach the current controls from the specified dom element.
  35766. * @param element Defines the element to stop listening the inputs from
  35767. */
  35768. detachControl(element: Nullable<HTMLElement>): void;
  35769. /**
  35770. * Gets the class name of the current input.
  35771. * @returns the class name
  35772. */
  35773. getClassName(): string;
  35774. /**
  35775. * Get the friendly name associated with the input class.
  35776. * @returns the input friendly name
  35777. */
  35778. getSimpleName(): string;
  35779. /**
  35780. * Called on pointer POINTERDOUBLETAP event.
  35781. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35782. */
  35783. protected onDoubleTap(type: string): void;
  35784. /**
  35785. * Called on pointer POINTERMOVE event if only a single touch is active.
  35786. * Override this method to provide functionality.
  35787. */
  35788. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35789. /**
  35790. * Called on pointer POINTERMOVE event if multiple touches are active.
  35791. * Override this method to provide functionality.
  35792. */
  35793. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35794. /**
  35795. * Called on JS contextmenu event.
  35796. * Override this method to provide functionality.
  35797. */
  35798. protected onContextMenu(evt: PointerEvent): void;
  35799. /**
  35800. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35801. * press.
  35802. * Override this method to provide functionality.
  35803. */
  35804. protected onButtonDown(evt: PointerEvent): void;
  35805. /**
  35806. * Called each time a new POINTERUP event occurs. Ie, for each button
  35807. * release.
  35808. * Override this method to provide functionality.
  35809. */
  35810. protected onButtonUp(evt: PointerEvent): void;
  35811. /**
  35812. * Called when window becomes inactive.
  35813. * Override this method to provide functionality.
  35814. */
  35815. protected onLostFocus(): void;
  35816. private _pointerInput;
  35817. private _observer;
  35818. private _onLostFocus;
  35819. private pointA;
  35820. private pointB;
  35821. }
  35822. }
  35823. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35824. import { Nullable } from "babylonjs/types";
  35825. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35826. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35827. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35828. /**
  35829. * Manage the pointers inputs to control an arc rotate camera.
  35830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35831. */
  35832. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35833. /**
  35834. * Defines the camera the input is attached to.
  35835. */
  35836. camera: ArcRotateCamera;
  35837. /**
  35838. * Gets the class name of the current input.
  35839. * @returns the class name
  35840. */
  35841. getClassName(): string;
  35842. /**
  35843. * Defines the buttons associated with the input to handle camera move.
  35844. */
  35845. buttons: number[];
  35846. /**
  35847. * Defines the pointer angular sensibility along the X axis or how fast is
  35848. * the camera rotating.
  35849. */
  35850. angularSensibilityX: number;
  35851. /**
  35852. * Defines the pointer angular sensibility along the Y axis or how fast is
  35853. * the camera rotating.
  35854. */
  35855. angularSensibilityY: number;
  35856. /**
  35857. * Defines the pointer pinch precision or how fast is the camera zooming.
  35858. */
  35859. pinchPrecision: number;
  35860. /**
  35861. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35862. * from 0.
  35863. * It defines the percentage of current camera.radius to use as delta when
  35864. * pinch zoom is used.
  35865. */
  35866. pinchDeltaPercentage: number;
  35867. /**
  35868. * Defines the pointer panning sensibility or how fast is the camera moving.
  35869. */
  35870. panningSensibility: number;
  35871. /**
  35872. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35873. */
  35874. multiTouchPanning: boolean;
  35875. /**
  35876. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35877. * zoom (pinch) through multitouch.
  35878. */
  35879. multiTouchPanAndZoom: boolean;
  35880. /**
  35881. * Revers pinch action direction.
  35882. */
  35883. pinchInwards: boolean;
  35884. private _isPanClick;
  35885. private _twoFingerActivityCount;
  35886. private _isPinching;
  35887. /**
  35888. * Called on pointer POINTERMOVE event if only a single touch is active.
  35889. */
  35890. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35891. /**
  35892. * Called on pointer POINTERDOUBLETAP event.
  35893. */
  35894. protected onDoubleTap(type: string): void;
  35895. /**
  35896. * Called on pointer POINTERMOVE event if multiple touches are active.
  35897. */
  35898. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35899. /**
  35900. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35901. * press.
  35902. */
  35903. protected onButtonDown(evt: PointerEvent): void;
  35904. /**
  35905. * Called each time a new POINTERUP event occurs. Ie, for each button
  35906. * release.
  35907. */
  35908. protected onButtonUp(evt: PointerEvent): void;
  35909. /**
  35910. * Called when window becomes inactive.
  35911. */
  35912. protected onLostFocus(): void;
  35913. }
  35914. }
  35915. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35916. import { Nullable } from "babylonjs/types";
  35917. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35918. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35919. /**
  35920. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35922. */
  35923. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35924. /**
  35925. * Defines the camera the input is attached to.
  35926. */
  35927. camera: ArcRotateCamera;
  35928. /**
  35929. * Defines the list of key codes associated with the up action (increase alpha)
  35930. */
  35931. keysUp: number[];
  35932. /**
  35933. * Defines the list of key codes associated with the down action (decrease alpha)
  35934. */
  35935. keysDown: number[];
  35936. /**
  35937. * Defines the list of key codes associated with the left action (increase beta)
  35938. */
  35939. keysLeft: number[];
  35940. /**
  35941. * Defines the list of key codes associated with the right action (decrease beta)
  35942. */
  35943. keysRight: number[];
  35944. /**
  35945. * Defines the list of key codes associated with the reset action.
  35946. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35947. */
  35948. keysReset: number[];
  35949. /**
  35950. * Defines the panning sensibility of the inputs.
  35951. * (How fast is the camera paning)
  35952. */
  35953. panningSensibility: number;
  35954. /**
  35955. * Defines the zooming sensibility of the inputs.
  35956. * (How fast is the camera zooming)
  35957. */
  35958. zoomingSensibility: number;
  35959. /**
  35960. * Defines wether maintaining the alt key down switch the movement mode from
  35961. * orientation to zoom.
  35962. */
  35963. useAltToZoom: boolean;
  35964. /**
  35965. * Rotation speed of the camera
  35966. */
  35967. angularSpeed: number;
  35968. private _keys;
  35969. private _ctrlPressed;
  35970. private _altPressed;
  35971. private _onCanvasBlurObserver;
  35972. private _onKeyboardObserver;
  35973. private _engine;
  35974. private _scene;
  35975. /**
  35976. * Attach the input controls to a specific dom element to get the input from.
  35977. * @param element Defines the element the controls should be listened from
  35978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35979. */
  35980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35981. /**
  35982. * Detach the current controls from the specified dom element.
  35983. * @param element Defines the element to stop listening the inputs from
  35984. */
  35985. detachControl(element: Nullable<HTMLElement>): void;
  35986. /**
  35987. * Update the current camera state depending on the inputs that have been used this frame.
  35988. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35989. */
  35990. checkInputs(): void;
  35991. /**
  35992. * Gets the class name of the current intput.
  35993. * @returns the class name
  35994. */
  35995. getClassName(): string;
  35996. /**
  35997. * Get the friendly name associated with the input class.
  35998. * @returns the input friendly name
  35999. */
  36000. getSimpleName(): string;
  36001. }
  36002. }
  36003. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36004. import { Nullable } from "babylonjs/types";
  36005. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36006. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36007. /**
  36008. * Manage the mouse wheel inputs to control an arc rotate camera.
  36009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36010. */
  36011. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36012. /**
  36013. * Defines the camera the input is attached to.
  36014. */
  36015. camera: ArcRotateCamera;
  36016. /**
  36017. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36018. */
  36019. wheelPrecision: number;
  36020. /**
  36021. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36022. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36023. */
  36024. wheelDeltaPercentage: number;
  36025. private _wheel;
  36026. private _observer;
  36027. private computeDeltaFromMouseWheelLegacyEvent;
  36028. /**
  36029. * Attach the input controls to a specific dom element to get the input from.
  36030. * @param element Defines the element the controls should be listened from
  36031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36032. */
  36033. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36034. /**
  36035. * Detach the current controls from the specified dom element.
  36036. * @param element Defines the element to stop listening the inputs from
  36037. */
  36038. detachControl(element: Nullable<HTMLElement>): void;
  36039. /**
  36040. * Gets the class name of the current intput.
  36041. * @returns the class name
  36042. */
  36043. getClassName(): string;
  36044. /**
  36045. * Get the friendly name associated with the input class.
  36046. * @returns the input friendly name
  36047. */
  36048. getSimpleName(): string;
  36049. }
  36050. }
  36051. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36052. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36053. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36054. /**
  36055. * Default Inputs manager for the ArcRotateCamera.
  36056. * It groups all the default supported inputs for ease of use.
  36057. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36058. */
  36059. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36060. /**
  36061. * Instantiates a new ArcRotateCameraInputsManager.
  36062. * @param camera Defines the camera the inputs belong to
  36063. */
  36064. constructor(camera: ArcRotateCamera);
  36065. /**
  36066. * Add mouse wheel input support to the input manager.
  36067. * @returns the current input manager
  36068. */
  36069. addMouseWheel(): ArcRotateCameraInputsManager;
  36070. /**
  36071. * Add pointers input support to the input manager.
  36072. * @returns the current input manager
  36073. */
  36074. addPointers(): ArcRotateCameraInputsManager;
  36075. /**
  36076. * Add keyboard input support to the input manager.
  36077. * @returns the current input manager
  36078. */
  36079. addKeyboard(): ArcRotateCameraInputsManager;
  36080. }
  36081. }
  36082. declare module "babylonjs/Cameras/arcRotateCamera" {
  36083. import { Observable } from "babylonjs/Misc/observable";
  36084. import { Nullable } from "babylonjs/types";
  36085. import { Scene } from "babylonjs/scene";
  36086. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36088. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36089. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36090. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36091. import { Camera } from "babylonjs/Cameras/camera";
  36092. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36093. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36094. import { Collider } from "babylonjs/Collisions/collider";
  36095. /**
  36096. * This represents an orbital type of camera.
  36097. *
  36098. * 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.
  36099. * 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.
  36100. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36101. */
  36102. export class ArcRotateCamera extends TargetCamera {
  36103. /**
  36104. * Defines the rotation angle of the camera along the longitudinal axis.
  36105. */
  36106. alpha: number;
  36107. /**
  36108. * Defines the rotation angle of the camera along the latitudinal axis.
  36109. */
  36110. beta: number;
  36111. /**
  36112. * Defines the radius of the camera from it s target point.
  36113. */
  36114. radius: number;
  36115. protected _target: Vector3;
  36116. protected _targetHost: Nullable<AbstractMesh>;
  36117. /**
  36118. * Defines the target point of the camera.
  36119. * The camera looks towards it form the radius distance.
  36120. */
  36121. target: Vector3;
  36122. /**
  36123. * Define the current local position of the camera in the scene
  36124. */
  36125. position: Vector3;
  36126. protected _upVector: Vector3;
  36127. protected _upToYMatrix: Matrix;
  36128. protected _YToUpMatrix: Matrix;
  36129. /**
  36130. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36131. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36132. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36133. */
  36134. upVector: Vector3;
  36135. /**
  36136. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36137. */
  36138. setMatUp(): void;
  36139. /**
  36140. * Current inertia value on the longitudinal axis.
  36141. * The bigger this number the longer it will take for the camera to stop.
  36142. */
  36143. inertialAlphaOffset: number;
  36144. /**
  36145. * Current inertia value on the latitudinal axis.
  36146. * The bigger this number the longer it will take for the camera to stop.
  36147. */
  36148. inertialBetaOffset: number;
  36149. /**
  36150. * Current inertia value on the radius axis.
  36151. * The bigger this number the longer it will take for the camera to stop.
  36152. */
  36153. inertialRadiusOffset: number;
  36154. /**
  36155. * Minimum allowed angle on the longitudinal axis.
  36156. * This can help limiting how the Camera is able to move in the scene.
  36157. */
  36158. lowerAlphaLimit: Nullable<number>;
  36159. /**
  36160. * Maximum allowed angle on the longitudinal axis.
  36161. * This can help limiting how the Camera is able to move in the scene.
  36162. */
  36163. upperAlphaLimit: Nullable<number>;
  36164. /**
  36165. * Minimum allowed angle on the latitudinal axis.
  36166. * This can help limiting how the Camera is able to move in the scene.
  36167. */
  36168. lowerBetaLimit: number;
  36169. /**
  36170. * Maximum allowed angle on the latitudinal axis.
  36171. * This can help limiting how the Camera is able to move in the scene.
  36172. */
  36173. upperBetaLimit: number;
  36174. /**
  36175. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36176. * This can help limiting how the Camera is able to move in the scene.
  36177. */
  36178. lowerRadiusLimit: Nullable<number>;
  36179. /**
  36180. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36181. * This can help limiting how the Camera is able to move in the scene.
  36182. */
  36183. upperRadiusLimit: Nullable<number>;
  36184. /**
  36185. * Defines the current inertia value used during panning of the camera along the X axis.
  36186. */
  36187. inertialPanningX: number;
  36188. /**
  36189. * Defines the current inertia value used during panning of the camera along the Y axis.
  36190. */
  36191. inertialPanningY: number;
  36192. /**
  36193. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36194. * Basically if your fingers moves away from more than this distance you will be considered
  36195. * in pinch mode.
  36196. */
  36197. pinchToPanMaxDistance: number;
  36198. /**
  36199. * Defines the maximum distance the camera can pan.
  36200. * This could help keeping the cammera always in your scene.
  36201. */
  36202. panningDistanceLimit: Nullable<number>;
  36203. /**
  36204. * Defines the target of the camera before paning.
  36205. */
  36206. panningOriginTarget: Vector3;
  36207. /**
  36208. * Defines the value of the inertia used during panning.
  36209. * 0 would mean stop inertia and one would mean no decelleration at all.
  36210. */
  36211. panningInertia: number;
  36212. /**
  36213. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36214. */
  36215. angularSensibilityX: number;
  36216. /**
  36217. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36218. */
  36219. angularSensibilityY: number;
  36220. /**
  36221. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36222. */
  36223. pinchPrecision: number;
  36224. /**
  36225. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36226. * It will be used instead of pinchDeltaPrecision if different from 0.
  36227. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36228. */
  36229. pinchDeltaPercentage: number;
  36230. /**
  36231. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36232. */
  36233. panningSensibility: number;
  36234. /**
  36235. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36236. */
  36237. keysUp: number[];
  36238. /**
  36239. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36240. */
  36241. keysDown: number[];
  36242. /**
  36243. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36244. */
  36245. keysLeft: number[];
  36246. /**
  36247. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36248. */
  36249. keysRight: number[];
  36250. /**
  36251. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36252. */
  36253. wheelPrecision: number;
  36254. /**
  36255. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36256. * It will be used instead of pinchDeltaPrecision if different from 0.
  36257. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36258. */
  36259. wheelDeltaPercentage: number;
  36260. /**
  36261. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36262. */
  36263. zoomOnFactor: number;
  36264. /**
  36265. * Defines a screen offset for the camera position.
  36266. */
  36267. targetScreenOffset: Vector2;
  36268. /**
  36269. * Allows the camera to be completely reversed.
  36270. * If false the camera can not arrive upside down.
  36271. */
  36272. allowUpsideDown: boolean;
  36273. /**
  36274. * Define if double tap/click is used to restore the previously saved state of the camera.
  36275. */
  36276. useInputToRestoreState: boolean;
  36277. /** @hidden */
  36278. _viewMatrix: Matrix;
  36279. /** @hidden */
  36280. _useCtrlForPanning: boolean;
  36281. /** @hidden */
  36282. _panningMouseButton: number;
  36283. /**
  36284. * Defines the input associated to the camera.
  36285. */
  36286. inputs: ArcRotateCameraInputsManager;
  36287. /** @hidden */
  36288. _reset: () => void;
  36289. /**
  36290. * Defines the allowed panning axis.
  36291. */
  36292. panningAxis: Vector3;
  36293. protected _localDirection: Vector3;
  36294. protected _transformedDirection: Vector3;
  36295. private _bouncingBehavior;
  36296. /**
  36297. * Gets the bouncing behavior of the camera if it has been enabled.
  36298. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36299. */
  36300. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36301. /**
  36302. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36303. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36304. */
  36305. useBouncingBehavior: boolean;
  36306. private _framingBehavior;
  36307. /**
  36308. * Gets the framing behavior of the camera if it has been enabled.
  36309. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36310. */
  36311. readonly framingBehavior: Nullable<FramingBehavior>;
  36312. /**
  36313. * Defines if the framing behavior of the camera is enabled on the camera.
  36314. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36315. */
  36316. useFramingBehavior: boolean;
  36317. private _autoRotationBehavior;
  36318. /**
  36319. * Gets the auto rotation behavior of the camera if it has been enabled.
  36320. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36321. */
  36322. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36323. /**
  36324. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36325. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36326. */
  36327. useAutoRotationBehavior: boolean;
  36328. /**
  36329. * Observable triggered when the mesh target has been changed on the camera.
  36330. */
  36331. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36332. /**
  36333. * Event raised when the camera is colliding with a mesh.
  36334. */
  36335. onCollide: (collidedMesh: AbstractMesh) => void;
  36336. /**
  36337. * Defines whether the camera should check collision with the objects oh the scene.
  36338. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36339. */
  36340. checkCollisions: boolean;
  36341. /**
  36342. * Defines the collision radius of the camera.
  36343. * This simulates a sphere around the camera.
  36344. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36345. */
  36346. collisionRadius: Vector3;
  36347. protected _collider: Collider;
  36348. protected _previousPosition: Vector3;
  36349. protected _collisionVelocity: Vector3;
  36350. protected _newPosition: Vector3;
  36351. protected _previousAlpha: number;
  36352. protected _previousBeta: number;
  36353. protected _previousRadius: number;
  36354. protected _collisionTriggered: boolean;
  36355. protected _targetBoundingCenter: Nullable<Vector3>;
  36356. private _computationVector;
  36357. /**
  36358. * Instantiates a new ArcRotateCamera in a given scene
  36359. * @param name Defines the name of the camera
  36360. * @param alpha Defines the camera rotation along the logitudinal axis
  36361. * @param beta Defines the camera rotation along the latitudinal axis
  36362. * @param radius Defines the camera distance from its target
  36363. * @param target Defines the camera target
  36364. * @param scene Defines the scene the camera belongs to
  36365. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36366. */
  36367. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36368. /** @hidden */
  36369. _initCache(): void;
  36370. /** @hidden */
  36371. _updateCache(ignoreParentClass?: boolean): void;
  36372. protected _getTargetPosition(): Vector3;
  36373. private _storedAlpha;
  36374. private _storedBeta;
  36375. private _storedRadius;
  36376. private _storedTarget;
  36377. /**
  36378. * Stores the current state of the camera (alpha, beta, radius and target)
  36379. * @returns the camera itself
  36380. */
  36381. storeState(): Camera;
  36382. /**
  36383. * @hidden
  36384. * Restored camera state. You must call storeState() first
  36385. */
  36386. _restoreStateValues(): boolean;
  36387. /** @hidden */
  36388. _isSynchronizedViewMatrix(): boolean;
  36389. /**
  36390. * Attached controls to the current camera.
  36391. * @param element Defines the element the controls should be listened from
  36392. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36393. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36394. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36395. */
  36396. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36397. /**
  36398. * Detach the current controls from the camera.
  36399. * The camera will stop reacting to inputs.
  36400. * @param element Defines the element to stop listening the inputs from
  36401. */
  36402. detachControl(element: HTMLElement): void;
  36403. /** @hidden */
  36404. _checkInputs(): void;
  36405. protected _checkLimits(): void;
  36406. /**
  36407. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36408. */
  36409. rebuildAnglesAndRadius(): void;
  36410. /**
  36411. * Use a position to define the current camera related information like aplha, beta and radius
  36412. * @param position Defines the position to set the camera at
  36413. */
  36414. setPosition(position: Vector3): void;
  36415. /**
  36416. * Defines the target the camera should look at.
  36417. * This will automatically adapt alpha beta and radius to fit within the new target.
  36418. * @param target Defines the new target as a Vector or a mesh
  36419. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36420. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36421. */
  36422. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36423. /** @hidden */
  36424. _getViewMatrix(): Matrix;
  36425. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36426. /**
  36427. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36428. * @param meshes Defines the mesh to zoom on
  36429. * @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)
  36430. */
  36431. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36432. /**
  36433. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36434. * The target will be changed but the radius
  36435. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36436. * @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)
  36437. */
  36438. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36439. min: Vector3;
  36440. max: Vector3;
  36441. distance: number;
  36442. }, doNotUpdateMaxZ?: boolean): void;
  36443. /**
  36444. * @override
  36445. * Override Camera.createRigCamera
  36446. */
  36447. createRigCamera(name: string, cameraIndex: number): Camera;
  36448. /**
  36449. * @hidden
  36450. * @override
  36451. * Override Camera._updateRigCameras
  36452. */
  36453. _updateRigCameras(): void;
  36454. /**
  36455. * Destroy the camera and release the current resources hold by it.
  36456. */
  36457. dispose(): void;
  36458. /**
  36459. * Gets the current object class name.
  36460. * @return the class name
  36461. */
  36462. getClassName(): string;
  36463. }
  36464. }
  36465. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36466. import { Behavior } from "babylonjs/Behaviors/behavior";
  36467. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36468. /**
  36469. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36470. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36471. */
  36472. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36473. /**
  36474. * Gets the name of the behavior.
  36475. */
  36476. readonly name: string;
  36477. private _zoomStopsAnimation;
  36478. private _idleRotationSpeed;
  36479. private _idleRotationWaitTime;
  36480. private _idleRotationSpinupTime;
  36481. /**
  36482. * Sets the flag that indicates if user zooming should stop animation.
  36483. */
  36484. /**
  36485. * Gets the flag that indicates if user zooming should stop animation.
  36486. */
  36487. zoomStopsAnimation: boolean;
  36488. /**
  36489. * Sets the default speed at which the camera rotates around the model.
  36490. */
  36491. /**
  36492. * Gets the default speed at which the camera rotates around the model.
  36493. */
  36494. idleRotationSpeed: number;
  36495. /**
  36496. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36497. */
  36498. /**
  36499. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36500. */
  36501. idleRotationWaitTime: number;
  36502. /**
  36503. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36504. */
  36505. /**
  36506. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36507. */
  36508. idleRotationSpinupTime: number;
  36509. /**
  36510. * Gets a value indicating if the camera is currently rotating because of this behavior
  36511. */
  36512. readonly rotationInProgress: boolean;
  36513. private _onPrePointerObservableObserver;
  36514. private _onAfterCheckInputsObserver;
  36515. private _attachedCamera;
  36516. private _isPointerDown;
  36517. private _lastFrameTime;
  36518. private _lastInteractionTime;
  36519. private _cameraRotationSpeed;
  36520. /**
  36521. * Initializes the behavior.
  36522. */
  36523. init(): void;
  36524. /**
  36525. * Attaches the behavior to its arc rotate camera.
  36526. * @param camera Defines the camera to attach the behavior to
  36527. */
  36528. attach(camera: ArcRotateCamera): void;
  36529. /**
  36530. * Detaches the behavior from its current arc rotate camera.
  36531. */
  36532. detach(): void;
  36533. /**
  36534. * Returns true if user is scrolling.
  36535. * @return true if user is scrolling.
  36536. */
  36537. private _userIsZooming;
  36538. private _lastFrameRadius;
  36539. private _shouldAnimationStopForInteraction;
  36540. /**
  36541. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36542. */
  36543. private _applyUserInteraction;
  36544. private _userIsMoving;
  36545. }
  36546. }
  36547. declare module "babylonjs/Behaviors/Cameras/index" {
  36548. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36549. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36550. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36551. }
  36552. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36553. import { Mesh } from "babylonjs/Meshes/mesh";
  36554. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36555. import { Behavior } from "babylonjs/Behaviors/behavior";
  36556. /**
  36557. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36558. */
  36559. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36560. private ui;
  36561. /**
  36562. * The name of the behavior
  36563. */
  36564. name: string;
  36565. /**
  36566. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36567. */
  36568. distanceAwayFromFace: number;
  36569. /**
  36570. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36571. */
  36572. distanceAwayFromBottomOfFace: number;
  36573. private _faceVectors;
  36574. private _target;
  36575. private _scene;
  36576. private _onRenderObserver;
  36577. private _tmpMatrix;
  36578. private _tmpVector;
  36579. /**
  36580. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36581. * @param ui The transform node that should be attched to the mesh
  36582. */
  36583. constructor(ui: TransformNode);
  36584. /**
  36585. * Initializes the behavior
  36586. */
  36587. init(): void;
  36588. private _closestFace;
  36589. private _zeroVector;
  36590. private _lookAtTmpMatrix;
  36591. private _lookAtToRef;
  36592. /**
  36593. * Attaches the AttachToBoxBehavior to the passed in mesh
  36594. * @param target The mesh that the specified node will be attached to
  36595. */
  36596. attach(target: Mesh): void;
  36597. /**
  36598. * Detaches the behavior from the mesh
  36599. */
  36600. detach(): void;
  36601. }
  36602. }
  36603. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36604. import { Behavior } from "babylonjs/Behaviors/behavior";
  36605. import { Mesh } from "babylonjs/Meshes/mesh";
  36606. /**
  36607. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36608. */
  36609. export class FadeInOutBehavior implements Behavior<Mesh> {
  36610. /**
  36611. * Time in milliseconds to delay before fading in (Default: 0)
  36612. */
  36613. delay: number;
  36614. /**
  36615. * Time in milliseconds for the mesh to fade in (Default: 300)
  36616. */
  36617. fadeInTime: number;
  36618. private _millisecondsPerFrame;
  36619. private _hovered;
  36620. private _hoverValue;
  36621. private _ownerNode;
  36622. /**
  36623. * Instatiates the FadeInOutBehavior
  36624. */
  36625. constructor();
  36626. /**
  36627. * The name of the behavior
  36628. */
  36629. readonly name: string;
  36630. /**
  36631. * Initializes the behavior
  36632. */
  36633. init(): void;
  36634. /**
  36635. * Attaches the fade behavior on the passed in mesh
  36636. * @param ownerNode The mesh that will be faded in/out once attached
  36637. */
  36638. attach(ownerNode: Mesh): void;
  36639. /**
  36640. * Detaches the behavior from the mesh
  36641. */
  36642. detach(): void;
  36643. /**
  36644. * Triggers the mesh to begin fading in or out
  36645. * @param value if the object should fade in or out (true to fade in)
  36646. */
  36647. fadeIn(value: boolean): void;
  36648. private _update;
  36649. private _setAllVisibility;
  36650. }
  36651. }
  36652. declare module "babylonjs/Misc/pivotTools" {
  36653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36654. /**
  36655. * Class containing a set of static utilities functions for managing Pivots
  36656. * @hidden
  36657. */
  36658. export class PivotTools {
  36659. private static _PivotCached;
  36660. private static _OldPivotPoint;
  36661. private static _PivotTranslation;
  36662. private static _PivotTmpVector;
  36663. /** @hidden */
  36664. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36665. /** @hidden */
  36666. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36667. }
  36668. }
  36669. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36670. import { Scene } from "babylonjs/scene";
  36671. import { Vector4, Plane } from "babylonjs/Maths/math";
  36672. import { Mesh } from "babylonjs/Meshes/mesh";
  36673. import { Nullable } from "babylonjs/types";
  36674. /**
  36675. * Class containing static functions to help procedurally build meshes
  36676. */
  36677. export class PlaneBuilder {
  36678. /**
  36679. * Creates a plane mesh
  36680. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36681. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36682. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36686. * @param name defines the name of the mesh
  36687. * @param options defines the options used to create the mesh
  36688. * @param scene defines the hosting scene
  36689. * @returns the plane mesh
  36690. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36691. */
  36692. static CreatePlane(name: string, options: {
  36693. size?: number;
  36694. width?: number;
  36695. height?: number;
  36696. sideOrientation?: number;
  36697. frontUVs?: Vector4;
  36698. backUVs?: Vector4;
  36699. updatable?: boolean;
  36700. sourcePlane?: Plane;
  36701. }, scene?: Nullable<Scene>): Mesh;
  36702. }
  36703. }
  36704. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36705. import { Behavior } from "babylonjs/Behaviors/behavior";
  36706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36707. import { Observable } from "babylonjs/Misc/observable";
  36708. import { Vector3 } from "babylonjs/Maths/math";
  36709. import { Ray } from "babylonjs/Culling/ray";
  36710. import "babylonjs/Meshes/Builders/planeBuilder";
  36711. /**
  36712. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36713. */
  36714. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36715. private static _AnyMouseID;
  36716. private _attachedNode;
  36717. private _dragPlane;
  36718. private _scene;
  36719. private _pointerObserver;
  36720. private _beforeRenderObserver;
  36721. private static _planeScene;
  36722. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36723. /**
  36724. * 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)
  36725. */
  36726. maxDragAngle: number;
  36727. /**
  36728. * @hidden
  36729. */
  36730. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36731. /**
  36732. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36733. */
  36734. currentDraggingPointerID: number;
  36735. /**
  36736. * The last position where the pointer hit the drag plane in world space
  36737. */
  36738. lastDragPosition: Vector3;
  36739. /**
  36740. * If the behavior is currently in a dragging state
  36741. */
  36742. dragging: boolean;
  36743. /**
  36744. * 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)
  36745. */
  36746. dragDeltaRatio: number;
  36747. /**
  36748. * If the drag plane orientation should be updated during the dragging (Default: true)
  36749. */
  36750. updateDragPlane: boolean;
  36751. private _debugMode;
  36752. private _moving;
  36753. /**
  36754. * Fires each time the attached mesh is dragged with the pointer
  36755. * * delta between last drag position and current drag position in world space
  36756. * * dragDistance along the drag axis
  36757. * * dragPlaneNormal normal of the current drag plane used during the drag
  36758. * * dragPlanePoint in world space where the drag intersects the drag plane
  36759. */
  36760. onDragObservable: Observable<{
  36761. delta: Vector3;
  36762. dragPlanePoint: Vector3;
  36763. dragPlaneNormal: Vector3;
  36764. dragDistance: number;
  36765. pointerId: number;
  36766. }>;
  36767. /**
  36768. * Fires each time a drag begins (eg. mouse down on mesh)
  36769. */
  36770. onDragStartObservable: Observable<{
  36771. dragPlanePoint: Vector3;
  36772. pointerId: number;
  36773. }>;
  36774. /**
  36775. * Fires each time a drag ends (eg. mouse release after drag)
  36776. */
  36777. onDragEndObservable: Observable<{
  36778. dragPlanePoint: Vector3;
  36779. pointerId: number;
  36780. }>;
  36781. /**
  36782. * If the attached mesh should be moved when dragged
  36783. */
  36784. moveAttached: boolean;
  36785. /**
  36786. * If the drag behavior will react to drag events (Default: true)
  36787. */
  36788. enabled: boolean;
  36789. /**
  36790. * If camera controls should be detached during the drag
  36791. */
  36792. detachCameraControls: boolean;
  36793. /**
  36794. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36795. */
  36796. useObjectOrienationForDragging: boolean;
  36797. private _options;
  36798. /**
  36799. * Creates a pointer drag behavior that can be attached to a mesh
  36800. * @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)
  36801. */
  36802. constructor(options?: {
  36803. dragAxis?: Vector3;
  36804. dragPlaneNormal?: Vector3;
  36805. });
  36806. /**
  36807. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36808. */
  36809. validateDrag: (targetPosition: Vector3) => boolean;
  36810. /**
  36811. * The name of the behavior
  36812. */
  36813. readonly name: string;
  36814. /**
  36815. * Initializes the behavior
  36816. */
  36817. init(): void;
  36818. private _tmpVector;
  36819. private _alternatePickedPoint;
  36820. private _worldDragAxis;
  36821. private _targetPosition;
  36822. private _attachedElement;
  36823. /**
  36824. * Attaches the drag behavior the passed in mesh
  36825. * @param ownerNode The mesh that will be dragged around once attached
  36826. */
  36827. attach(ownerNode: AbstractMesh): void;
  36828. /**
  36829. * Force relase the drag action by code.
  36830. */
  36831. releaseDrag(): void;
  36832. private _startDragRay;
  36833. private _lastPointerRay;
  36834. /**
  36835. * Simulates the start of a pointer drag event on the behavior
  36836. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36837. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36838. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36839. */
  36840. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36841. private _startDrag;
  36842. private _dragDelta;
  36843. private _moveDrag;
  36844. private _pickWithRayOnDragPlane;
  36845. private _pointA;
  36846. private _pointB;
  36847. private _pointC;
  36848. private _lineA;
  36849. private _lineB;
  36850. private _localAxis;
  36851. private _lookAt;
  36852. private _updateDragPlanePosition;
  36853. /**
  36854. * Detaches the behavior from the mesh
  36855. */
  36856. detach(): void;
  36857. }
  36858. }
  36859. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36860. import { Mesh } from "babylonjs/Meshes/mesh";
  36861. import { Behavior } from "babylonjs/Behaviors/behavior";
  36862. /**
  36863. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36864. */
  36865. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36866. private _dragBehaviorA;
  36867. private _dragBehaviorB;
  36868. private _startDistance;
  36869. private _initialScale;
  36870. private _targetScale;
  36871. private _ownerNode;
  36872. private _sceneRenderObserver;
  36873. /**
  36874. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36875. */
  36876. constructor();
  36877. /**
  36878. * The name of the behavior
  36879. */
  36880. readonly name: string;
  36881. /**
  36882. * Initializes the behavior
  36883. */
  36884. init(): void;
  36885. private _getCurrentDistance;
  36886. /**
  36887. * Attaches the scale behavior the passed in mesh
  36888. * @param ownerNode The mesh that will be scaled around once attached
  36889. */
  36890. attach(ownerNode: Mesh): void;
  36891. /**
  36892. * Detaches the behavior from the mesh
  36893. */
  36894. detach(): void;
  36895. }
  36896. }
  36897. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36898. import { Behavior } from "babylonjs/Behaviors/behavior";
  36899. import { Mesh } from "babylonjs/Meshes/mesh";
  36900. import { Observable } from "babylonjs/Misc/observable";
  36901. /**
  36902. * 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
  36903. */
  36904. export class SixDofDragBehavior implements Behavior<Mesh> {
  36905. private static _virtualScene;
  36906. private _ownerNode;
  36907. private _sceneRenderObserver;
  36908. private _scene;
  36909. private _targetPosition;
  36910. private _virtualOriginMesh;
  36911. private _virtualDragMesh;
  36912. private _pointerObserver;
  36913. private _moving;
  36914. private _startingOrientation;
  36915. /**
  36916. * 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)
  36917. */
  36918. private zDragFactor;
  36919. /**
  36920. * If the object should rotate to face the drag origin
  36921. */
  36922. rotateDraggedObject: boolean;
  36923. /**
  36924. * If the behavior is currently in a dragging state
  36925. */
  36926. dragging: boolean;
  36927. /**
  36928. * 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)
  36929. */
  36930. dragDeltaRatio: number;
  36931. /**
  36932. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36933. */
  36934. currentDraggingPointerID: number;
  36935. /**
  36936. * If camera controls should be detached during the drag
  36937. */
  36938. detachCameraControls: boolean;
  36939. /**
  36940. * Fires each time a drag starts
  36941. */
  36942. onDragStartObservable: Observable<{}>;
  36943. /**
  36944. * Fires each time a drag ends (eg. mouse release after drag)
  36945. */
  36946. onDragEndObservable: Observable<{}>;
  36947. /**
  36948. * 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
  36949. */
  36950. constructor();
  36951. /**
  36952. * The name of the behavior
  36953. */
  36954. readonly name: string;
  36955. /**
  36956. * Initializes the behavior
  36957. */
  36958. init(): void;
  36959. /**
  36960. * Attaches the scale behavior the passed in mesh
  36961. * @param ownerNode The mesh that will be scaled around once attached
  36962. */
  36963. attach(ownerNode: Mesh): void;
  36964. /**
  36965. * Detaches the behavior from the mesh
  36966. */
  36967. detach(): void;
  36968. }
  36969. }
  36970. declare module "babylonjs/Behaviors/Meshes/index" {
  36971. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36972. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36973. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36974. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36975. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36976. }
  36977. declare module "babylonjs/Behaviors/index" {
  36978. export * from "babylonjs/Behaviors/behavior";
  36979. export * from "babylonjs/Behaviors/Cameras/index";
  36980. export * from "babylonjs/Behaviors/Meshes/index";
  36981. }
  36982. declare module "babylonjs/Bones/boneIKController" {
  36983. import { Bone } from "babylonjs/Bones/bone";
  36984. import { Vector3 } from "babylonjs/Maths/math";
  36985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36986. import { Nullable } from "babylonjs/types";
  36987. /**
  36988. * Class used to apply inverse kinematics to bones
  36989. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36990. */
  36991. export class BoneIKController {
  36992. private static _tmpVecs;
  36993. private static _tmpQuat;
  36994. private static _tmpMats;
  36995. /**
  36996. * Gets or sets the target mesh
  36997. */
  36998. targetMesh: AbstractMesh;
  36999. /** Gets or sets the mesh used as pole */
  37000. poleTargetMesh: AbstractMesh;
  37001. /**
  37002. * Gets or sets the bone used as pole
  37003. */
  37004. poleTargetBone: Nullable<Bone>;
  37005. /**
  37006. * Gets or sets the target position
  37007. */
  37008. targetPosition: Vector3;
  37009. /**
  37010. * Gets or sets the pole target position
  37011. */
  37012. poleTargetPosition: Vector3;
  37013. /**
  37014. * Gets or sets the pole target local offset
  37015. */
  37016. poleTargetLocalOffset: Vector3;
  37017. /**
  37018. * Gets or sets the pole angle
  37019. */
  37020. poleAngle: number;
  37021. /**
  37022. * Gets or sets the mesh associated with the controller
  37023. */
  37024. mesh: AbstractMesh;
  37025. /**
  37026. * 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)
  37027. */
  37028. slerpAmount: number;
  37029. private _bone1Quat;
  37030. private _bone1Mat;
  37031. private _bone2Ang;
  37032. private _bone1;
  37033. private _bone2;
  37034. private _bone1Length;
  37035. private _bone2Length;
  37036. private _maxAngle;
  37037. private _maxReach;
  37038. private _rightHandedSystem;
  37039. private _bendAxis;
  37040. private _slerping;
  37041. private _adjustRoll;
  37042. /**
  37043. * Gets or sets maximum allowed angle
  37044. */
  37045. maxAngle: number;
  37046. /**
  37047. * Creates a new BoneIKController
  37048. * @param mesh defines the mesh to control
  37049. * @param bone defines the bone to control
  37050. * @param options defines options to set up the controller
  37051. */
  37052. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37053. targetMesh?: AbstractMesh;
  37054. poleTargetMesh?: AbstractMesh;
  37055. poleTargetBone?: Bone;
  37056. poleTargetLocalOffset?: Vector3;
  37057. poleAngle?: number;
  37058. bendAxis?: Vector3;
  37059. maxAngle?: number;
  37060. slerpAmount?: number;
  37061. });
  37062. private _setMaxAngle;
  37063. /**
  37064. * Force the controller to update the bones
  37065. */
  37066. update(): void;
  37067. }
  37068. }
  37069. declare module "babylonjs/Bones/boneLookController" {
  37070. import { Vector3, Space } from "babylonjs/Maths/math";
  37071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37072. import { Bone } from "babylonjs/Bones/bone";
  37073. /**
  37074. * Class used to make a bone look toward a point in space
  37075. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37076. */
  37077. export class BoneLookController {
  37078. private static _tmpVecs;
  37079. private static _tmpQuat;
  37080. private static _tmpMats;
  37081. /**
  37082. * The target Vector3 that the bone will look at
  37083. */
  37084. target: Vector3;
  37085. /**
  37086. * The mesh that the bone is attached to
  37087. */
  37088. mesh: AbstractMesh;
  37089. /**
  37090. * The bone that will be looking to the target
  37091. */
  37092. bone: Bone;
  37093. /**
  37094. * The up axis of the coordinate system that is used when the bone is rotated
  37095. */
  37096. upAxis: Vector3;
  37097. /**
  37098. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37099. */
  37100. upAxisSpace: Space;
  37101. /**
  37102. * Used to make an adjustment to the yaw of the bone
  37103. */
  37104. adjustYaw: number;
  37105. /**
  37106. * Used to make an adjustment to the pitch of the bone
  37107. */
  37108. adjustPitch: number;
  37109. /**
  37110. * Used to make an adjustment to the roll of the bone
  37111. */
  37112. adjustRoll: number;
  37113. /**
  37114. * 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)
  37115. */
  37116. slerpAmount: number;
  37117. private _minYaw;
  37118. private _maxYaw;
  37119. private _minPitch;
  37120. private _maxPitch;
  37121. private _minYawSin;
  37122. private _minYawCos;
  37123. private _maxYawSin;
  37124. private _maxYawCos;
  37125. private _midYawConstraint;
  37126. private _minPitchTan;
  37127. private _maxPitchTan;
  37128. private _boneQuat;
  37129. private _slerping;
  37130. private _transformYawPitch;
  37131. private _transformYawPitchInv;
  37132. private _firstFrameSkipped;
  37133. private _yawRange;
  37134. private _fowardAxis;
  37135. /**
  37136. * Gets or sets the minimum yaw angle that the bone can look to
  37137. */
  37138. minYaw: number;
  37139. /**
  37140. * Gets or sets the maximum yaw angle that the bone can look to
  37141. */
  37142. maxYaw: number;
  37143. /**
  37144. * Gets or sets the minimum pitch angle that the bone can look to
  37145. */
  37146. minPitch: number;
  37147. /**
  37148. * Gets or sets the maximum pitch angle that the bone can look to
  37149. */
  37150. maxPitch: number;
  37151. /**
  37152. * Create a BoneLookController
  37153. * @param mesh the mesh that the bone belongs to
  37154. * @param bone the bone that will be looking to the target
  37155. * @param target the target Vector3 to look at
  37156. * @param options optional settings:
  37157. * * maxYaw: the maximum angle the bone will yaw to
  37158. * * minYaw: the minimum angle the bone will yaw to
  37159. * * maxPitch: the maximum angle the bone will pitch to
  37160. * * minPitch: the minimum angle the bone will yaw to
  37161. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37162. * * upAxis: the up axis of the coordinate system
  37163. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37164. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37165. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37166. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37167. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37168. * * adjustRoll: used to make an adjustment to the roll of the bone
  37169. **/
  37170. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37171. maxYaw?: number;
  37172. minYaw?: number;
  37173. maxPitch?: number;
  37174. minPitch?: number;
  37175. slerpAmount?: number;
  37176. upAxis?: Vector3;
  37177. upAxisSpace?: Space;
  37178. yawAxis?: Vector3;
  37179. pitchAxis?: Vector3;
  37180. adjustYaw?: number;
  37181. adjustPitch?: number;
  37182. adjustRoll?: number;
  37183. });
  37184. /**
  37185. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37186. */
  37187. update(): void;
  37188. private _getAngleDiff;
  37189. private _getAngleBetween;
  37190. private _isAngleBetween;
  37191. }
  37192. }
  37193. declare module "babylonjs/Bones/index" {
  37194. export * from "babylonjs/Bones/bone";
  37195. export * from "babylonjs/Bones/boneIKController";
  37196. export * from "babylonjs/Bones/boneLookController";
  37197. export * from "babylonjs/Bones/skeleton";
  37198. }
  37199. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37200. import { Nullable } from "babylonjs/types";
  37201. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37202. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37203. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37204. /**
  37205. * Manage the gamepad inputs to control an arc rotate camera.
  37206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37207. */
  37208. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37209. /**
  37210. * Defines the camera the input is attached to.
  37211. */
  37212. camera: ArcRotateCamera;
  37213. /**
  37214. * Defines the gamepad the input is gathering event from.
  37215. */
  37216. gamepad: Nullable<Gamepad>;
  37217. /**
  37218. * Defines the gamepad rotation sensiblity.
  37219. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37220. */
  37221. gamepadRotationSensibility: number;
  37222. /**
  37223. * Defines the gamepad move sensiblity.
  37224. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37225. */
  37226. gamepadMoveSensibility: number;
  37227. private _onGamepadConnectedObserver;
  37228. private _onGamepadDisconnectedObserver;
  37229. /**
  37230. * Attach the input controls to a specific dom element to get the input from.
  37231. * @param element Defines the element the controls should be listened from
  37232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37233. */
  37234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37235. /**
  37236. * Detach the current controls from the specified dom element.
  37237. * @param element Defines the element to stop listening the inputs from
  37238. */
  37239. detachControl(element: Nullable<HTMLElement>): void;
  37240. /**
  37241. * Update the current camera state depending on the inputs that have been used this frame.
  37242. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37243. */
  37244. checkInputs(): void;
  37245. /**
  37246. * Gets the class name of the current intput.
  37247. * @returns the class name
  37248. */
  37249. getClassName(): string;
  37250. /**
  37251. * Get the friendly name associated with the input class.
  37252. * @returns the input friendly name
  37253. */
  37254. getSimpleName(): string;
  37255. }
  37256. }
  37257. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37258. import { Nullable } from "babylonjs/types";
  37259. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37260. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37261. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37262. interface ArcRotateCameraInputsManager {
  37263. /**
  37264. * Add orientation input support to the input manager.
  37265. * @returns the current input manager
  37266. */
  37267. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37268. }
  37269. }
  37270. /**
  37271. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37272. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37273. */
  37274. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37275. /**
  37276. * Defines the camera the input is attached to.
  37277. */
  37278. camera: ArcRotateCamera;
  37279. /**
  37280. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37281. */
  37282. alphaCorrection: number;
  37283. /**
  37284. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37285. */
  37286. gammaCorrection: number;
  37287. private _alpha;
  37288. private _gamma;
  37289. private _dirty;
  37290. private _deviceOrientationHandler;
  37291. /**
  37292. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37293. */
  37294. constructor();
  37295. /**
  37296. * Attach the input controls to a specific dom element to get the input from.
  37297. * @param element Defines the element the controls should be listened from
  37298. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37299. */
  37300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37301. /** @hidden */
  37302. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37303. /**
  37304. * Update the current camera state depending on the inputs that have been used this frame.
  37305. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37306. */
  37307. checkInputs(): void;
  37308. /**
  37309. * Detach the current controls from the specified dom element.
  37310. * @param element Defines the element to stop listening the inputs from
  37311. */
  37312. detachControl(element: Nullable<HTMLElement>): void;
  37313. /**
  37314. * Gets the class name of the current intput.
  37315. * @returns the class name
  37316. */
  37317. getClassName(): string;
  37318. /**
  37319. * Get the friendly name associated with the input class.
  37320. * @returns the input friendly name
  37321. */
  37322. getSimpleName(): string;
  37323. }
  37324. }
  37325. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37326. import { Nullable } from "babylonjs/types";
  37327. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37328. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37329. /**
  37330. * Listen to mouse events to control the camera.
  37331. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37332. */
  37333. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37334. /**
  37335. * Defines the camera the input is attached to.
  37336. */
  37337. camera: FlyCamera;
  37338. /**
  37339. * Defines if touch is enabled. (Default is true.)
  37340. */
  37341. touchEnabled: boolean;
  37342. /**
  37343. * Defines the buttons associated with the input to handle camera rotation.
  37344. */
  37345. buttons: number[];
  37346. /**
  37347. * Assign buttons for Yaw control.
  37348. */
  37349. buttonsYaw: number[];
  37350. /**
  37351. * Assign buttons for Pitch control.
  37352. */
  37353. buttonsPitch: number[];
  37354. /**
  37355. * Assign buttons for Roll control.
  37356. */
  37357. buttonsRoll: number[];
  37358. /**
  37359. * Detect if any button is being pressed while mouse is moved.
  37360. * -1 = Mouse locked.
  37361. * 0 = Left button.
  37362. * 1 = Middle Button.
  37363. * 2 = Right Button.
  37364. */
  37365. activeButton: number;
  37366. /**
  37367. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37368. * Higher values reduce its sensitivity.
  37369. */
  37370. angularSensibility: number;
  37371. private _mousemoveCallback;
  37372. private _observer;
  37373. private _rollObserver;
  37374. private previousPosition;
  37375. private noPreventDefault;
  37376. private element;
  37377. /**
  37378. * Listen to mouse events to control the camera.
  37379. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37380. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37381. */
  37382. constructor(touchEnabled?: boolean);
  37383. /**
  37384. * Attach the mouse control to the HTML DOM element.
  37385. * @param element Defines the element that listens to the input events.
  37386. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37387. */
  37388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37389. /**
  37390. * Detach the current controls from the specified dom element.
  37391. * @param element Defines the element to stop listening the inputs from
  37392. */
  37393. detachControl(element: Nullable<HTMLElement>): void;
  37394. /**
  37395. * Gets the class name of the current input.
  37396. * @returns the class name.
  37397. */
  37398. getClassName(): string;
  37399. /**
  37400. * Get the friendly name associated with the input class.
  37401. * @returns the input's friendly name.
  37402. */
  37403. getSimpleName(): string;
  37404. private _pointerInput;
  37405. private _onMouseMove;
  37406. /**
  37407. * Rotate camera by mouse offset.
  37408. */
  37409. private rotateCamera;
  37410. }
  37411. }
  37412. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37413. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37414. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37415. /**
  37416. * Default Inputs manager for the FlyCamera.
  37417. * It groups all the default supported inputs for ease of use.
  37418. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37419. */
  37420. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37421. /**
  37422. * Instantiates a new FlyCameraInputsManager.
  37423. * @param camera Defines the camera the inputs belong to.
  37424. */
  37425. constructor(camera: FlyCamera);
  37426. /**
  37427. * Add keyboard input support to the input manager.
  37428. * @returns the new FlyCameraKeyboardMoveInput().
  37429. */
  37430. addKeyboard(): FlyCameraInputsManager;
  37431. /**
  37432. * Add mouse input support to the input manager.
  37433. * @param touchEnabled Enable touch screen support.
  37434. * @returns the new FlyCameraMouseInput().
  37435. */
  37436. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37437. }
  37438. }
  37439. declare module "babylonjs/Cameras/flyCamera" {
  37440. import { Scene } from "babylonjs/scene";
  37441. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37443. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37444. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37445. /**
  37446. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37447. * such as in a 3D Space Shooter or a Flight Simulator.
  37448. */
  37449. export class FlyCamera extends TargetCamera {
  37450. /**
  37451. * Define the collision ellipsoid of the camera.
  37452. * This is helpful for simulating a camera body, like a player's body.
  37453. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37454. */
  37455. ellipsoid: Vector3;
  37456. /**
  37457. * Define an offset for the position of the ellipsoid around the camera.
  37458. * This can be helpful if the camera is attached away from the player's body center,
  37459. * such as at its head.
  37460. */
  37461. ellipsoidOffset: Vector3;
  37462. /**
  37463. * Enable or disable collisions of the camera with the rest of the scene objects.
  37464. */
  37465. checkCollisions: boolean;
  37466. /**
  37467. * Enable or disable gravity on the camera.
  37468. */
  37469. applyGravity: boolean;
  37470. /**
  37471. * Define the current direction the camera is moving to.
  37472. */
  37473. cameraDirection: Vector3;
  37474. /**
  37475. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37476. * This overrides and empties cameraRotation.
  37477. */
  37478. rotationQuaternion: Quaternion;
  37479. /**
  37480. * Track Roll to maintain the wanted Rolling when looking around.
  37481. */
  37482. _trackRoll: number;
  37483. /**
  37484. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37485. */
  37486. rollCorrect: number;
  37487. /**
  37488. * Mimic a banked turn, Rolling the camera when Yawing.
  37489. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37490. */
  37491. bankedTurn: boolean;
  37492. /**
  37493. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37494. */
  37495. bankedTurnLimit: number;
  37496. /**
  37497. * Value of 0 disables the banked Roll.
  37498. * Value of 1 is equal to the Yaw angle in radians.
  37499. */
  37500. bankedTurnMultiplier: number;
  37501. /**
  37502. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37503. */
  37504. inputs: FlyCameraInputsManager;
  37505. /**
  37506. * Gets the input sensibility for mouse input.
  37507. * Higher values reduce sensitivity.
  37508. */
  37509. /**
  37510. * Sets the input sensibility for a mouse input.
  37511. * Higher values reduce sensitivity.
  37512. */
  37513. angularSensibility: number;
  37514. /**
  37515. * Get the keys for camera movement forward.
  37516. */
  37517. /**
  37518. * Set the keys for camera movement forward.
  37519. */
  37520. keysForward: number[];
  37521. /**
  37522. * Get the keys for camera movement backward.
  37523. */
  37524. keysBackward: number[];
  37525. /**
  37526. * Get the keys for camera movement up.
  37527. */
  37528. /**
  37529. * Set the keys for camera movement up.
  37530. */
  37531. keysUp: number[];
  37532. /**
  37533. * Get the keys for camera movement down.
  37534. */
  37535. /**
  37536. * Set the keys for camera movement down.
  37537. */
  37538. keysDown: number[];
  37539. /**
  37540. * Get the keys for camera movement left.
  37541. */
  37542. /**
  37543. * Set the keys for camera movement left.
  37544. */
  37545. keysLeft: number[];
  37546. /**
  37547. * Set the keys for camera movement right.
  37548. */
  37549. /**
  37550. * Set the keys for camera movement right.
  37551. */
  37552. keysRight: number[];
  37553. /**
  37554. * Event raised when the camera collides with a mesh in the scene.
  37555. */
  37556. onCollide: (collidedMesh: AbstractMesh) => void;
  37557. private _collider;
  37558. private _needMoveForGravity;
  37559. private _oldPosition;
  37560. private _diffPosition;
  37561. private _newPosition;
  37562. /** @hidden */
  37563. _localDirection: Vector3;
  37564. /** @hidden */
  37565. _transformedDirection: Vector3;
  37566. /**
  37567. * Instantiates a FlyCamera.
  37568. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37569. * such as in a 3D Space Shooter or a Flight Simulator.
  37570. * @param name Define the name of the camera in the scene.
  37571. * @param position Define the starting position of the camera in the scene.
  37572. * @param scene Define the scene the camera belongs to.
  37573. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37574. */
  37575. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37576. /**
  37577. * Attach a control to the HTML DOM element.
  37578. * @param element Defines the element that listens to the input events.
  37579. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37580. */
  37581. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37582. /**
  37583. * Detach a control from the HTML DOM element.
  37584. * The camera will stop reacting to that input.
  37585. * @param element Defines the element that listens to the input events.
  37586. */
  37587. detachControl(element: HTMLElement): void;
  37588. private _collisionMask;
  37589. /**
  37590. * Get the mask that the camera ignores in collision events.
  37591. */
  37592. /**
  37593. * Set the mask that the camera ignores in collision events.
  37594. */
  37595. collisionMask: number;
  37596. /** @hidden */
  37597. _collideWithWorld(displacement: Vector3): void;
  37598. /** @hidden */
  37599. private _onCollisionPositionChange;
  37600. /** @hidden */
  37601. _checkInputs(): void;
  37602. /** @hidden */
  37603. _decideIfNeedsToMove(): boolean;
  37604. /** @hidden */
  37605. _updatePosition(): void;
  37606. /**
  37607. * Restore the Roll to its target value at the rate specified.
  37608. * @param rate - Higher means slower restoring.
  37609. * @hidden
  37610. */
  37611. restoreRoll(rate: number): void;
  37612. /**
  37613. * Destroy the camera and release the current resources held by it.
  37614. */
  37615. dispose(): void;
  37616. /**
  37617. * Get the current object class name.
  37618. * @returns the class name.
  37619. */
  37620. getClassName(): string;
  37621. }
  37622. }
  37623. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37624. import { Nullable } from "babylonjs/types";
  37625. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37626. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37627. /**
  37628. * Listen to keyboard events to control the camera.
  37629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37630. */
  37631. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37632. /**
  37633. * Defines the camera the input is attached to.
  37634. */
  37635. camera: FlyCamera;
  37636. /**
  37637. * The list of keyboard keys used to control the forward move of the camera.
  37638. */
  37639. keysForward: number[];
  37640. /**
  37641. * The list of keyboard keys used to control the backward move of the camera.
  37642. */
  37643. keysBackward: number[];
  37644. /**
  37645. * The list of keyboard keys used to control the forward move of the camera.
  37646. */
  37647. keysUp: number[];
  37648. /**
  37649. * The list of keyboard keys used to control the backward move of the camera.
  37650. */
  37651. keysDown: number[];
  37652. /**
  37653. * The list of keyboard keys used to control the right strafe move of the camera.
  37654. */
  37655. keysRight: number[];
  37656. /**
  37657. * The list of keyboard keys used to control the left strafe move of the camera.
  37658. */
  37659. keysLeft: number[];
  37660. private _keys;
  37661. private _onCanvasBlurObserver;
  37662. private _onKeyboardObserver;
  37663. private _engine;
  37664. private _scene;
  37665. /**
  37666. * Attach the input controls to a specific dom element to get the input from.
  37667. * @param element Defines the element the controls should be listened from
  37668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37669. */
  37670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37671. /**
  37672. * Detach the current controls from the specified dom element.
  37673. * @param element Defines the element to stop listening the inputs from
  37674. */
  37675. detachControl(element: Nullable<HTMLElement>): void;
  37676. /**
  37677. * Gets the class name of the current intput.
  37678. * @returns the class name
  37679. */
  37680. getClassName(): string;
  37681. /** @hidden */
  37682. _onLostFocus(e: FocusEvent): void;
  37683. /**
  37684. * Get the friendly name associated with the input class.
  37685. * @returns the input friendly name
  37686. */
  37687. getSimpleName(): string;
  37688. /**
  37689. * Update the current camera state depending on the inputs that have been used this frame.
  37690. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37691. */
  37692. checkInputs(): void;
  37693. }
  37694. }
  37695. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37696. import { Nullable } from "babylonjs/types";
  37697. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37698. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37699. /**
  37700. * Manage the mouse wheel inputs to control a follow camera.
  37701. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37702. */
  37703. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37704. /**
  37705. * Defines the camera the input is attached to.
  37706. */
  37707. camera: FollowCamera;
  37708. /**
  37709. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37710. */
  37711. axisControlRadius: boolean;
  37712. /**
  37713. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37714. */
  37715. axisControlHeight: boolean;
  37716. /**
  37717. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37718. */
  37719. axisControlRotation: boolean;
  37720. /**
  37721. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37722. * relation to mouseWheel events.
  37723. */
  37724. wheelPrecision: number;
  37725. /**
  37726. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37727. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37728. */
  37729. wheelDeltaPercentage: number;
  37730. private _wheel;
  37731. private _observer;
  37732. /**
  37733. * Attach the input controls to a specific dom element to get the input from.
  37734. * @param element Defines the element the controls should be listened from
  37735. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37736. */
  37737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37738. /**
  37739. * Detach the current controls from the specified dom element.
  37740. * @param element Defines the element to stop listening the inputs from
  37741. */
  37742. detachControl(element: Nullable<HTMLElement>): void;
  37743. /**
  37744. * Gets the class name of the current intput.
  37745. * @returns the class name
  37746. */
  37747. getClassName(): string;
  37748. /**
  37749. * Get the friendly name associated with the input class.
  37750. * @returns the input friendly name
  37751. */
  37752. getSimpleName(): string;
  37753. }
  37754. }
  37755. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37756. import { Nullable } from "babylonjs/types";
  37757. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37758. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37759. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37760. /**
  37761. * Manage the pointers inputs to control an follow camera.
  37762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37763. */
  37764. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37765. /**
  37766. * Defines the camera the input is attached to.
  37767. */
  37768. camera: FollowCamera;
  37769. /**
  37770. * Gets the class name of the current input.
  37771. * @returns the class name
  37772. */
  37773. getClassName(): string;
  37774. /**
  37775. * Defines the pointer angular sensibility along the X axis or how fast is
  37776. * the camera rotating.
  37777. * A negative number will reverse the axis direction.
  37778. */
  37779. angularSensibilityX: number;
  37780. /**
  37781. * Defines the pointer angular sensibility along the Y axis or how fast is
  37782. * the camera rotating.
  37783. * A negative number will reverse the axis direction.
  37784. */
  37785. angularSensibilityY: number;
  37786. /**
  37787. * Defines the pointer pinch precision or how fast is the camera zooming.
  37788. * A negative number will reverse the axis direction.
  37789. */
  37790. pinchPrecision: number;
  37791. /**
  37792. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37793. * from 0.
  37794. * It defines the percentage of current camera.radius to use as delta when
  37795. * pinch zoom is used.
  37796. */
  37797. pinchDeltaPercentage: number;
  37798. /**
  37799. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37800. */
  37801. axisXControlRadius: boolean;
  37802. /**
  37803. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37804. */
  37805. axisXControlHeight: boolean;
  37806. /**
  37807. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37808. */
  37809. axisXControlRotation: boolean;
  37810. /**
  37811. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37812. */
  37813. axisYControlRadius: boolean;
  37814. /**
  37815. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37816. */
  37817. axisYControlHeight: boolean;
  37818. /**
  37819. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37820. */
  37821. axisYControlRotation: boolean;
  37822. /**
  37823. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37824. */
  37825. axisPinchControlRadius: boolean;
  37826. /**
  37827. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37828. */
  37829. axisPinchControlHeight: boolean;
  37830. /**
  37831. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37832. */
  37833. axisPinchControlRotation: boolean;
  37834. /**
  37835. * Log error messages if basic misconfiguration has occurred.
  37836. */
  37837. warningEnable: boolean;
  37838. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37839. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37840. private _warningCounter;
  37841. private _warning;
  37842. }
  37843. }
  37844. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37845. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37846. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37847. /**
  37848. * Default Inputs manager for the FollowCamera.
  37849. * It groups all the default supported inputs for ease of use.
  37850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37851. */
  37852. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37853. /**
  37854. * Instantiates a new FollowCameraInputsManager.
  37855. * @param camera Defines the camera the inputs belong to
  37856. */
  37857. constructor(camera: FollowCamera);
  37858. /**
  37859. * Add keyboard input support to the input manager.
  37860. * @returns the current input manager
  37861. */
  37862. addKeyboard(): FollowCameraInputsManager;
  37863. /**
  37864. * Add mouse wheel input support to the input manager.
  37865. * @returns the current input manager
  37866. */
  37867. addMouseWheel(): FollowCameraInputsManager;
  37868. /**
  37869. * Add pointers input support to the input manager.
  37870. * @returns the current input manager
  37871. */
  37872. addPointers(): FollowCameraInputsManager;
  37873. /**
  37874. * Add orientation input support to the input manager.
  37875. * @returns the current input manager
  37876. */
  37877. addVRDeviceOrientation(): FollowCameraInputsManager;
  37878. }
  37879. }
  37880. declare module "babylonjs/Cameras/followCamera" {
  37881. import { Nullable } from "babylonjs/types";
  37882. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37883. import { Scene } from "babylonjs/scene";
  37884. import { Vector3 } from "babylonjs/Maths/math";
  37885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37886. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37887. /**
  37888. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37889. * an arc rotate version arcFollowCamera are available.
  37890. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37891. */
  37892. export class FollowCamera extends TargetCamera {
  37893. /**
  37894. * Distance the follow camera should follow an object at
  37895. */
  37896. radius: number;
  37897. /**
  37898. * Minimum allowed distance of the camera to the axis of rotation
  37899. * (The camera can not get closer).
  37900. * This can help limiting how the Camera is able to move in the scene.
  37901. */
  37902. lowerRadiusLimit: Nullable<number>;
  37903. /**
  37904. * Maximum allowed distance of the camera to the axis of rotation
  37905. * (The camera can not get further).
  37906. * This can help limiting how the Camera is able to move in the scene.
  37907. */
  37908. upperRadiusLimit: Nullable<number>;
  37909. /**
  37910. * Define a rotation offset between the camera and the object it follows
  37911. */
  37912. rotationOffset: number;
  37913. /**
  37914. * Minimum allowed angle to camera position relative to target object.
  37915. * This can help limiting how the Camera is able to move in the scene.
  37916. */
  37917. lowerRotationOffsetLimit: Nullable<number>;
  37918. /**
  37919. * Maximum allowed angle to camera position relative to target object.
  37920. * This can help limiting how the Camera is able to move in the scene.
  37921. */
  37922. upperRotationOffsetLimit: Nullable<number>;
  37923. /**
  37924. * Define a height offset between the camera and the object it follows.
  37925. * It can help following an object from the top (like a car chaing a plane)
  37926. */
  37927. heightOffset: number;
  37928. /**
  37929. * Minimum allowed height of camera position relative to target object.
  37930. * This can help limiting how the Camera is able to move in the scene.
  37931. */
  37932. lowerHeightOffsetLimit: Nullable<number>;
  37933. /**
  37934. * Maximum allowed height of camera position relative to target object.
  37935. * This can help limiting how the Camera is able to move in the scene.
  37936. */
  37937. upperHeightOffsetLimit: Nullable<number>;
  37938. /**
  37939. * Define how fast the camera can accelerate to follow it s target.
  37940. */
  37941. cameraAcceleration: number;
  37942. /**
  37943. * Define the speed limit of the camera following an object.
  37944. */
  37945. maxCameraSpeed: number;
  37946. /**
  37947. * Define the target of the camera.
  37948. */
  37949. lockedTarget: Nullable<AbstractMesh>;
  37950. /**
  37951. * Defines the input associated with the camera.
  37952. */
  37953. inputs: FollowCameraInputsManager;
  37954. /**
  37955. * Instantiates the follow camera.
  37956. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37957. * @param name Define the name of the camera in the scene
  37958. * @param position Define the position of the camera
  37959. * @param scene Define the scene the camera belong to
  37960. * @param lockedTarget Define the target of the camera
  37961. */
  37962. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37963. private _follow;
  37964. /**
  37965. * Attached controls to the current camera.
  37966. * @param element Defines the element the controls should be listened from
  37967. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37968. */
  37969. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37970. /**
  37971. * Detach the current controls from the camera.
  37972. * The camera will stop reacting to inputs.
  37973. * @param element Defines the element to stop listening the inputs from
  37974. */
  37975. detachControl(element: HTMLElement): void;
  37976. /** @hidden */
  37977. _checkInputs(): void;
  37978. private _checkLimits;
  37979. /**
  37980. * Gets the camera class name.
  37981. * @returns the class name
  37982. */
  37983. getClassName(): string;
  37984. }
  37985. /**
  37986. * Arc Rotate version of the follow camera.
  37987. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37988. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37989. */
  37990. export class ArcFollowCamera extends TargetCamera {
  37991. /** The longitudinal angle of the camera */
  37992. alpha: number;
  37993. /** The latitudinal angle of the camera */
  37994. beta: number;
  37995. /** The radius of the camera from its target */
  37996. radius: number;
  37997. /** Define the camera target (the messh it should follow) */
  37998. target: Nullable<AbstractMesh>;
  37999. private _cartesianCoordinates;
  38000. /**
  38001. * Instantiates a new ArcFollowCamera
  38002. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38003. * @param name Define the name of the camera
  38004. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38005. * @param beta Define the rotation angle of the camera around the elevation axis
  38006. * @param radius Define the radius of the camera from its target point
  38007. * @param target Define the target of the camera
  38008. * @param scene Define the scene the camera belongs to
  38009. */
  38010. constructor(name: string,
  38011. /** The longitudinal angle of the camera */
  38012. alpha: number,
  38013. /** The latitudinal angle of the camera */
  38014. beta: number,
  38015. /** The radius of the camera from its target */
  38016. radius: number,
  38017. /** Define the camera target (the messh it should follow) */
  38018. target: Nullable<AbstractMesh>, scene: Scene);
  38019. private _follow;
  38020. /** @hidden */
  38021. _checkInputs(): void;
  38022. /**
  38023. * Returns the class name of the object.
  38024. * It is mostly used internally for serialization purposes.
  38025. */
  38026. getClassName(): string;
  38027. }
  38028. }
  38029. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38030. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38031. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38032. import { Nullable } from "babylonjs/types";
  38033. /**
  38034. * Manage the keyboard inputs to control the movement of a follow camera.
  38035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38036. */
  38037. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38038. /**
  38039. * Defines the camera the input is attached to.
  38040. */
  38041. camera: FollowCamera;
  38042. /**
  38043. * Defines the list of key codes associated with the up action (increase heightOffset)
  38044. */
  38045. keysHeightOffsetIncr: number[];
  38046. /**
  38047. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38048. */
  38049. keysHeightOffsetDecr: number[];
  38050. /**
  38051. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38052. */
  38053. keysHeightOffsetModifierAlt: boolean;
  38054. /**
  38055. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38056. */
  38057. keysHeightOffsetModifierCtrl: boolean;
  38058. /**
  38059. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38060. */
  38061. keysHeightOffsetModifierShift: boolean;
  38062. /**
  38063. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38064. */
  38065. keysRotationOffsetIncr: number[];
  38066. /**
  38067. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38068. */
  38069. keysRotationOffsetDecr: number[];
  38070. /**
  38071. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38072. */
  38073. keysRotationOffsetModifierAlt: boolean;
  38074. /**
  38075. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38076. */
  38077. keysRotationOffsetModifierCtrl: boolean;
  38078. /**
  38079. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38080. */
  38081. keysRotationOffsetModifierShift: boolean;
  38082. /**
  38083. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38084. */
  38085. keysRadiusIncr: number[];
  38086. /**
  38087. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38088. */
  38089. keysRadiusDecr: number[];
  38090. /**
  38091. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38092. */
  38093. keysRadiusModifierAlt: boolean;
  38094. /**
  38095. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38096. */
  38097. keysRadiusModifierCtrl: boolean;
  38098. /**
  38099. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38100. */
  38101. keysRadiusModifierShift: boolean;
  38102. /**
  38103. * Defines the rate of change of heightOffset.
  38104. */
  38105. heightSensibility: number;
  38106. /**
  38107. * Defines the rate of change of rotationOffset.
  38108. */
  38109. rotationSensibility: number;
  38110. /**
  38111. * Defines the rate of change of radius.
  38112. */
  38113. radiusSensibility: number;
  38114. private _keys;
  38115. private _ctrlPressed;
  38116. private _altPressed;
  38117. private _shiftPressed;
  38118. private _onCanvasBlurObserver;
  38119. private _onKeyboardObserver;
  38120. private _engine;
  38121. private _scene;
  38122. /**
  38123. * Attach the input controls to a specific dom element to get the input from.
  38124. * @param element Defines the element the controls should be listened from
  38125. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38126. */
  38127. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38128. /**
  38129. * Detach the current controls from the specified dom element.
  38130. * @param element Defines the element to stop listening the inputs from
  38131. */
  38132. detachControl(element: Nullable<HTMLElement>): void;
  38133. /**
  38134. * Update the current camera state depending on the inputs that have been used this frame.
  38135. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38136. */
  38137. checkInputs(): void;
  38138. /**
  38139. * Gets the class name of the current input.
  38140. * @returns the class name
  38141. */
  38142. getClassName(): string;
  38143. /**
  38144. * Get the friendly name associated with the input class.
  38145. * @returns the input friendly name
  38146. */
  38147. getSimpleName(): string;
  38148. /**
  38149. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38150. * allow modification of the heightOffset value.
  38151. */
  38152. private _modifierHeightOffset;
  38153. /**
  38154. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38155. * allow modification of the rotationOffset value.
  38156. */
  38157. private _modifierRotationOffset;
  38158. /**
  38159. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38160. * allow modification of the radius value.
  38161. */
  38162. private _modifierRadius;
  38163. }
  38164. }
  38165. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38166. import { Nullable } from "babylonjs/types";
  38167. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38168. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38169. import { Observable } from "babylonjs/Misc/observable";
  38170. module "babylonjs/Cameras/freeCameraInputsManager" {
  38171. interface FreeCameraInputsManager {
  38172. /**
  38173. * @hidden
  38174. */
  38175. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38176. /**
  38177. * Add orientation input support to the input manager.
  38178. * @returns the current input manager
  38179. */
  38180. addDeviceOrientation(): FreeCameraInputsManager;
  38181. }
  38182. }
  38183. /**
  38184. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38185. * Screen rotation is taken into account.
  38186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38187. */
  38188. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38189. private _camera;
  38190. private _screenOrientationAngle;
  38191. private _constantTranform;
  38192. private _screenQuaternion;
  38193. private _alpha;
  38194. private _beta;
  38195. private _gamma;
  38196. /**
  38197. * @hidden
  38198. */
  38199. _onDeviceOrientationChangedObservable: Observable<void>;
  38200. /**
  38201. * Instantiates a new input
  38202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38203. */
  38204. constructor();
  38205. /**
  38206. * Define the camera controlled by the input.
  38207. */
  38208. camera: FreeCamera;
  38209. /**
  38210. * Attach the input controls to a specific dom element to get the input from.
  38211. * @param element Defines the element the controls should be listened from
  38212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38213. */
  38214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38215. private _orientationChanged;
  38216. private _deviceOrientation;
  38217. /**
  38218. * Detach the current controls from the specified dom element.
  38219. * @param element Defines the element to stop listening the inputs from
  38220. */
  38221. detachControl(element: Nullable<HTMLElement>): void;
  38222. /**
  38223. * Update the current camera state depending on the inputs that have been used this frame.
  38224. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38225. */
  38226. checkInputs(): void;
  38227. /**
  38228. * Gets the class name of the current intput.
  38229. * @returns the class name
  38230. */
  38231. getClassName(): string;
  38232. /**
  38233. * Get the friendly name associated with the input class.
  38234. * @returns the input friendly name
  38235. */
  38236. getSimpleName(): string;
  38237. }
  38238. }
  38239. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38240. import { Nullable } from "babylonjs/types";
  38241. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38242. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38243. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38244. /**
  38245. * Manage the gamepad inputs to control a free camera.
  38246. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38247. */
  38248. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38249. /**
  38250. * Define the camera the input is attached to.
  38251. */
  38252. camera: FreeCamera;
  38253. /**
  38254. * Define the Gamepad controlling the input
  38255. */
  38256. gamepad: Nullable<Gamepad>;
  38257. /**
  38258. * Defines the gamepad rotation sensiblity.
  38259. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38260. */
  38261. gamepadAngularSensibility: number;
  38262. /**
  38263. * Defines the gamepad move sensiblity.
  38264. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38265. */
  38266. gamepadMoveSensibility: number;
  38267. private _onGamepadConnectedObserver;
  38268. private _onGamepadDisconnectedObserver;
  38269. private _cameraTransform;
  38270. private _deltaTransform;
  38271. private _vector3;
  38272. private _vector2;
  38273. /**
  38274. * Attach the input controls to a specific dom element to get the input from.
  38275. * @param element Defines the element the controls should be listened from
  38276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38277. */
  38278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38279. /**
  38280. * Detach the current controls from the specified dom element.
  38281. * @param element Defines the element to stop listening the inputs from
  38282. */
  38283. detachControl(element: Nullable<HTMLElement>): void;
  38284. /**
  38285. * Update the current camera state depending on the inputs that have been used this frame.
  38286. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38287. */
  38288. checkInputs(): void;
  38289. /**
  38290. * Gets the class name of the current intput.
  38291. * @returns the class name
  38292. */
  38293. getClassName(): string;
  38294. /**
  38295. * Get the friendly name associated with the input class.
  38296. * @returns the input friendly name
  38297. */
  38298. getSimpleName(): string;
  38299. }
  38300. }
  38301. declare module "babylonjs/Misc/virtualJoystick" {
  38302. import { Nullable } from "babylonjs/types";
  38303. import { Vector3 } from "babylonjs/Maths/math";
  38304. /**
  38305. * Defines the potential axis of a Joystick
  38306. */
  38307. export enum JoystickAxis {
  38308. /** X axis */
  38309. X = 0,
  38310. /** Y axis */
  38311. Y = 1,
  38312. /** Z axis */
  38313. Z = 2
  38314. }
  38315. /**
  38316. * Class used to define virtual joystick (used in touch mode)
  38317. */
  38318. export class VirtualJoystick {
  38319. /**
  38320. * Gets or sets a boolean indicating that left and right values must be inverted
  38321. */
  38322. reverseLeftRight: boolean;
  38323. /**
  38324. * Gets or sets a boolean indicating that up and down values must be inverted
  38325. */
  38326. reverseUpDown: boolean;
  38327. /**
  38328. * Gets the offset value for the position (ie. the change of the position value)
  38329. */
  38330. deltaPosition: Vector3;
  38331. /**
  38332. * Gets a boolean indicating if the virtual joystick was pressed
  38333. */
  38334. pressed: boolean;
  38335. /**
  38336. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38337. */
  38338. static Canvas: Nullable<HTMLCanvasElement>;
  38339. private static _globalJoystickIndex;
  38340. private static vjCanvasContext;
  38341. private static vjCanvasWidth;
  38342. private static vjCanvasHeight;
  38343. private static halfWidth;
  38344. private _action;
  38345. private _axisTargetedByLeftAndRight;
  38346. private _axisTargetedByUpAndDown;
  38347. private _joystickSensibility;
  38348. private _inversedSensibility;
  38349. private _joystickPointerID;
  38350. private _joystickColor;
  38351. private _joystickPointerPos;
  38352. private _joystickPreviousPointerPos;
  38353. private _joystickPointerStartPos;
  38354. private _deltaJoystickVector;
  38355. private _leftJoystick;
  38356. private _touches;
  38357. private _onPointerDownHandlerRef;
  38358. private _onPointerMoveHandlerRef;
  38359. private _onPointerUpHandlerRef;
  38360. private _onResize;
  38361. /**
  38362. * Creates a new virtual joystick
  38363. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38364. */
  38365. constructor(leftJoystick?: boolean);
  38366. /**
  38367. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38368. * @param newJoystickSensibility defines the new sensibility
  38369. */
  38370. setJoystickSensibility(newJoystickSensibility: number): void;
  38371. private _onPointerDown;
  38372. private _onPointerMove;
  38373. private _onPointerUp;
  38374. /**
  38375. * Change the color of the virtual joystick
  38376. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38377. */
  38378. setJoystickColor(newColor: string): void;
  38379. /**
  38380. * Defines a callback to call when the joystick is touched
  38381. * @param action defines the callback
  38382. */
  38383. setActionOnTouch(action: () => any): void;
  38384. /**
  38385. * Defines which axis you'd like to control for left & right
  38386. * @param axis defines the axis to use
  38387. */
  38388. setAxisForLeftRight(axis: JoystickAxis): void;
  38389. /**
  38390. * Defines which axis you'd like to control for up & down
  38391. * @param axis defines the axis to use
  38392. */
  38393. setAxisForUpDown(axis: JoystickAxis): void;
  38394. private _drawVirtualJoystick;
  38395. /**
  38396. * Release internal HTML canvas
  38397. */
  38398. releaseCanvas(): void;
  38399. }
  38400. }
  38401. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38402. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38403. import { Nullable } from "babylonjs/types";
  38404. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38405. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38406. module "babylonjs/Cameras/freeCameraInputsManager" {
  38407. interface FreeCameraInputsManager {
  38408. /**
  38409. * Add virtual joystick input support to the input manager.
  38410. * @returns the current input manager
  38411. */
  38412. addVirtualJoystick(): FreeCameraInputsManager;
  38413. }
  38414. }
  38415. /**
  38416. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38417. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38418. */
  38419. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38420. /**
  38421. * Defines the camera the input is attached to.
  38422. */
  38423. camera: FreeCamera;
  38424. private _leftjoystick;
  38425. private _rightjoystick;
  38426. /**
  38427. * Gets the left stick of the virtual joystick.
  38428. * @returns The virtual Joystick
  38429. */
  38430. getLeftJoystick(): VirtualJoystick;
  38431. /**
  38432. * Gets the right stick of the virtual joystick.
  38433. * @returns The virtual Joystick
  38434. */
  38435. getRightJoystick(): VirtualJoystick;
  38436. /**
  38437. * Update the current camera state depending on the inputs that have been used this frame.
  38438. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38439. */
  38440. checkInputs(): void;
  38441. /**
  38442. * Attach the input controls to a specific dom element to get the input from.
  38443. * @param element Defines the element the controls should be listened from
  38444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38445. */
  38446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38447. /**
  38448. * Detach the current controls from the specified dom element.
  38449. * @param element Defines the element to stop listening the inputs from
  38450. */
  38451. detachControl(element: Nullable<HTMLElement>): void;
  38452. /**
  38453. * Gets the class name of the current intput.
  38454. * @returns the class name
  38455. */
  38456. getClassName(): string;
  38457. /**
  38458. * Get the friendly name associated with the input class.
  38459. * @returns the input friendly name
  38460. */
  38461. getSimpleName(): string;
  38462. }
  38463. }
  38464. declare module "babylonjs/Cameras/Inputs/index" {
  38465. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38466. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38467. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38468. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38469. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38470. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38471. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38472. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38473. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38474. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38475. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38476. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38477. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38478. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38479. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38480. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38481. }
  38482. declare module "babylonjs/Cameras/touchCamera" {
  38483. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38484. import { Scene } from "babylonjs/scene";
  38485. import { Vector3 } from "babylonjs/Maths/math";
  38486. /**
  38487. * This represents a FPS type of camera controlled by touch.
  38488. * This is like a universal camera minus the Gamepad controls.
  38489. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38490. */
  38491. export class TouchCamera extends FreeCamera {
  38492. /**
  38493. * Defines the touch sensibility for rotation.
  38494. * The higher the faster.
  38495. */
  38496. touchAngularSensibility: number;
  38497. /**
  38498. * Defines the touch sensibility for move.
  38499. * The higher the faster.
  38500. */
  38501. touchMoveSensibility: number;
  38502. /**
  38503. * Instantiates a new touch camera.
  38504. * This represents a FPS type of camera controlled by touch.
  38505. * This is like a universal camera minus the Gamepad controls.
  38506. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38507. * @param name Define the name of the camera in the scene
  38508. * @param position Define the start position of the camera in the scene
  38509. * @param scene Define the scene the camera belongs to
  38510. */
  38511. constructor(name: string, position: Vector3, scene: Scene);
  38512. /**
  38513. * Gets the current object class name.
  38514. * @return the class name
  38515. */
  38516. getClassName(): string;
  38517. /** @hidden */
  38518. _setupInputs(): void;
  38519. }
  38520. }
  38521. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38522. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38523. import { Scene } from "babylonjs/scene";
  38524. import { Vector3, Axis } from "babylonjs/Maths/math";
  38525. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38526. /**
  38527. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38528. * being tilted forward or back and left or right.
  38529. */
  38530. export class DeviceOrientationCamera extends FreeCamera {
  38531. private _initialQuaternion;
  38532. private _quaternionCache;
  38533. private _tmpDragQuaternion;
  38534. /**
  38535. * Creates a new device orientation camera
  38536. * @param name The name of the camera
  38537. * @param position The start position camera
  38538. * @param scene The scene the camera belongs to
  38539. */
  38540. constructor(name: string, position: Vector3, scene: Scene);
  38541. /**
  38542. * @hidden
  38543. * Disabled pointer input on first orientation sensor update (Default: true)
  38544. */
  38545. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38546. private _dragFactor;
  38547. /**
  38548. * Enabled turning on the y axis when the orientation sensor is active
  38549. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38550. */
  38551. enableHorizontalDragging(dragFactor?: number): void;
  38552. /**
  38553. * Gets the current instance class name ("DeviceOrientationCamera").
  38554. * This helps avoiding instanceof at run time.
  38555. * @returns the class name
  38556. */
  38557. getClassName(): string;
  38558. /**
  38559. * @hidden
  38560. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38561. */
  38562. _checkInputs(): void;
  38563. /**
  38564. * Reset the camera to its default orientation on the specified axis only.
  38565. * @param axis The axis to reset
  38566. */
  38567. resetToCurrentRotation(axis?: Axis): void;
  38568. }
  38569. }
  38570. declare module "babylonjs/Cameras/universalCamera" {
  38571. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38572. import { Scene } from "babylonjs/scene";
  38573. import { Vector3 } from "babylonjs/Maths/math";
  38574. /**
  38575. * 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,
  38576. * which still works and will still be found in many Playgrounds.
  38577. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38578. */
  38579. export class UniversalCamera extends TouchCamera {
  38580. /**
  38581. * Defines the gamepad rotation sensiblity.
  38582. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38583. */
  38584. gamepadAngularSensibility: number;
  38585. /**
  38586. * Defines the gamepad move sensiblity.
  38587. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38588. */
  38589. gamepadMoveSensibility: number;
  38590. /**
  38591. * 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,
  38592. * which still works and will still be found in many Playgrounds.
  38593. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38594. * @param name Define the name of the camera in the scene
  38595. * @param position Define the start position of the camera in the scene
  38596. * @param scene Define the scene the camera belongs to
  38597. */
  38598. constructor(name: string, position: Vector3, scene: Scene);
  38599. /**
  38600. * Gets the current object class name.
  38601. * @return the class name
  38602. */
  38603. getClassName(): string;
  38604. }
  38605. }
  38606. declare module "babylonjs/Cameras/gamepadCamera" {
  38607. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38608. import { Scene } from "babylonjs/scene";
  38609. import { Vector3 } from "babylonjs/Maths/math";
  38610. /**
  38611. * This represents a FPS type of camera. This is only here for back compat purpose.
  38612. * Please use the UniversalCamera instead as both are identical.
  38613. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38614. */
  38615. export class GamepadCamera extends UniversalCamera {
  38616. /**
  38617. * Instantiates a new Gamepad Camera
  38618. * This represents a FPS type of camera. This is only here for back compat purpose.
  38619. * Please use the UniversalCamera instead as both are identical.
  38620. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38621. * @param name Define the name of the camera in the scene
  38622. * @param position Define the start position of the camera in the scene
  38623. * @param scene Define the scene the camera belongs to
  38624. */
  38625. constructor(name: string, position: Vector3, scene: Scene);
  38626. /**
  38627. * Gets the current object class name.
  38628. * @return the class name
  38629. */
  38630. getClassName(): string;
  38631. }
  38632. }
  38633. declare module "babylonjs/Shaders/pass.fragment" {
  38634. /** @hidden */
  38635. export var passPixelShader: {
  38636. name: string;
  38637. shader: string;
  38638. };
  38639. }
  38640. declare module "babylonjs/Shaders/passCube.fragment" {
  38641. /** @hidden */
  38642. export var passCubePixelShader: {
  38643. name: string;
  38644. shader: string;
  38645. };
  38646. }
  38647. declare module "babylonjs/PostProcesses/passPostProcess" {
  38648. import { Nullable } from "babylonjs/types";
  38649. import { Camera } from "babylonjs/Cameras/camera";
  38650. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38651. import { Engine } from "babylonjs/Engines/engine";
  38652. import "babylonjs/Shaders/pass.fragment";
  38653. import "babylonjs/Shaders/passCube.fragment";
  38654. /**
  38655. * PassPostProcess which produces an output the same as it's input
  38656. */
  38657. export class PassPostProcess extends PostProcess {
  38658. /**
  38659. * Creates the PassPostProcess
  38660. * @param name The name of the effect.
  38661. * @param options The required width/height ratio to downsize to before computing the render pass.
  38662. * @param camera The camera to apply the render pass to.
  38663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38664. * @param engine The engine which the post process will be applied. (default: current engine)
  38665. * @param reusable If the post process can be reused on the same frame. (default: false)
  38666. * @param textureType The type of texture to be used when performing the post processing.
  38667. * @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)
  38668. */
  38669. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38670. }
  38671. /**
  38672. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38673. */
  38674. export class PassCubePostProcess extends PostProcess {
  38675. private _face;
  38676. /**
  38677. * Gets or sets the cube face to display.
  38678. * * 0 is +X
  38679. * * 1 is -X
  38680. * * 2 is +Y
  38681. * * 3 is -Y
  38682. * * 4 is +Z
  38683. * * 5 is -Z
  38684. */
  38685. face: number;
  38686. /**
  38687. * Creates the PassCubePostProcess
  38688. * @param name The name of the effect.
  38689. * @param options The required width/height ratio to downsize to before computing the render pass.
  38690. * @param camera The camera to apply the render pass to.
  38691. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38692. * @param engine The engine which the post process will be applied. (default: current engine)
  38693. * @param reusable If the post process can be reused on the same frame. (default: false)
  38694. * @param textureType The type of texture to be used when performing the post processing.
  38695. * @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)
  38696. */
  38697. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38698. }
  38699. }
  38700. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38701. /** @hidden */
  38702. export var anaglyphPixelShader: {
  38703. name: string;
  38704. shader: string;
  38705. };
  38706. }
  38707. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38708. import { Engine } from "babylonjs/Engines/engine";
  38709. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38710. import { Camera } from "babylonjs/Cameras/camera";
  38711. import "babylonjs/Shaders/anaglyph.fragment";
  38712. /**
  38713. * Postprocess used to generate anaglyphic rendering
  38714. */
  38715. export class AnaglyphPostProcess extends PostProcess {
  38716. private _passedProcess;
  38717. /**
  38718. * Creates a new AnaglyphPostProcess
  38719. * @param name defines postprocess name
  38720. * @param options defines creation options or target ratio scale
  38721. * @param rigCameras defines cameras using this postprocess
  38722. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38723. * @param engine defines hosting engine
  38724. * @param reusable defines if the postprocess will be reused multiple times per frame
  38725. */
  38726. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38727. }
  38728. }
  38729. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38730. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38731. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38732. import { Scene } from "babylonjs/scene";
  38733. import { Vector3 } from "babylonjs/Maths/math";
  38734. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38735. /**
  38736. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38737. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38738. */
  38739. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38740. /**
  38741. * Creates a new AnaglyphArcRotateCamera
  38742. * @param name defines camera name
  38743. * @param alpha defines alpha angle (in radians)
  38744. * @param beta defines beta angle (in radians)
  38745. * @param radius defines radius
  38746. * @param target defines camera target
  38747. * @param interaxialDistance defines distance between each color axis
  38748. * @param scene defines the hosting scene
  38749. */
  38750. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38751. /**
  38752. * Gets camera class name
  38753. * @returns AnaglyphArcRotateCamera
  38754. */
  38755. getClassName(): string;
  38756. }
  38757. }
  38758. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38759. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38760. import { Scene } from "babylonjs/scene";
  38761. import { Vector3 } from "babylonjs/Maths/math";
  38762. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38763. /**
  38764. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38765. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38766. */
  38767. export class AnaglyphFreeCamera extends FreeCamera {
  38768. /**
  38769. * Creates a new AnaglyphFreeCamera
  38770. * @param name defines camera name
  38771. * @param position defines initial position
  38772. * @param interaxialDistance defines distance between each color axis
  38773. * @param scene defines the hosting scene
  38774. */
  38775. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38776. /**
  38777. * Gets camera class name
  38778. * @returns AnaglyphFreeCamera
  38779. */
  38780. getClassName(): string;
  38781. }
  38782. }
  38783. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38784. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38785. import { Scene } from "babylonjs/scene";
  38786. import { Vector3 } from "babylonjs/Maths/math";
  38787. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38788. /**
  38789. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38790. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38791. */
  38792. export class AnaglyphGamepadCamera extends GamepadCamera {
  38793. /**
  38794. * Creates a new AnaglyphGamepadCamera
  38795. * @param name defines camera name
  38796. * @param position defines initial position
  38797. * @param interaxialDistance defines distance between each color axis
  38798. * @param scene defines the hosting scene
  38799. */
  38800. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38801. /**
  38802. * Gets camera class name
  38803. * @returns AnaglyphGamepadCamera
  38804. */
  38805. getClassName(): string;
  38806. }
  38807. }
  38808. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38809. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38810. import { Scene } from "babylonjs/scene";
  38811. import { Vector3 } from "babylonjs/Maths/math";
  38812. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38813. /**
  38814. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38815. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38816. */
  38817. export class AnaglyphUniversalCamera extends UniversalCamera {
  38818. /**
  38819. * Creates a new AnaglyphUniversalCamera
  38820. * @param name defines camera name
  38821. * @param position defines initial position
  38822. * @param interaxialDistance defines distance between each color axis
  38823. * @param scene defines the hosting scene
  38824. */
  38825. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38826. /**
  38827. * Gets camera class name
  38828. * @returns AnaglyphUniversalCamera
  38829. */
  38830. getClassName(): string;
  38831. }
  38832. }
  38833. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38834. /** @hidden */
  38835. export var stereoscopicInterlacePixelShader: {
  38836. name: string;
  38837. shader: string;
  38838. };
  38839. }
  38840. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38841. import { Camera } from "babylonjs/Cameras/camera";
  38842. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38843. import { Engine } from "babylonjs/Engines/engine";
  38844. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38845. /**
  38846. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38847. */
  38848. export class StereoscopicInterlacePostProcess extends PostProcess {
  38849. private _stepSize;
  38850. private _passedProcess;
  38851. /**
  38852. * Initializes a StereoscopicInterlacePostProcess
  38853. * @param name The name of the effect.
  38854. * @param rigCameras The rig cameras to be appled to the post process
  38855. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38856. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38857. * @param engine The engine which the post process will be applied. (default: current engine)
  38858. * @param reusable If the post process can be reused on the same frame. (default: false)
  38859. */
  38860. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38861. }
  38862. }
  38863. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38864. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38865. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38866. import { Scene } from "babylonjs/scene";
  38867. import { Vector3 } from "babylonjs/Maths/math";
  38868. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38869. /**
  38870. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38871. * @see http://doc.babylonjs.com/features/cameras
  38872. */
  38873. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38874. /**
  38875. * Creates a new StereoscopicArcRotateCamera
  38876. * @param name defines camera name
  38877. * @param alpha defines alpha angle (in radians)
  38878. * @param beta defines beta angle (in radians)
  38879. * @param radius defines radius
  38880. * @param target defines camera target
  38881. * @param interaxialDistance defines distance between each color axis
  38882. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38883. * @param scene defines the hosting scene
  38884. */
  38885. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38886. /**
  38887. * Gets camera class name
  38888. * @returns StereoscopicArcRotateCamera
  38889. */
  38890. getClassName(): string;
  38891. }
  38892. }
  38893. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38894. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38895. import { Scene } from "babylonjs/scene";
  38896. import { Vector3 } from "babylonjs/Maths/math";
  38897. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38898. /**
  38899. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38900. * @see http://doc.babylonjs.com/features/cameras
  38901. */
  38902. export class StereoscopicFreeCamera extends FreeCamera {
  38903. /**
  38904. * Creates a new StereoscopicFreeCamera
  38905. * @param name defines camera name
  38906. * @param position defines initial position
  38907. * @param interaxialDistance defines distance between each color axis
  38908. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38909. * @param scene defines the hosting scene
  38910. */
  38911. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38912. /**
  38913. * Gets camera class name
  38914. * @returns StereoscopicFreeCamera
  38915. */
  38916. getClassName(): string;
  38917. }
  38918. }
  38919. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38920. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38921. import { Scene } from "babylonjs/scene";
  38922. import { Vector3 } from "babylonjs/Maths/math";
  38923. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38924. /**
  38925. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38926. * @see http://doc.babylonjs.com/features/cameras
  38927. */
  38928. export class StereoscopicGamepadCamera extends GamepadCamera {
  38929. /**
  38930. * Creates a new StereoscopicGamepadCamera
  38931. * @param name defines camera name
  38932. * @param position defines initial position
  38933. * @param interaxialDistance defines distance between each color axis
  38934. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38935. * @param scene defines the hosting scene
  38936. */
  38937. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38938. /**
  38939. * Gets camera class name
  38940. * @returns StereoscopicGamepadCamera
  38941. */
  38942. getClassName(): string;
  38943. }
  38944. }
  38945. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38946. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38947. import { Scene } from "babylonjs/scene";
  38948. import { Vector3 } from "babylonjs/Maths/math";
  38949. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38950. /**
  38951. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38952. * @see http://doc.babylonjs.com/features/cameras
  38953. */
  38954. export class StereoscopicUniversalCamera extends UniversalCamera {
  38955. /**
  38956. * Creates a new StereoscopicUniversalCamera
  38957. * @param name defines camera name
  38958. * @param position defines initial position
  38959. * @param interaxialDistance defines distance between each color axis
  38960. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38961. * @param scene defines the hosting scene
  38962. */
  38963. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38964. /**
  38965. * Gets camera class name
  38966. * @returns StereoscopicUniversalCamera
  38967. */
  38968. getClassName(): string;
  38969. }
  38970. }
  38971. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38972. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38973. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38974. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38975. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38976. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38977. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38978. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38979. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38980. }
  38981. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38982. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38983. import { Scene } from "babylonjs/scene";
  38984. import { Vector3 } from "babylonjs/Maths/math";
  38985. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38986. /**
  38987. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38988. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38989. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38990. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38991. */
  38992. export class VirtualJoysticksCamera extends FreeCamera {
  38993. /**
  38994. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38995. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38996. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38997. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38998. * @param name Define the name of the camera in the scene
  38999. * @param position Define the start position of the camera in the scene
  39000. * @param scene Define the scene the camera belongs to
  39001. */
  39002. constructor(name: string, position: Vector3, scene: Scene);
  39003. /**
  39004. * Gets the current object class name.
  39005. * @return the class name
  39006. */
  39007. getClassName(): string;
  39008. }
  39009. }
  39010. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39011. import { Matrix } from "babylonjs/Maths/math";
  39012. /**
  39013. * This represents all the required metrics to create a VR camera.
  39014. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39015. */
  39016. export class VRCameraMetrics {
  39017. /**
  39018. * Define the horizontal resolution off the screen.
  39019. */
  39020. hResolution: number;
  39021. /**
  39022. * Define the vertical resolution off the screen.
  39023. */
  39024. vResolution: number;
  39025. /**
  39026. * Define the horizontal screen size.
  39027. */
  39028. hScreenSize: number;
  39029. /**
  39030. * Define the vertical screen size.
  39031. */
  39032. vScreenSize: number;
  39033. /**
  39034. * Define the vertical screen center position.
  39035. */
  39036. vScreenCenter: number;
  39037. /**
  39038. * Define the distance of the eyes to the screen.
  39039. */
  39040. eyeToScreenDistance: number;
  39041. /**
  39042. * Define the distance between both lenses
  39043. */
  39044. lensSeparationDistance: number;
  39045. /**
  39046. * Define the distance between both viewer's eyes.
  39047. */
  39048. interpupillaryDistance: number;
  39049. /**
  39050. * Define the distortion factor of the VR postprocess.
  39051. * Please, touch with care.
  39052. */
  39053. distortionK: number[];
  39054. /**
  39055. * Define the chromatic aberration correction factors for the VR post process.
  39056. */
  39057. chromaAbCorrection: number[];
  39058. /**
  39059. * Define the scale factor of the post process.
  39060. * The smaller the better but the slower.
  39061. */
  39062. postProcessScaleFactor: number;
  39063. /**
  39064. * Define an offset for the lens center.
  39065. */
  39066. lensCenterOffset: number;
  39067. /**
  39068. * Define if the current vr camera should compensate the distortion of the lense or not.
  39069. */
  39070. compensateDistortion: boolean;
  39071. /**
  39072. * Defines if multiview should be enabled when rendering (Default: false)
  39073. */
  39074. multiviewEnabled: boolean;
  39075. /**
  39076. * Gets the rendering aspect ratio based on the provided resolutions.
  39077. */
  39078. readonly aspectRatio: number;
  39079. /**
  39080. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39081. */
  39082. readonly aspectRatioFov: number;
  39083. /**
  39084. * @hidden
  39085. */
  39086. readonly leftHMatrix: Matrix;
  39087. /**
  39088. * @hidden
  39089. */
  39090. readonly rightHMatrix: Matrix;
  39091. /**
  39092. * @hidden
  39093. */
  39094. readonly leftPreViewMatrix: Matrix;
  39095. /**
  39096. * @hidden
  39097. */
  39098. readonly rightPreViewMatrix: Matrix;
  39099. /**
  39100. * Get the default VRMetrics based on the most generic setup.
  39101. * @returns the default vr metrics
  39102. */
  39103. static GetDefault(): VRCameraMetrics;
  39104. }
  39105. }
  39106. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39107. /** @hidden */
  39108. export var vrDistortionCorrectionPixelShader: {
  39109. name: string;
  39110. shader: string;
  39111. };
  39112. }
  39113. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39114. import { Camera } from "babylonjs/Cameras/camera";
  39115. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39116. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39117. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39118. /**
  39119. * VRDistortionCorrectionPostProcess used for mobile VR
  39120. */
  39121. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39122. private _isRightEye;
  39123. private _distortionFactors;
  39124. private _postProcessScaleFactor;
  39125. private _lensCenterOffset;
  39126. private _scaleIn;
  39127. private _scaleFactor;
  39128. private _lensCenter;
  39129. /**
  39130. * Initializes the VRDistortionCorrectionPostProcess
  39131. * @param name The name of the effect.
  39132. * @param camera The camera to apply the render pass to.
  39133. * @param isRightEye If this is for the right eye distortion
  39134. * @param vrMetrics All the required metrics for the VR camera
  39135. */
  39136. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39137. }
  39138. }
  39139. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39140. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39141. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39142. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39143. import { Scene } from "babylonjs/scene";
  39144. import { Vector3 } from "babylonjs/Maths/math";
  39145. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39146. import "babylonjs/Cameras/RigModes/vrRigMode";
  39147. /**
  39148. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39149. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39150. */
  39151. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39152. /**
  39153. * Creates a new VRDeviceOrientationArcRotateCamera
  39154. * @param name defines camera name
  39155. * @param alpha defines the camera rotation along the logitudinal axis
  39156. * @param beta defines the camera rotation along the latitudinal axis
  39157. * @param radius defines the camera distance from its target
  39158. * @param target defines the camera target
  39159. * @param scene defines the scene the camera belongs to
  39160. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39161. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39162. */
  39163. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39164. /**
  39165. * Gets camera class name
  39166. * @returns VRDeviceOrientationArcRotateCamera
  39167. */
  39168. getClassName(): string;
  39169. }
  39170. }
  39171. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39172. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39173. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39174. import { Scene } from "babylonjs/scene";
  39175. import { Vector3 } from "babylonjs/Maths/math";
  39176. import "babylonjs/Cameras/RigModes/vrRigMode";
  39177. /**
  39178. * Camera used to simulate VR rendering (based on FreeCamera)
  39179. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39180. */
  39181. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39182. /**
  39183. * Creates a new VRDeviceOrientationFreeCamera
  39184. * @param name defines camera name
  39185. * @param position defines the start position of the camera
  39186. * @param scene defines the scene the camera belongs to
  39187. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39188. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39189. */
  39190. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39191. /**
  39192. * Gets camera class name
  39193. * @returns VRDeviceOrientationFreeCamera
  39194. */
  39195. getClassName(): string;
  39196. }
  39197. }
  39198. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39199. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39200. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39201. import { Scene } from "babylonjs/scene";
  39202. import { Vector3 } from "babylonjs/Maths/math";
  39203. /**
  39204. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39205. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39206. */
  39207. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39208. /**
  39209. * Creates a new VRDeviceOrientationGamepadCamera
  39210. * @param name defines camera name
  39211. * @param position defines the start position of the camera
  39212. * @param scene defines the scene the camera belongs to
  39213. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39214. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39215. */
  39216. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39217. /**
  39218. * Gets camera class name
  39219. * @returns VRDeviceOrientationGamepadCamera
  39220. */
  39221. getClassName(): string;
  39222. }
  39223. }
  39224. declare module "babylonjs/Gamepads/xboxGamepad" {
  39225. import { Observable } from "babylonjs/Misc/observable";
  39226. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39227. /**
  39228. * Defines supported buttons for XBox360 compatible gamepads
  39229. */
  39230. export enum Xbox360Button {
  39231. /** A */
  39232. A = 0,
  39233. /** B */
  39234. B = 1,
  39235. /** X */
  39236. X = 2,
  39237. /** Y */
  39238. Y = 3,
  39239. /** Start */
  39240. Start = 4,
  39241. /** Back */
  39242. Back = 5,
  39243. /** Left button */
  39244. LB = 6,
  39245. /** Right button */
  39246. RB = 7,
  39247. /** Left stick */
  39248. LeftStick = 8,
  39249. /** Right stick */
  39250. RightStick = 9
  39251. }
  39252. /** Defines values for XBox360 DPad */
  39253. export enum Xbox360Dpad {
  39254. /** Up */
  39255. Up = 0,
  39256. /** Down */
  39257. Down = 1,
  39258. /** Left */
  39259. Left = 2,
  39260. /** Right */
  39261. Right = 3
  39262. }
  39263. /**
  39264. * Defines a XBox360 gamepad
  39265. */
  39266. export class Xbox360Pad extends Gamepad {
  39267. private _leftTrigger;
  39268. private _rightTrigger;
  39269. private _onlefttriggerchanged;
  39270. private _onrighttriggerchanged;
  39271. private _onbuttondown;
  39272. private _onbuttonup;
  39273. private _ondpaddown;
  39274. private _ondpadup;
  39275. /** Observable raised when a button is pressed */
  39276. onButtonDownObservable: Observable<Xbox360Button>;
  39277. /** Observable raised when a button is released */
  39278. onButtonUpObservable: Observable<Xbox360Button>;
  39279. /** Observable raised when a pad is pressed */
  39280. onPadDownObservable: Observable<Xbox360Dpad>;
  39281. /** Observable raised when a pad is released */
  39282. onPadUpObservable: Observable<Xbox360Dpad>;
  39283. private _buttonA;
  39284. private _buttonB;
  39285. private _buttonX;
  39286. private _buttonY;
  39287. private _buttonBack;
  39288. private _buttonStart;
  39289. private _buttonLB;
  39290. private _buttonRB;
  39291. private _buttonLeftStick;
  39292. private _buttonRightStick;
  39293. private _dPadUp;
  39294. private _dPadDown;
  39295. private _dPadLeft;
  39296. private _dPadRight;
  39297. private _isXboxOnePad;
  39298. /**
  39299. * Creates a new XBox360 gamepad object
  39300. * @param id defines the id of this gamepad
  39301. * @param index defines its index
  39302. * @param gamepad defines the internal HTML gamepad object
  39303. * @param xboxOne defines if it is a XBox One gamepad
  39304. */
  39305. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39306. /**
  39307. * Defines the callback to call when left trigger is pressed
  39308. * @param callback defines the callback to use
  39309. */
  39310. onlefttriggerchanged(callback: (value: number) => void): void;
  39311. /**
  39312. * Defines the callback to call when right trigger is pressed
  39313. * @param callback defines the callback to use
  39314. */
  39315. onrighttriggerchanged(callback: (value: number) => void): void;
  39316. /**
  39317. * Gets the left trigger value
  39318. */
  39319. /**
  39320. * Sets the left trigger value
  39321. */
  39322. leftTrigger: number;
  39323. /**
  39324. * Gets the right trigger value
  39325. */
  39326. /**
  39327. * Sets the right trigger value
  39328. */
  39329. rightTrigger: number;
  39330. /**
  39331. * Defines the callback to call when a button is pressed
  39332. * @param callback defines the callback to use
  39333. */
  39334. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39335. /**
  39336. * Defines the callback to call when a button is released
  39337. * @param callback defines the callback to use
  39338. */
  39339. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39340. /**
  39341. * Defines the callback to call when a pad is pressed
  39342. * @param callback defines the callback to use
  39343. */
  39344. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39345. /**
  39346. * Defines the callback to call when a pad is released
  39347. * @param callback defines the callback to use
  39348. */
  39349. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39350. private _setButtonValue;
  39351. private _setDPadValue;
  39352. /**
  39353. * Gets the value of the `A` button
  39354. */
  39355. /**
  39356. * Sets the value of the `A` button
  39357. */
  39358. buttonA: number;
  39359. /**
  39360. * Gets the value of the `B` button
  39361. */
  39362. /**
  39363. * Sets the value of the `B` button
  39364. */
  39365. buttonB: number;
  39366. /**
  39367. * Gets the value of the `X` button
  39368. */
  39369. /**
  39370. * Sets the value of the `X` button
  39371. */
  39372. buttonX: number;
  39373. /**
  39374. * Gets the value of the `Y` button
  39375. */
  39376. /**
  39377. * Sets the value of the `Y` button
  39378. */
  39379. buttonY: number;
  39380. /**
  39381. * Gets the value of the `Start` button
  39382. */
  39383. /**
  39384. * Sets the value of the `Start` button
  39385. */
  39386. buttonStart: number;
  39387. /**
  39388. * Gets the value of the `Back` button
  39389. */
  39390. /**
  39391. * Sets the value of the `Back` button
  39392. */
  39393. buttonBack: number;
  39394. /**
  39395. * Gets the value of the `Left` button
  39396. */
  39397. /**
  39398. * Sets the value of the `Left` button
  39399. */
  39400. buttonLB: number;
  39401. /**
  39402. * Gets the value of the `Right` button
  39403. */
  39404. /**
  39405. * Sets the value of the `Right` button
  39406. */
  39407. buttonRB: number;
  39408. /**
  39409. * Gets the value of the Left joystick
  39410. */
  39411. /**
  39412. * Sets the value of the Left joystick
  39413. */
  39414. buttonLeftStick: number;
  39415. /**
  39416. * Gets the value of the Right joystick
  39417. */
  39418. /**
  39419. * Sets the value of the Right joystick
  39420. */
  39421. buttonRightStick: number;
  39422. /**
  39423. * Gets the value of D-pad up
  39424. */
  39425. /**
  39426. * Sets the value of D-pad up
  39427. */
  39428. dPadUp: number;
  39429. /**
  39430. * Gets the value of D-pad down
  39431. */
  39432. /**
  39433. * Sets the value of D-pad down
  39434. */
  39435. dPadDown: number;
  39436. /**
  39437. * Gets the value of D-pad left
  39438. */
  39439. /**
  39440. * Sets the value of D-pad left
  39441. */
  39442. dPadLeft: number;
  39443. /**
  39444. * Gets the value of D-pad right
  39445. */
  39446. /**
  39447. * Sets the value of D-pad right
  39448. */
  39449. dPadRight: number;
  39450. /**
  39451. * Force the gamepad to synchronize with device values
  39452. */
  39453. update(): void;
  39454. /**
  39455. * Disposes the gamepad
  39456. */
  39457. dispose(): void;
  39458. }
  39459. }
  39460. declare module "babylonjs/Materials/pushMaterial" {
  39461. import { Nullable } from "babylonjs/types";
  39462. import { Scene } from "babylonjs/scene";
  39463. import { Matrix } from "babylonjs/Maths/math";
  39464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39465. import { Mesh } from "babylonjs/Meshes/mesh";
  39466. import { Material } from "babylonjs/Materials/material";
  39467. import { Effect } from "babylonjs/Materials/effect";
  39468. /**
  39469. * Base class of materials working in push mode in babylon JS
  39470. * @hidden
  39471. */
  39472. export class PushMaterial extends Material {
  39473. protected _activeEffect: Effect;
  39474. protected _normalMatrix: Matrix;
  39475. /**
  39476. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39477. * This means that the material can keep using a previous shader while a new one is being compiled.
  39478. * This is mostly used when shader parallel compilation is supported (true by default)
  39479. */
  39480. allowShaderHotSwapping: boolean;
  39481. constructor(name: string, scene: Scene);
  39482. getEffect(): Effect;
  39483. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39484. /**
  39485. * Binds the given world matrix to the active effect
  39486. *
  39487. * @param world the matrix to bind
  39488. */
  39489. bindOnlyWorldMatrix(world: Matrix): void;
  39490. /**
  39491. * Binds the given normal matrix to the active effect
  39492. *
  39493. * @param normalMatrix the matrix to bind
  39494. */
  39495. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39496. bind(world: Matrix, mesh?: Mesh): void;
  39497. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39498. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39499. }
  39500. }
  39501. declare module "babylonjs/Materials/materialFlags" {
  39502. /**
  39503. * This groups all the flags used to control the materials channel.
  39504. */
  39505. export class MaterialFlags {
  39506. private static _DiffuseTextureEnabled;
  39507. /**
  39508. * Are diffuse textures enabled in the application.
  39509. */
  39510. static DiffuseTextureEnabled: boolean;
  39511. private static _AmbientTextureEnabled;
  39512. /**
  39513. * Are ambient textures enabled in the application.
  39514. */
  39515. static AmbientTextureEnabled: boolean;
  39516. private static _OpacityTextureEnabled;
  39517. /**
  39518. * Are opacity textures enabled in the application.
  39519. */
  39520. static OpacityTextureEnabled: boolean;
  39521. private static _ReflectionTextureEnabled;
  39522. /**
  39523. * Are reflection textures enabled in the application.
  39524. */
  39525. static ReflectionTextureEnabled: boolean;
  39526. private static _EmissiveTextureEnabled;
  39527. /**
  39528. * Are emissive textures enabled in the application.
  39529. */
  39530. static EmissiveTextureEnabled: boolean;
  39531. private static _SpecularTextureEnabled;
  39532. /**
  39533. * Are specular textures enabled in the application.
  39534. */
  39535. static SpecularTextureEnabled: boolean;
  39536. private static _BumpTextureEnabled;
  39537. /**
  39538. * Are bump textures enabled in the application.
  39539. */
  39540. static BumpTextureEnabled: boolean;
  39541. private static _LightmapTextureEnabled;
  39542. /**
  39543. * Are lightmap textures enabled in the application.
  39544. */
  39545. static LightmapTextureEnabled: boolean;
  39546. private static _RefractionTextureEnabled;
  39547. /**
  39548. * Are refraction textures enabled in the application.
  39549. */
  39550. static RefractionTextureEnabled: boolean;
  39551. private static _ColorGradingTextureEnabled;
  39552. /**
  39553. * Are color grading textures enabled in the application.
  39554. */
  39555. static ColorGradingTextureEnabled: boolean;
  39556. private static _FresnelEnabled;
  39557. /**
  39558. * Are fresnels enabled in the application.
  39559. */
  39560. static FresnelEnabled: boolean;
  39561. private static _ClearCoatTextureEnabled;
  39562. /**
  39563. * Are clear coat textures enabled in the application.
  39564. */
  39565. static ClearCoatTextureEnabled: boolean;
  39566. private static _ClearCoatBumpTextureEnabled;
  39567. /**
  39568. * Are clear coat bump textures enabled in the application.
  39569. */
  39570. static ClearCoatBumpTextureEnabled: boolean;
  39571. private static _ClearCoatTintTextureEnabled;
  39572. /**
  39573. * Are clear coat tint textures enabled in the application.
  39574. */
  39575. static ClearCoatTintTextureEnabled: boolean;
  39576. private static _SheenTextureEnabled;
  39577. /**
  39578. * Are sheen textures enabled in the application.
  39579. */
  39580. static SheenTextureEnabled: boolean;
  39581. private static _AnisotropicTextureEnabled;
  39582. /**
  39583. * Are anisotropic textures enabled in the application.
  39584. */
  39585. static AnisotropicTextureEnabled: boolean;
  39586. private static _ThicknessTextureEnabled;
  39587. /**
  39588. * Are thickness textures enabled in the application.
  39589. */
  39590. static ThicknessTextureEnabled: boolean;
  39591. }
  39592. }
  39593. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39594. /** @hidden */
  39595. export var defaultFragmentDeclaration: {
  39596. name: string;
  39597. shader: string;
  39598. };
  39599. }
  39600. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39601. /** @hidden */
  39602. export var defaultUboDeclaration: {
  39603. name: string;
  39604. shader: string;
  39605. };
  39606. }
  39607. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39608. /** @hidden */
  39609. export var lightFragmentDeclaration: {
  39610. name: string;
  39611. shader: string;
  39612. };
  39613. }
  39614. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39615. /** @hidden */
  39616. export var lightUboDeclaration: {
  39617. name: string;
  39618. shader: string;
  39619. };
  39620. }
  39621. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39622. /** @hidden */
  39623. export var lightsFragmentFunctions: {
  39624. name: string;
  39625. shader: string;
  39626. };
  39627. }
  39628. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39629. /** @hidden */
  39630. export var shadowsFragmentFunctions: {
  39631. name: string;
  39632. shader: string;
  39633. };
  39634. }
  39635. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39636. /** @hidden */
  39637. export var fresnelFunction: {
  39638. name: string;
  39639. shader: string;
  39640. };
  39641. }
  39642. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39643. /** @hidden */
  39644. export var reflectionFunction: {
  39645. name: string;
  39646. shader: string;
  39647. };
  39648. }
  39649. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39650. /** @hidden */
  39651. export var bumpFragmentFunctions: {
  39652. name: string;
  39653. shader: string;
  39654. };
  39655. }
  39656. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39657. /** @hidden */
  39658. export var logDepthDeclaration: {
  39659. name: string;
  39660. shader: string;
  39661. };
  39662. }
  39663. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39664. /** @hidden */
  39665. export var bumpFragment: {
  39666. name: string;
  39667. shader: string;
  39668. };
  39669. }
  39670. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39671. /** @hidden */
  39672. export var depthPrePass: {
  39673. name: string;
  39674. shader: string;
  39675. };
  39676. }
  39677. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39678. /** @hidden */
  39679. export var lightFragment: {
  39680. name: string;
  39681. shader: string;
  39682. };
  39683. }
  39684. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39685. /** @hidden */
  39686. export var logDepthFragment: {
  39687. name: string;
  39688. shader: string;
  39689. };
  39690. }
  39691. declare module "babylonjs/Shaders/default.fragment" {
  39692. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39693. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39694. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39695. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39696. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39697. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39698. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39699. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39700. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39701. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39702. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39703. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39704. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39705. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39706. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39707. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39708. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39709. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39710. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39711. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39712. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39713. /** @hidden */
  39714. export var defaultPixelShader: {
  39715. name: string;
  39716. shader: string;
  39717. };
  39718. }
  39719. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39720. /** @hidden */
  39721. export var defaultVertexDeclaration: {
  39722. name: string;
  39723. shader: string;
  39724. };
  39725. }
  39726. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39727. /** @hidden */
  39728. export var bumpVertexDeclaration: {
  39729. name: string;
  39730. shader: string;
  39731. };
  39732. }
  39733. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39734. /** @hidden */
  39735. export var bumpVertex: {
  39736. name: string;
  39737. shader: string;
  39738. };
  39739. }
  39740. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39741. /** @hidden */
  39742. export var fogVertex: {
  39743. name: string;
  39744. shader: string;
  39745. };
  39746. }
  39747. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39748. /** @hidden */
  39749. export var shadowsVertex: {
  39750. name: string;
  39751. shader: string;
  39752. };
  39753. }
  39754. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39755. /** @hidden */
  39756. export var pointCloudVertex: {
  39757. name: string;
  39758. shader: string;
  39759. };
  39760. }
  39761. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39762. /** @hidden */
  39763. export var logDepthVertex: {
  39764. name: string;
  39765. shader: string;
  39766. };
  39767. }
  39768. declare module "babylonjs/Shaders/default.vertex" {
  39769. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39770. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39771. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39772. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39773. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39774. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39775. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39776. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39777. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39778. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39779. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39780. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39781. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39782. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39783. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39784. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39785. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39786. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39787. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39788. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39789. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39790. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39791. /** @hidden */
  39792. export var defaultVertexShader: {
  39793. name: string;
  39794. shader: string;
  39795. };
  39796. }
  39797. declare module "babylonjs/Materials/standardMaterial" {
  39798. import { SmartArray } from "babylonjs/Misc/smartArray";
  39799. import { IAnimatable } from "babylonjs/Misc/tools";
  39800. import { Nullable } from "babylonjs/types";
  39801. import { Scene } from "babylonjs/scene";
  39802. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39803. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39805. import { Mesh } from "babylonjs/Meshes/mesh";
  39806. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39807. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39808. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39809. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39810. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39811. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39812. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39813. import "babylonjs/Shaders/default.fragment";
  39814. import "babylonjs/Shaders/default.vertex";
  39815. /** @hidden */
  39816. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39817. MAINUV1: boolean;
  39818. MAINUV2: boolean;
  39819. DIFFUSE: boolean;
  39820. DIFFUSEDIRECTUV: number;
  39821. AMBIENT: boolean;
  39822. AMBIENTDIRECTUV: number;
  39823. OPACITY: boolean;
  39824. OPACITYDIRECTUV: number;
  39825. OPACITYRGB: boolean;
  39826. REFLECTION: boolean;
  39827. EMISSIVE: boolean;
  39828. EMISSIVEDIRECTUV: number;
  39829. SPECULAR: boolean;
  39830. SPECULARDIRECTUV: number;
  39831. BUMP: boolean;
  39832. BUMPDIRECTUV: number;
  39833. PARALLAX: boolean;
  39834. PARALLAXOCCLUSION: boolean;
  39835. SPECULAROVERALPHA: boolean;
  39836. CLIPPLANE: boolean;
  39837. CLIPPLANE2: boolean;
  39838. CLIPPLANE3: boolean;
  39839. CLIPPLANE4: boolean;
  39840. ALPHATEST: boolean;
  39841. DEPTHPREPASS: boolean;
  39842. ALPHAFROMDIFFUSE: boolean;
  39843. POINTSIZE: boolean;
  39844. FOG: boolean;
  39845. SPECULARTERM: boolean;
  39846. DIFFUSEFRESNEL: boolean;
  39847. OPACITYFRESNEL: boolean;
  39848. REFLECTIONFRESNEL: boolean;
  39849. REFRACTIONFRESNEL: boolean;
  39850. EMISSIVEFRESNEL: boolean;
  39851. FRESNEL: boolean;
  39852. NORMAL: boolean;
  39853. UV1: boolean;
  39854. UV2: boolean;
  39855. VERTEXCOLOR: boolean;
  39856. VERTEXALPHA: boolean;
  39857. NUM_BONE_INFLUENCERS: number;
  39858. BonesPerMesh: number;
  39859. BONETEXTURE: boolean;
  39860. INSTANCES: boolean;
  39861. GLOSSINESS: boolean;
  39862. ROUGHNESS: boolean;
  39863. EMISSIVEASILLUMINATION: boolean;
  39864. LINKEMISSIVEWITHDIFFUSE: boolean;
  39865. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39866. LIGHTMAP: boolean;
  39867. LIGHTMAPDIRECTUV: number;
  39868. OBJECTSPACE_NORMALMAP: boolean;
  39869. USELIGHTMAPASSHADOWMAP: boolean;
  39870. REFLECTIONMAP_3D: boolean;
  39871. REFLECTIONMAP_SPHERICAL: boolean;
  39872. REFLECTIONMAP_PLANAR: boolean;
  39873. REFLECTIONMAP_CUBIC: boolean;
  39874. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39875. REFLECTIONMAP_PROJECTION: boolean;
  39876. REFLECTIONMAP_SKYBOX: boolean;
  39877. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39878. REFLECTIONMAP_EXPLICIT: boolean;
  39879. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39880. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39881. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39882. INVERTCUBICMAP: boolean;
  39883. LOGARITHMICDEPTH: boolean;
  39884. REFRACTION: boolean;
  39885. REFRACTIONMAP_3D: boolean;
  39886. REFLECTIONOVERALPHA: boolean;
  39887. TWOSIDEDLIGHTING: boolean;
  39888. SHADOWFLOAT: boolean;
  39889. MORPHTARGETS: boolean;
  39890. MORPHTARGETS_NORMAL: boolean;
  39891. MORPHTARGETS_TANGENT: boolean;
  39892. NUM_MORPH_INFLUENCERS: number;
  39893. NONUNIFORMSCALING: boolean;
  39894. PREMULTIPLYALPHA: boolean;
  39895. IMAGEPROCESSING: boolean;
  39896. VIGNETTE: boolean;
  39897. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39898. VIGNETTEBLENDMODEOPAQUE: boolean;
  39899. TONEMAPPING: boolean;
  39900. TONEMAPPING_ACES: boolean;
  39901. CONTRAST: boolean;
  39902. COLORCURVES: boolean;
  39903. COLORGRADING: boolean;
  39904. COLORGRADING3D: boolean;
  39905. SAMPLER3DGREENDEPTH: boolean;
  39906. SAMPLER3DBGRMAP: boolean;
  39907. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39908. MULTIVIEW: boolean;
  39909. /**
  39910. * If the reflection texture on this material is in linear color space
  39911. * @hidden
  39912. */
  39913. IS_REFLECTION_LINEAR: boolean;
  39914. /**
  39915. * If the refraction texture on this material is in linear color space
  39916. * @hidden
  39917. */
  39918. IS_REFRACTION_LINEAR: boolean;
  39919. EXPOSURE: boolean;
  39920. constructor();
  39921. setReflectionMode(modeToEnable: string): void;
  39922. }
  39923. /**
  39924. * This is the default material used in Babylon. It is the best trade off between quality
  39925. * and performances.
  39926. * @see http://doc.babylonjs.com/babylon101/materials
  39927. */
  39928. export class StandardMaterial extends PushMaterial {
  39929. private _diffuseTexture;
  39930. /**
  39931. * The basic texture of the material as viewed under a light.
  39932. */
  39933. diffuseTexture: Nullable<BaseTexture>;
  39934. private _ambientTexture;
  39935. /**
  39936. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39937. */
  39938. ambientTexture: Nullable<BaseTexture>;
  39939. private _opacityTexture;
  39940. /**
  39941. * Define the transparency of the material from a texture.
  39942. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39943. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39944. */
  39945. opacityTexture: Nullable<BaseTexture>;
  39946. private _reflectionTexture;
  39947. /**
  39948. * Define the texture used to display the reflection.
  39949. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39950. */
  39951. reflectionTexture: Nullable<BaseTexture>;
  39952. private _emissiveTexture;
  39953. /**
  39954. * Define texture of the material as if self lit.
  39955. * This will be mixed in the final result even in the absence of light.
  39956. */
  39957. emissiveTexture: Nullable<BaseTexture>;
  39958. private _specularTexture;
  39959. /**
  39960. * Define how the color and intensity of the highlight given by the light in the material.
  39961. */
  39962. specularTexture: Nullable<BaseTexture>;
  39963. private _bumpTexture;
  39964. /**
  39965. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39966. * 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.
  39967. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39968. */
  39969. bumpTexture: Nullable<BaseTexture>;
  39970. private _lightmapTexture;
  39971. /**
  39972. * Complex lighting can be computationally expensive to compute at runtime.
  39973. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39974. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39975. */
  39976. lightmapTexture: Nullable<BaseTexture>;
  39977. private _refractionTexture;
  39978. /**
  39979. * Define the texture used to display the refraction.
  39980. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39981. */
  39982. refractionTexture: Nullable<BaseTexture>;
  39983. /**
  39984. * The color of the material lit by the environmental background lighting.
  39985. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39986. */
  39987. ambientColor: Color3;
  39988. /**
  39989. * The basic color of the material as viewed under a light.
  39990. */
  39991. diffuseColor: Color3;
  39992. /**
  39993. * Define how the color and intensity of the highlight given by the light in the material.
  39994. */
  39995. specularColor: Color3;
  39996. /**
  39997. * Define the color of the material as if self lit.
  39998. * This will be mixed in the final result even in the absence of light.
  39999. */
  40000. emissiveColor: Color3;
  40001. /**
  40002. * Defines how sharp are the highlights in the material.
  40003. * The bigger the value the sharper giving a more glossy feeling to the result.
  40004. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40005. */
  40006. specularPower: number;
  40007. private _useAlphaFromDiffuseTexture;
  40008. /**
  40009. * Does the transparency come from the diffuse texture alpha channel.
  40010. */
  40011. useAlphaFromDiffuseTexture: boolean;
  40012. private _useEmissiveAsIllumination;
  40013. /**
  40014. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40015. */
  40016. useEmissiveAsIllumination: boolean;
  40017. private _linkEmissiveWithDiffuse;
  40018. /**
  40019. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40020. * the emissive level when the final color is close to one.
  40021. */
  40022. linkEmissiveWithDiffuse: boolean;
  40023. private _useSpecularOverAlpha;
  40024. /**
  40025. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40026. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40027. */
  40028. useSpecularOverAlpha: boolean;
  40029. private _useReflectionOverAlpha;
  40030. /**
  40031. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40032. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40033. */
  40034. useReflectionOverAlpha: boolean;
  40035. private _disableLighting;
  40036. /**
  40037. * Does lights from the scene impacts this material.
  40038. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40039. */
  40040. disableLighting: boolean;
  40041. private _useObjectSpaceNormalMap;
  40042. /**
  40043. * Allows using an object space normal map (instead of tangent space).
  40044. */
  40045. useObjectSpaceNormalMap: boolean;
  40046. private _useParallax;
  40047. /**
  40048. * Is parallax enabled or not.
  40049. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40050. */
  40051. useParallax: boolean;
  40052. private _useParallaxOcclusion;
  40053. /**
  40054. * Is parallax occlusion enabled or not.
  40055. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40056. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40057. */
  40058. useParallaxOcclusion: boolean;
  40059. /**
  40060. * 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.
  40061. */
  40062. parallaxScaleBias: number;
  40063. private _roughness;
  40064. /**
  40065. * Helps to define how blurry the reflections should appears in the material.
  40066. */
  40067. roughness: number;
  40068. /**
  40069. * In case of refraction, define the value of the indice of refraction.
  40070. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40071. */
  40072. indexOfRefraction: number;
  40073. /**
  40074. * Invert the refraction texture alongside the y axis.
  40075. * It can be useful with procedural textures or probe for instance.
  40076. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40077. */
  40078. invertRefractionY: boolean;
  40079. /**
  40080. * Defines the alpha limits in alpha test mode.
  40081. */
  40082. alphaCutOff: number;
  40083. private _useLightmapAsShadowmap;
  40084. /**
  40085. * In case of light mapping, define whether the map contains light or shadow informations.
  40086. */
  40087. useLightmapAsShadowmap: boolean;
  40088. private _diffuseFresnelParameters;
  40089. /**
  40090. * Define the diffuse fresnel parameters of the material.
  40091. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40092. */
  40093. diffuseFresnelParameters: FresnelParameters;
  40094. private _opacityFresnelParameters;
  40095. /**
  40096. * Define the opacity fresnel parameters of the material.
  40097. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40098. */
  40099. opacityFresnelParameters: FresnelParameters;
  40100. private _reflectionFresnelParameters;
  40101. /**
  40102. * Define the reflection fresnel parameters of the material.
  40103. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40104. */
  40105. reflectionFresnelParameters: FresnelParameters;
  40106. private _refractionFresnelParameters;
  40107. /**
  40108. * Define the refraction fresnel parameters of the material.
  40109. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40110. */
  40111. refractionFresnelParameters: FresnelParameters;
  40112. private _emissiveFresnelParameters;
  40113. /**
  40114. * Define the emissive fresnel parameters of the material.
  40115. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40116. */
  40117. emissiveFresnelParameters: FresnelParameters;
  40118. private _useReflectionFresnelFromSpecular;
  40119. /**
  40120. * If true automatically deducts the fresnels values from the material specularity.
  40121. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40122. */
  40123. useReflectionFresnelFromSpecular: boolean;
  40124. private _useGlossinessFromSpecularMapAlpha;
  40125. /**
  40126. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40127. */
  40128. useGlossinessFromSpecularMapAlpha: boolean;
  40129. private _maxSimultaneousLights;
  40130. /**
  40131. * Defines the maximum number of lights that can be used in the material
  40132. */
  40133. maxSimultaneousLights: number;
  40134. private _invertNormalMapX;
  40135. /**
  40136. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40137. */
  40138. invertNormalMapX: boolean;
  40139. private _invertNormalMapY;
  40140. /**
  40141. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40142. */
  40143. invertNormalMapY: boolean;
  40144. private _twoSidedLighting;
  40145. /**
  40146. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40147. */
  40148. twoSidedLighting: boolean;
  40149. /**
  40150. * Default configuration related to image processing available in the standard Material.
  40151. */
  40152. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40153. /**
  40154. * Gets the image processing configuration used either in this material.
  40155. */
  40156. /**
  40157. * Sets the Default image processing configuration used either in the this material.
  40158. *
  40159. * If sets to null, the scene one is in use.
  40160. */
  40161. imageProcessingConfiguration: ImageProcessingConfiguration;
  40162. /**
  40163. * Keep track of the image processing observer to allow dispose and replace.
  40164. */
  40165. private _imageProcessingObserver;
  40166. /**
  40167. * Attaches a new image processing configuration to the Standard Material.
  40168. * @param configuration
  40169. */
  40170. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40171. /**
  40172. * Gets wether the color curves effect is enabled.
  40173. */
  40174. /**
  40175. * Sets wether the color curves effect is enabled.
  40176. */
  40177. cameraColorCurvesEnabled: boolean;
  40178. /**
  40179. * Gets wether the color grading effect is enabled.
  40180. */
  40181. /**
  40182. * Gets wether the color grading effect is enabled.
  40183. */
  40184. cameraColorGradingEnabled: boolean;
  40185. /**
  40186. * Gets wether tonemapping is enabled or not.
  40187. */
  40188. /**
  40189. * Sets wether tonemapping is enabled or not
  40190. */
  40191. cameraToneMappingEnabled: boolean;
  40192. /**
  40193. * The camera exposure used on this material.
  40194. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40195. * This corresponds to a photographic exposure.
  40196. */
  40197. /**
  40198. * The camera exposure used on this material.
  40199. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40200. * This corresponds to a photographic exposure.
  40201. */
  40202. cameraExposure: number;
  40203. /**
  40204. * Gets The camera contrast used on this material.
  40205. */
  40206. /**
  40207. * Sets The camera contrast used on this material.
  40208. */
  40209. cameraContrast: number;
  40210. /**
  40211. * Gets the Color Grading 2D Lookup Texture.
  40212. */
  40213. /**
  40214. * Sets the Color Grading 2D Lookup Texture.
  40215. */
  40216. cameraColorGradingTexture: Nullable<BaseTexture>;
  40217. /**
  40218. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40219. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40220. * 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;
  40221. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40222. */
  40223. /**
  40224. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40225. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40226. * 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;
  40227. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40228. */
  40229. cameraColorCurves: Nullable<ColorCurves>;
  40230. /**
  40231. * Custom callback helping to override the default shader used in the material.
  40232. */
  40233. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40234. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40235. protected _worldViewProjectionMatrix: Matrix;
  40236. protected _globalAmbientColor: Color3;
  40237. protected _useLogarithmicDepth: boolean;
  40238. /**
  40239. * Instantiates a new standard material.
  40240. * This is the default material used in Babylon. It is the best trade off between quality
  40241. * and performances.
  40242. * @see http://doc.babylonjs.com/babylon101/materials
  40243. * @param name Define the name of the material in the scene
  40244. * @param scene Define the scene the material belong to
  40245. */
  40246. constructor(name: string, scene: Scene);
  40247. /**
  40248. * Gets a boolean indicating that current material needs to register RTT
  40249. */
  40250. readonly hasRenderTargetTextures: boolean;
  40251. /**
  40252. * Gets the current class name of the material e.g. "StandardMaterial"
  40253. * Mainly use in serialization.
  40254. * @returns the class name
  40255. */
  40256. getClassName(): string;
  40257. /**
  40258. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40259. * You can try switching to logarithmic depth.
  40260. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40261. */
  40262. useLogarithmicDepth: boolean;
  40263. /**
  40264. * Specifies if the material will require alpha blending
  40265. * @returns a boolean specifying if alpha blending is needed
  40266. */
  40267. needAlphaBlending(): boolean;
  40268. /**
  40269. * Specifies if this material should be rendered in alpha test mode
  40270. * @returns a boolean specifying if an alpha test is needed.
  40271. */
  40272. needAlphaTesting(): boolean;
  40273. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40274. /**
  40275. * Get the texture used for alpha test purpose.
  40276. * @returns the diffuse texture in case of the standard material.
  40277. */
  40278. getAlphaTestTexture(): Nullable<BaseTexture>;
  40279. /**
  40280. * Get if the submesh is ready to be used and all its information available.
  40281. * Child classes can use it to update shaders
  40282. * @param mesh defines the mesh to check
  40283. * @param subMesh defines which submesh to check
  40284. * @param useInstances specifies that instances should be used
  40285. * @returns a boolean indicating that the submesh is ready or not
  40286. */
  40287. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40288. /**
  40289. * Builds the material UBO layouts.
  40290. * Used internally during the effect preparation.
  40291. */
  40292. buildUniformLayout(): void;
  40293. /**
  40294. * Unbinds the material from the mesh
  40295. */
  40296. unbind(): void;
  40297. /**
  40298. * Binds the submesh to this material by preparing the effect and shader to draw
  40299. * @param world defines the world transformation matrix
  40300. * @param mesh defines the mesh containing the submesh
  40301. * @param subMesh defines the submesh to bind the material to
  40302. */
  40303. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40304. /**
  40305. * Get the list of animatables in the material.
  40306. * @returns the list of animatables object used in the material
  40307. */
  40308. getAnimatables(): IAnimatable[];
  40309. /**
  40310. * Gets the active textures from the material
  40311. * @returns an array of textures
  40312. */
  40313. getActiveTextures(): BaseTexture[];
  40314. /**
  40315. * Specifies if the material uses a texture
  40316. * @param texture defines the texture to check against the material
  40317. * @returns a boolean specifying if the material uses the texture
  40318. */
  40319. hasTexture(texture: BaseTexture): boolean;
  40320. /**
  40321. * Disposes the material
  40322. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40323. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40324. */
  40325. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40326. /**
  40327. * Makes a duplicate of the material, and gives it a new name
  40328. * @param name defines the new name for the duplicated material
  40329. * @returns the cloned material
  40330. */
  40331. clone(name: string): StandardMaterial;
  40332. /**
  40333. * Serializes this material in a JSON representation
  40334. * @returns the serialized material object
  40335. */
  40336. serialize(): any;
  40337. /**
  40338. * Creates a standard material from parsed material data
  40339. * @param source defines the JSON representation of the material
  40340. * @param scene defines the hosting scene
  40341. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40342. * @returns a new standard material
  40343. */
  40344. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40345. /**
  40346. * Are diffuse textures enabled in the application.
  40347. */
  40348. static DiffuseTextureEnabled: boolean;
  40349. /**
  40350. * Are ambient textures enabled in the application.
  40351. */
  40352. static AmbientTextureEnabled: boolean;
  40353. /**
  40354. * Are opacity textures enabled in the application.
  40355. */
  40356. static OpacityTextureEnabled: boolean;
  40357. /**
  40358. * Are reflection textures enabled in the application.
  40359. */
  40360. static ReflectionTextureEnabled: boolean;
  40361. /**
  40362. * Are emissive textures enabled in the application.
  40363. */
  40364. static EmissiveTextureEnabled: boolean;
  40365. /**
  40366. * Are specular textures enabled in the application.
  40367. */
  40368. static SpecularTextureEnabled: boolean;
  40369. /**
  40370. * Are bump textures enabled in the application.
  40371. */
  40372. static BumpTextureEnabled: boolean;
  40373. /**
  40374. * Are lightmap textures enabled in the application.
  40375. */
  40376. static LightmapTextureEnabled: boolean;
  40377. /**
  40378. * Are refraction textures enabled in the application.
  40379. */
  40380. static RefractionTextureEnabled: boolean;
  40381. /**
  40382. * Are color grading textures enabled in the application.
  40383. */
  40384. static ColorGradingTextureEnabled: boolean;
  40385. /**
  40386. * Are fresnels enabled in the application.
  40387. */
  40388. static FresnelEnabled: boolean;
  40389. }
  40390. }
  40391. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40392. import { Scene } from "babylonjs/scene";
  40393. import { Texture } from "babylonjs/Materials/Textures/texture";
  40394. /**
  40395. * A class extending Texture allowing drawing on a texture
  40396. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40397. */
  40398. export class DynamicTexture extends Texture {
  40399. private _generateMipMaps;
  40400. private _canvas;
  40401. private _context;
  40402. private _engine;
  40403. /**
  40404. * Creates a DynamicTexture
  40405. * @param name defines the name of the texture
  40406. * @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
  40407. * @param scene defines the scene where you want the texture
  40408. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40409. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40410. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40411. */
  40412. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40413. /**
  40414. * Get the current class name of the texture useful for serialization or dynamic coding.
  40415. * @returns "DynamicTexture"
  40416. */
  40417. getClassName(): string;
  40418. /**
  40419. * Gets the current state of canRescale
  40420. */
  40421. readonly canRescale: boolean;
  40422. private _recreate;
  40423. /**
  40424. * Scales the texture
  40425. * @param ratio the scale factor to apply to both width and height
  40426. */
  40427. scale(ratio: number): void;
  40428. /**
  40429. * Resizes the texture
  40430. * @param width the new width
  40431. * @param height the new height
  40432. */
  40433. scaleTo(width: number, height: number): void;
  40434. /**
  40435. * Gets the context of the canvas used by the texture
  40436. * @returns the canvas context of the dynamic texture
  40437. */
  40438. getContext(): CanvasRenderingContext2D;
  40439. /**
  40440. * Clears the texture
  40441. */
  40442. clear(): void;
  40443. /**
  40444. * Updates the texture
  40445. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40446. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40447. */
  40448. update(invertY?: boolean, premulAlpha?: boolean): void;
  40449. /**
  40450. * Draws text onto the texture
  40451. * @param text defines the text to be drawn
  40452. * @param x defines the placement of the text from the left
  40453. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40454. * @param font defines the font to be used with font-style, font-size, font-name
  40455. * @param color defines the color used for the text
  40456. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40457. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40458. * @param update defines whether texture is immediately update (default is true)
  40459. */
  40460. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40461. /**
  40462. * Clones the texture
  40463. * @returns the clone of the texture.
  40464. */
  40465. clone(): DynamicTexture;
  40466. /**
  40467. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40468. * @returns a serialized dynamic texture object
  40469. */
  40470. serialize(): any;
  40471. /** @hidden */
  40472. _rebuild(): void;
  40473. }
  40474. }
  40475. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40476. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40477. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40478. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40479. /** @hidden */
  40480. export var imageProcessingPixelShader: {
  40481. name: string;
  40482. shader: string;
  40483. };
  40484. }
  40485. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40486. import { Nullable } from "babylonjs/types";
  40487. import { Color4 } from "babylonjs/Maths/math";
  40488. import { Camera } from "babylonjs/Cameras/camera";
  40489. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40490. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40491. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40492. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40493. import { Engine } from "babylonjs/Engines/engine";
  40494. import "babylonjs/Shaders/imageProcessing.fragment";
  40495. import "babylonjs/Shaders/postprocess.vertex";
  40496. /**
  40497. * ImageProcessingPostProcess
  40498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40499. */
  40500. export class ImageProcessingPostProcess extends PostProcess {
  40501. /**
  40502. * Default configuration related to image processing available in the PBR Material.
  40503. */
  40504. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40505. /**
  40506. * Gets the image processing configuration used either in this material.
  40507. */
  40508. /**
  40509. * Sets the Default image processing configuration used either in the this material.
  40510. *
  40511. * If sets to null, the scene one is in use.
  40512. */
  40513. imageProcessingConfiguration: ImageProcessingConfiguration;
  40514. /**
  40515. * Keep track of the image processing observer to allow dispose and replace.
  40516. */
  40517. private _imageProcessingObserver;
  40518. /**
  40519. * Attaches a new image processing configuration to the PBR Material.
  40520. * @param configuration
  40521. */
  40522. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40523. /**
  40524. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40525. */
  40526. /**
  40527. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40528. */
  40529. colorCurves: Nullable<ColorCurves>;
  40530. /**
  40531. * Gets wether the color curves effect is enabled.
  40532. */
  40533. /**
  40534. * Sets wether the color curves effect is enabled.
  40535. */
  40536. colorCurvesEnabled: boolean;
  40537. /**
  40538. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40539. */
  40540. /**
  40541. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40542. */
  40543. colorGradingTexture: Nullable<BaseTexture>;
  40544. /**
  40545. * Gets wether the color grading effect is enabled.
  40546. */
  40547. /**
  40548. * Gets wether the color grading effect is enabled.
  40549. */
  40550. colorGradingEnabled: boolean;
  40551. /**
  40552. * Gets exposure used in the effect.
  40553. */
  40554. /**
  40555. * Sets exposure used in the effect.
  40556. */
  40557. exposure: number;
  40558. /**
  40559. * Gets wether tonemapping is enabled or not.
  40560. */
  40561. /**
  40562. * Sets wether tonemapping is enabled or not
  40563. */
  40564. toneMappingEnabled: boolean;
  40565. /**
  40566. * Gets the type of tone mapping effect.
  40567. */
  40568. /**
  40569. * Sets the type of tone mapping effect.
  40570. */
  40571. toneMappingType: number;
  40572. /**
  40573. * Gets contrast used in the effect.
  40574. */
  40575. /**
  40576. * Sets contrast used in the effect.
  40577. */
  40578. contrast: number;
  40579. /**
  40580. * Gets Vignette stretch size.
  40581. */
  40582. /**
  40583. * Sets Vignette stretch size.
  40584. */
  40585. vignetteStretch: number;
  40586. /**
  40587. * Gets Vignette centre X Offset.
  40588. */
  40589. /**
  40590. * Sets Vignette centre X Offset.
  40591. */
  40592. vignetteCentreX: number;
  40593. /**
  40594. * Gets Vignette centre Y Offset.
  40595. */
  40596. /**
  40597. * Sets Vignette centre Y Offset.
  40598. */
  40599. vignetteCentreY: number;
  40600. /**
  40601. * Gets Vignette weight or intensity of the vignette effect.
  40602. */
  40603. /**
  40604. * Sets Vignette weight or intensity of the vignette effect.
  40605. */
  40606. vignetteWeight: number;
  40607. /**
  40608. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40609. * if vignetteEnabled is set to true.
  40610. */
  40611. /**
  40612. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40613. * if vignetteEnabled is set to true.
  40614. */
  40615. vignetteColor: Color4;
  40616. /**
  40617. * Gets Camera field of view used by the Vignette effect.
  40618. */
  40619. /**
  40620. * Sets Camera field of view used by the Vignette effect.
  40621. */
  40622. vignetteCameraFov: number;
  40623. /**
  40624. * Gets the vignette blend mode allowing different kind of effect.
  40625. */
  40626. /**
  40627. * Sets the vignette blend mode allowing different kind of effect.
  40628. */
  40629. vignetteBlendMode: number;
  40630. /**
  40631. * Gets wether the vignette effect is enabled.
  40632. */
  40633. /**
  40634. * Sets wether the vignette effect is enabled.
  40635. */
  40636. vignetteEnabled: boolean;
  40637. private _fromLinearSpace;
  40638. /**
  40639. * Gets wether the input of the processing is in Gamma or Linear Space.
  40640. */
  40641. /**
  40642. * Sets wether the input of the processing is in Gamma or Linear Space.
  40643. */
  40644. fromLinearSpace: boolean;
  40645. /**
  40646. * Defines cache preventing GC.
  40647. */
  40648. private _defines;
  40649. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40650. /**
  40651. * "ImageProcessingPostProcess"
  40652. * @returns "ImageProcessingPostProcess"
  40653. */
  40654. getClassName(): string;
  40655. protected _updateParameters(): void;
  40656. dispose(camera?: Camera): void;
  40657. }
  40658. }
  40659. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40660. import { Scene } from "babylonjs/scene";
  40661. import { Color3 } from "babylonjs/Maths/math";
  40662. import { Mesh } from "babylonjs/Meshes/mesh";
  40663. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40664. import { Nullable } from "babylonjs/types";
  40665. /**
  40666. * Class containing static functions to help procedurally build meshes
  40667. */
  40668. export class GroundBuilder {
  40669. /**
  40670. * Creates a ground mesh
  40671. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40672. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40674. * @param name defines the name of the mesh
  40675. * @param options defines the options used to create the mesh
  40676. * @param scene defines the hosting scene
  40677. * @returns the ground mesh
  40678. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40679. */
  40680. static CreateGround(name: string, options: {
  40681. width?: number;
  40682. height?: number;
  40683. subdivisions?: number;
  40684. subdivisionsX?: number;
  40685. subdivisionsY?: number;
  40686. updatable?: boolean;
  40687. }, scene: any): Mesh;
  40688. /**
  40689. * Creates a tiled ground mesh
  40690. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40691. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40692. * * 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
  40693. * * 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
  40694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40695. * @param name defines the name of the mesh
  40696. * @param options defines the options used to create the mesh
  40697. * @param scene defines the hosting scene
  40698. * @returns the tiled ground mesh
  40699. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40700. */
  40701. static CreateTiledGround(name: string, options: {
  40702. xmin: number;
  40703. zmin: number;
  40704. xmax: number;
  40705. zmax: number;
  40706. subdivisions?: {
  40707. w: number;
  40708. h: number;
  40709. };
  40710. precision?: {
  40711. w: number;
  40712. h: number;
  40713. };
  40714. updatable?: boolean;
  40715. }, scene?: Nullable<Scene>): Mesh;
  40716. /**
  40717. * Creates a ground mesh from a height map
  40718. * * The parameter `url` sets the URL of the height map image resource.
  40719. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40720. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40721. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40722. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40723. * * 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.
  40724. * * 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).
  40725. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40727. * @param name defines the name of the mesh
  40728. * @param url defines the url to the height map
  40729. * @param options defines the options used to create the mesh
  40730. * @param scene defines the hosting scene
  40731. * @returns the ground mesh
  40732. * @see https://doc.babylonjs.com/babylon101/height_map
  40733. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40734. */
  40735. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40736. width?: number;
  40737. height?: number;
  40738. subdivisions?: number;
  40739. minHeight?: number;
  40740. maxHeight?: number;
  40741. colorFilter?: Color3;
  40742. alphaFilter?: number;
  40743. updatable?: boolean;
  40744. onReady?: (mesh: GroundMesh) => void;
  40745. }, scene?: Nullable<Scene>): GroundMesh;
  40746. }
  40747. }
  40748. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40749. import { Vector4 } from "babylonjs/Maths/math";
  40750. import { Mesh } from "babylonjs/Meshes/mesh";
  40751. /**
  40752. * Class containing static functions to help procedurally build meshes
  40753. */
  40754. export class TorusBuilder {
  40755. /**
  40756. * Creates a torus mesh
  40757. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40758. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40759. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40761. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40763. * @param name defines the name of the mesh
  40764. * @param options defines the options used to create the mesh
  40765. * @param scene defines the hosting scene
  40766. * @returns the torus mesh
  40767. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40768. */
  40769. static CreateTorus(name: string, options: {
  40770. diameter?: number;
  40771. thickness?: number;
  40772. tessellation?: number;
  40773. updatable?: boolean;
  40774. sideOrientation?: number;
  40775. frontUVs?: Vector4;
  40776. backUVs?: Vector4;
  40777. }, scene: any): Mesh;
  40778. }
  40779. }
  40780. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40781. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40782. import { Mesh } from "babylonjs/Meshes/mesh";
  40783. /**
  40784. * Class containing static functions to help procedurally build meshes
  40785. */
  40786. export class CylinderBuilder {
  40787. /**
  40788. * Creates a cylinder or a cone mesh
  40789. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40790. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40791. * * 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.
  40792. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40793. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40794. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40795. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40796. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40797. * * 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).
  40798. * * 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
  40799. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40800. * * 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
  40801. * * 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.
  40802. * * If `enclose` is false, a ring surface is one element.
  40803. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40804. * * 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
  40805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40806. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40808. * @param name defines the name of the mesh
  40809. * @param options defines the options used to create the mesh
  40810. * @param scene defines the hosting scene
  40811. * @returns the cylinder mesh
  40812. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40813. */
  40814. static CreateCylinder(name: string, options: {
  40815. height?: number;
  40816. diameterTop?: number;
  40817. diameterBottom?: number;
  40818. diameter?: number;
  40819. tessellation?: number;
  40820. subdivisions?: number;
  40821. arc?: number;
  40822. faceColors?: Color4[];
  40823. faceUV?: Vector4[];
  40824. updatable?: boolean;
  40825. hasRings?: boolean;
  40826. enclose?: boolean;
  40827. sideOrientation?: number;
  40828. frontUVs?: Vector4;
  40829. backUVs?: Vector4;
  40830. }, scene: any): Mesh;
  40831. }
  40832. }
  40833. declare module "babylonjs/Gamepads/gamepadManager" {
  40834. import { Observable } from "babylonjs/Misc/observable";
  40835. import { Nullable } from "babylonjs/types";
  40836. import { Scene } from "babylonjs/scene";
  40837. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40838. /**
  40839. * Manager for handling gamepads
  40840. */
  40841. export class GamepadManager {
  40842. private _scene?;
  40843. private _babylonGamepads;
  40844. private _oneGamepadConnected;
  40845. /** @hidden */
  40846. _isMonitoring: boolean;
  40847. private _gamepadEventSupported;
  40848. private _gamepadSupport;
  40849. /**
  40850. * observable to be triggered when the gamepad controller has been connected
  40851. */
  40852. onGamepadConnectedObservable: Observable<Gamepad>;
  40853. /**
  40854. * observable to be triggered when the gamepad controller has been disconnected
  40855. */
  40856. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40857. private _onGamepadConnectedEvent;
  40858. private _onGamepadDisconnectedEvent;
  40859. /**
  40860. * Initializes the gamepad manager
  40861. * @param _scene BabylonJS scene
  40862. */
  40863. constructor(_scene?: Scene | undefined);
  40864. /**
  40865. * The gamepads in the game pad manager
  40866. */
  40867. readonly gamepads: Gamepad[];
  40868. /**
  40869. * Get the gamepad controllers based on type
  40870. * @param type The type of gamepad controller
  40871. * @returns Nullable gamepad
  40872. */
  40873. getGamepadByType(type?: number): Nullable<Gamepad>;
  40874. /**
  40875. * Disposes the gamepad manager
  40876. */
  40877. dispose(): void;
  40878. private _addNewGamepad;
  40879. private _startMonitoringGamepads;
  40880. private _stopMonitoringGamepads;
  40881. /** @hidden */
  40882. _checkGamepadsStatus(): void;
  40883. private _updateGamepadObjects;
  40884. }
  40885. }
  40886. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40887. import { Nullable } from "babylonjs/types";
  40888. import { Scene } from "babylonjs/scene";
  40889. import { ISceneComponent } from "babylonjs/sceneComponent";
  40890. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40891. module "babylonjs/scene" {
  40892. interface Scene {
  40893. /** @hidden */
  40894. _gamepadManager: Nullable<GamepadManager>;
  40895. /**
  40896. * Gets the gamepad manager associated with the scene
  40897. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40898. */
  40899. gamepadManager: GamepadManager;
  40900. }
  40901. }
  40902. module "babylonjs/Cameras/freeCameraInputsManager" {
  40903. /**
  40904. * Interface representing a free camera inputs manager
  40905. */
  40906. interface FreeCameraInputsManager {
  40907. /**
  40908. * Adds gamepad input support to the FreeCameraInputsManager.
  40909. * @returns the FreeCameraInputsManager
  40910. */
  40911. addGamepad(): FreeCameraInputsManager;
  40912. }
  40913. }
  40914. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40915. /**
  40916. * Interface representing an arc rotate camera inputs manager
  40917. */
  40918. interface ArcRotateCameraInputsManager {
  40919. /**
  40920. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40921. * @returns the camera inputs manager
  40922. */
  40923. addGamepad(): ArcRotateCameraInputsManager;
  40924. }
  40925. }
  40926. /**
  40927. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40928. */
  40929. export class GamepadSystemSceneComponent implements ISceneComponent {
  40930. /**
  40931. * The component name helpfull to identify the component in the list of scene components.
  40932. */
  40933. readonly name: string;
  40934. /**
  40935. * The scene the component belongs to.
  40936. */
  40937. scene: Scene;
  40938. /**
  40939. * Creates a new instance of the component for the given scene
  40940. * @param scene Defines the scene to register the component in
  40941. */
  40942. constructor(scene: Scene);
  40943. /**
  40944. * Registers the component in a given scene
  40945. */
  40946. register(): void;
  40947. /**
  40948. * Rebuilds the elements related to this component in case of
  40949. * context lost for instance.
  40950. */
  40951. rebuild(): void;
  40952. /**
  40953. * Disposes the component and the associated ressources
  40954. */
  40955. dispose(): void;
  40956. private _beforeCameraUpdate;
  40957. }
  40958. }
  40959. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40960. import { Observable } from "babylonjs/Misc/observable";
  40961. import { Nullable } from "babylonjs/types";
  40962. import { Camera } from "babylonjs/Cameras/camera";
  40963. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40964. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40965. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40966. import { Scene } from "babylonjs/scene";
  40967. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40968. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40970. import { Mesh } from "babylonjs/Meshes/mesh";
  40971. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40972. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40973. import "babylonjs/Meshes/Builders/groundBuilder";
  40974. import "babylonjs/Meshes/Builders/torusBuilder";
  40975. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40976. import "babylonjs/Gamepads/gamepadSceneComponent";
  40977. import "babylonjs/Animations/animatable";
  40978. /**
  40979. * Options to modify the vr teleportation behavior.
  40980. */
  40981. export interface VRTeleportationOptions {
  40982. /**
  40983. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40984. */
  40985. floorMeshName?: string;
  40986. /**
  40987. * A list of meshes to be used as the teleportation floor. (default: empty)
  40988. */
  40989. floorMeshes?: Mesh[];
  40990. }
  40991. /**
  40992. * Options to modify the vr experience helper's behavior.
  40993. */
  40994. export interface VRExperienceHelperOptions extends WebVROptions {
  40995. /**
  40996. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40997. */
  40998. createDeviceOrientationCamera?: boolean;
  40999. /**
  41000. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41001. */
  41002. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41003. /**
  41004. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41005. */
  41006. laserToggle?: boolean;
  41007. /**
  41008. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41009. */
  41010. floorMeshes?: Mesh[];
  41011. /**
  41012. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41013. */
  41014. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41015. }
  41016. /**
  41017. * Event containing information after VR has been entered
  41018. */
  41019. export class OnAfterEnteringVRObservableEvent {
  41020. /**
  41021. * If entering vr was successful
  41022. */
  41023. success: boolean;
  41024. }
  41025. /**
  41026. * Helps to quickly add VR support to an existing scene.
  41027. * See http://doc.babylonjs.com/how_to/webvr_helper
  41028. */
  41029. export class VRExperienceHelper {
  41030. /** Options to modify the vr experience helper's behavior. */
  41031. webVROptions: VRExperienceHelperOptions;
  41032. private _scene;
  41033. private _position;
  41034. private _btnVR;
  41035. private _btnVRDisplayed;
  41036. private _webVRsupported;
  41037. private _webVRready;
  41038. private _webVRrequesting;
  41039. private _webVRpresenting;
  41040. private _hasEnteredVR;
  41041. private _fullscreenVRpresenting;
  41042. private _canvas;
  41043. private _webVRCamera;
  41044. private _vrDeviceOrientationCamera;
  41045. private _deviceOrientationCamera;
  41046. private _existingCamera;
  41047. private _onKeyDown;
  41048. private _onVrDisplayPresentChange;
  41049. private _onVRDisplayChanged;
  41050. private _onVRRequestPresentStart;
  41051. private _onVRRequestPresentComplete;
  41052. /**
  41053. * Observable raised right before entering VR.
  41054. */
  41055. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41056. /**
  41057. * Observable raised when entering VR has completed.
  41058. */
  41059. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41060. /**
  41061. * Observable raised when exiting VR.
  41062. */
  41063. onExitingVRObservable: Observable<VRExperienceHelper>;
  41064. /**
  41065. * Observable raised when controller mesh is loaded.
  41066. */
  41067. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41068. /** Return this.onEnteringVRObservable
  41069. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41070. */
  41071. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41072. /** Return this.onExitingVRObservable
  41073. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41074. */
  41075. readonly onExitingVR: Observable<VRExperienceHelper>;
  41076. /** Return this.onControllerMeshLoadedObservable
  41077. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41078. */
  41079. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41080. private _rayLength;
  41081. private _useCustomVRButton;
  41082. private _teleportationRequested;
  41083. private _teleportActive;
  41084. private _floorMeshName;
  41085. private _floorMeshesCollection;
  41086. private _rotationAllowed;
  41087. private _teleportBackwardsVector;
  41088. private _teleportationTarget;
  41089. private _isDefaultTeleportationTarget;
  41090. private _postProcessMove;
  41091. private _teleportationFillColor;
  41092. private _teleportationBorderColor;
  41093. private _rotationAngle;
  41094. private _haloCenter;
  41095. private _cameraGazer;
  41096. private _padSensibilityUp;
  41097. private _padSensibilityDown;
  41098. private _leftController;
  41099. private _rightController;
  41100. /**
  41101. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41102. */
  41103. onNewMeshSelected: Observable<AbstractMesh>;
  41104. /**
  41105. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41106. */
  41107. onNewMeshPicked: Observable<PickingInfo>;
  41108. private _circleEase;
  41109. /**
  41110. * Observable raised before camera teleportation
  41111. */
  41112. onBeforeCameraTeleport: Observable<Vector3>;
  41113. /**
  41114. * Observable raised after camera teleportation
  41115. */
  41116. onAfterCameraTeleport: Observable<Vector3>;
  41117. /**
  41118. * Observable raised when current selected mesh gets unselected
  41119. */
  41120. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41121. private _raySelectionPredicate;
  41122. /**
  41123. * To be optionaly changed by user to define custom ray selection
  41124. */
  41125. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41126. /**
  41127. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41128. */
  41129. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41130. /**
  41131. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41132. */
  41133. teleportationEnabled: boolean;
  41134. private _defaultHeight;
  41135. private _teleportationInitialized;
  41136. private _interactionsEnabled;
  41137. private _interactionsRequested;
  41138. private _displayGaze;
  41139. private _displayLaserPointer;
  41140. /**
  41141. * The mesh used to display where the user is going to teleport.
  41142. */
  41143. /**
  41144. * Sets the mesh to be used to display where the user is going to teleport.
  41145. */
  41146. teleportationTarget: Mesh;
  41147. /**
  41148. * 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
  41149. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41150. * See http://doc.babylonjs.com/resources/baking_transformations
  41151. */
  41152. gazeTrackerMesh: Mesh;
  41153. /**
  41154. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41155. */
  41156. updateGazeTrackerScale: boolean;
  41157. /**
  41158. * If the gaze trackers color should be updated when selecting meshes
  41159. */
  41160. updateGazeTrackerColor: boolean;
  41161. /**
  41162. * The gaze tracking mesh corresponding to the left controller
  41163. */
  41164. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41165. /**
  41166. * The gaze tracking mesh corresponding to the right controller
  41167. */
  41168. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41169. /**
  41170. * If the ray of the gaze should be displayed.
  41171. */
  41172. /**
  41173. * Sets if the ray of the gaze should be displayed.
  41174. */
  41175. displayGaze: boolean;
  41176. /**
  41177. * If the ray of the LaserPointer should be displayed.
  41178. */
  41179. /**
  41180. * Sets if the ray of the LaserPointer should be displayed.
  41181. */
  41182. displayLaserPointer: boolean;
  41183. /**
  41184. * The deviceOrientationCamera used as the camera when not in VR.
  41185. */
  41186. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41187. /**
  41188. * Based on the current WebVR support, returns the current VR camera used.
  41189. */
  41190. readonly currentVRCamera: Nullable<Camera>;
  41191. /**
  41192. * The webVRCamera which is used when in VR.
  41193. */
  41194. readonly webVRCamera: WebVRFreeCamera;
  41195. /**
  41196. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41197. */
  41198. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41199. private readonly _teleportationRequestInitiated;
  41200. /**
  41201. * Defines wether or not Pointer lock should be requested when switching to
  41202. * full screen.
  41203. */
  41204. requestPointerLockOnFullScreen: boolean;
  41205. /**
  41206. * Instantiates a VRExperienceHelper.
  41207. * Helps to quickly add VR support to an existing scene.
  41208. * @param scene The scene the VRExperienceHelper belongs to.
  41209. * @param webVROptions Options to modify the vr experience helper's behavior.
  41210. */
  41211. constructor(scene: Scene,
  41212. /** Options to modify the vr experience helper's behavior. */
  41213. webVROptions?: VRExperienceHelperOptions);
  41214. private _onDefaultMeshLoaded;
  41215. private _onResize;
  41216. private _onFullscreenChange;
  41217. /**
  41218. * Gets a value indicating if we are currently in VR mode.
  41219. */
  41220. readonly isInVRMode: boolean;
  41221. private onVrDisplayPresentChange;
  41222. private onVRDisplayChanged;
  41223. private moveButtonToBottomRight;
  41224. private displayVRButton;
  41225. private updateButtonVisibility;
  41226. private _cachedAngularSensibility;
  41227. /**
  41228. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41229. * Otherwise, will use the fullscreen API.
  41230. */
  41231. enterVR(): void;
  41232. /**
  41233. * Attempt to exit VR, or fullscreen.
  41234. */
  41235. exitVR(): void;
  41236. /**
  41237. * The position of the vr experience helper.
  41238. */
  41239. /**
  41240. * Sets the position of the vr experience helper.
  41241. */
  41242. position: Vector3;
  41243. /**
  41244. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41245. */
  41246. enableInteractions(): void;
  41247. private readonly _noControllerIsActive;
  41248. private beforeRender;
  41249. private _isTeleportationFloor;
  41250. /**
  41251. * Adds a floor mesh to be used for teleportation.
  41252. * @param floorMesh the mesh to be used for teleportation.
  41253. */
  41254. addFloorMesh(floorMesh: Mesh): void;
  41255. /**
  41256. * Removes a floor mesh from being used for teleportation.
  41257. * @param floorMesh the mesh to be removed.
  41258. */
  41259. removeFloorMesh(floorMesh: Mesh): void;
  41260. /**
  41261. * Enables interactions and teleportation using the VR controllers and gaze.
  41262. * @param vrTeleportationOptions options to modify teleportation behavior.
  41263. */
  41264. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41265. private _onNewGamepadConnected;
  41266. private _tryEnableInteractionOnController;
  41267. private _onNewGamepadDisconnected;
  41268. private _enableInteractionOnController;
  41269. private _checkTeleportWithRay;
  41270. private _checkRotate;
  41271. private _checkTeleportBackwards;
  41272. private _enableTeleportationOnController;
  41273. private _createTeleportationCircles;
  41274. private _displayTeleportationTarget;
  41275. private _hideTeleportationTarget;
  41276. private _rotateCamera;
  41277. private _moveTeleportationSelectorTo;
  41278. private _workingVector;
  41279. private _workingQuaternion;
  41280. private _workingMatrix;
  41281. /**
  41282. * Teleports the users feet to the desired location
  41283. * @param location The location where the user's feet should be placed
  41284. */
  41285. teleportCamera(location: Vector3): void;
  41286. private _convertNormalToDirectionOfRay;
  41287. private _castRayAndSelectObject;
  41288. private _notifySelectedMeshUnselected;
  41289. /**
  41290. * Sets the color of the laser ray from the vr controllers.
  41291. * @param color new color for the ray.
  41292. */
  41293. changeLaserColor(color: Color3): void;
  41294. /**
  41295. * Sets the color of the ray from the vr headsets gaze.
  41296. * @param color new color for the ray.
  41297. */
  41298. changeGazeColor(color: Color3): void;
  41299. /**
  41300. * Exits VR and disposes of the vr experience helper
  41301. */
  41302. dispose(): void;
  41303. /**
  41304. * Gets the name of the VRExperienceHelper class
  41305. * @returns "VRExperienceHelper"
  41306. */
  41307. getClassName(): string;
  41308. }
  41309. }
  41310. declare module "babylonjs/Cameras/VR/index" {
  41311. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41312. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41313. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41314. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41315. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41316. export * from "babylonjs/Cameras/VR/webVRCamera";
  41317. }
  41318. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41319. import { Observable } from "babylonjs/Misc/observable";
  41320. import { Nullable } from "babylonjs/types";
  41321. import { IDisposable, Scene } from "babylonjs/scene";
  41322. import { Vector3 } from "babylonjs/Maths/math";
  41323. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41324. import { Ray } from "babylonjs/Culling/ray";
  41325. /**
  41326. * Manages an XRSession
  41327. * @see https://doc.babylonjs.com/how_to/webxr
  41328. */
  41329. export class WebXRSessionManager implements IDisposable {
  41330. private scene;
  41331. /**
  41332. * Fires every time a new xrFrame arrives which can be used to update the camera
  41333. */
  41334. onXRFrameObservable: Observable<any>;
  41335. /**
  41336. * Fires when the xr session is ended either by the device or manually done
  41337. */
  41338. onXRSessionEnded: Observable<any>;
  41339. /** @hidden */
  41340. _xrSession: XRSession;
  41341. /** @hidden */
  41342. _frameOfReference: XRFrameOfReference;
  41343. /** @hidden */
  41344. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41345. /** @hidden */
  41346. _currentXRFrame: Nullable<XRFrame>;
  41347. private _xrNavigator;
  41348. private _xrDevice;
  41349. private _tmpMatrix;
  41350. /**
  41351. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41352. * @param scene The scene which the session should be created for
  41353. */
  41354. constructor(scene: Scene);
  41355. /**
  41356. * Initializes the manager
  41357. * After initialization enterXR can be called to start an XR session
  41358. * @returns Promise which resolves after it is initialized
  41359. */
  41360. initializeAsync(): Promise<void>;
  41361. /**
  41362. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41363. * @param sessionCreationOptions xr options to create the session with
  41364. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41365. * @returns Promise which resolves after it enters XR
  41366. */
  41367. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41368. /**
  41369. * Stops the xrSession and restores the renderloop
  41370. * @returns Promise which resolves after it exits XR
  41371. */
  41372. exitXRAsync(): Promise<void>;
  41373. /**
  41374. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41375. * @param ray ray to cast into the environment
  41376. * @returns Promise which resolves with a collision point in the environment if it exists
  41377. */
  41378. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41379. /**
  41380. * Checks if a session would be supported for the creation options specified
  41381. * @param options creation options to check if they are supported
  41382. * @returns true if supported
  41383. */
  41384. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41385. /**
  41386. * @hidden
  41387. * Converts the render layer of xrSession to a render target
  41388. * @param session session to create render target for
  41389. * @param scene scene the new render target should be created for
  41390. */
  41391. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41392. /**
  41393. * Disposes of the session manager
  41394. */
  41395. dispose(): void;
  41396. }
  41397. }
  41398. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41399. import { Scene } from "babylonjs/scene";
  41400. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41401. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41402. /**
  41403. * WebXR Camera which holds the views for the xrSession
  41404. * @see https://doc.babylonjs.com/how_to/webxr
  41405. */
  41406. export class WebXRCamera extends FreeCamera {
  41407. private static _TmpMatrix;
  41408. /**
  41409. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41410. * @param name the name of the camera
  41411. * @param scene the scene to add the camera to
  41412. */
  41413. constructor(name: string, scene: Scene);
  41414. private _updateNumberOfRigCameras;
  41415. /** @hidden */
  41416. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41417. /**
  41418. * Updates the cameras position from the current pose information of the XR session
  41419. * @param xrSessionManager the session containing pose information
  41420. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41421. */
  41422. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41423. }
  41424. }
  41425. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41426. import { Nullable } from "babylonjs/types";
  41427. import { Observable } from "babylonjs/Misc/observable";
  41428. import { IDisposable, Scene } from "babylonjs/scene";
  41429. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41431. import { Ray } from "babylonjs/Culling/ray";
  41432. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41433. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41434. /**
  41435. * States of the webXR experience
  41436. */
  41437. export enum WebXRState {
  41438. /**
  41439. * Transitioning to being in XR mode
  41440. */
  41441. ENTERING_XR = 0,
  41442. /**
  41443. * Transitioning to non XR mode
  41444. */
  41445. EXITING_XR = 1,
  41446. /**
  41447. * In XR mode and presenting
  41448. */
  41449. IN_XR = 2,
  41450. /**
  41451. * Not entered XR mode
  41452. */
  41453. NOT_IN_XR = 3
  41454. }
  41455. /**
  41456. * Helper class used to enable XR
  41457. * @see https://doc.babylonjs.com/how_to/webxr
  41458. */
  41459. export class WebXRExperienceHelper implements IDisposable {
  41460. private scene;
  41461. /**
  41462. * 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
  41463. */
  41464. container: AbstractMesh;
  41465. /**
  41466. * Camera used to render xr content
  41467. */
  41468. camera: WebXRCamera;
  41469. /**
  41470. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41471. */
  41472. state: WebXRState;
  41473. private _setState;
  41474. private static _TmpVector;
  41475. /**
  41476. * Fires when the state of the experience helper has changed
  41477. */
  41478. onStateChangedObservable: Observable<WebXRState>;
  41479. /** @hidden */
  41480. _sessionManager: WebXRSessionManager;
  41481. private _nonVRCamera;
  41482. private _originalSceneAutoClear;
  41483. private _supported;
  41484. /**
  41485. * Creates the experience helper
  41486. * @param scene the scene to attach the experience helper to
  41487. * @returns a promise for the experience helper
  41488. */
  41489. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41490. /**
  41491. * Creates a WebXRExperienceHelper
  41492. * @param scene The scene the helper should be created in
  41493. */
  41494. private constructor();
  41495. /**
  41496. * Exits XR mode and returns the scene to its original state
  41497. * @returns promise that resolves after xr mode has exited
  41498. */
  41499. exitXRAsync(): Promise<void>;
  41500. /**
  41501. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41502. * @param sessionCreationOptions options for the XR session
  41503. * @param frameOfReference frame of reference of the XR session
  41504. * @returns promise that resolves after xr mode has entered
  41505. */
  41506. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41507. /**
  41508. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41509. * @param ray ray to cast into the environment
  41510. * @returns Promise which resolves with a collision point in the environment if it exists
  41511. */
  41512. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41513. /**
  41514. * Updates the global position of the camera by moving the camera's container
  41515. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41516. * @param position The desired global position of the camera
  41517. */
  41518. setPositionOfCameraUsingContainer(position: Vector3): void;
  41519. /**
  41520. * Rotates the xr camera by rotating the camera's container around the camera's position
  41521. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41522. * @param rotation the desired quaternion rotation to apply to the camera
  41523. */
  41524. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41525. /**
  41526. * Checks if the creation options are supported by the xr session
  41527. * @param options creation options
  41528. * @returns true if supported
  41529. */
  41530. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41531. /**
  41532. * Disposes of the experience helper
  41533. */
  41534. dispose(): void;
  41535. }
  41536. }
  41537. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41538. import { Nullable } from "babylonjs/types";
  41539. import { Observable } from "babylonjs/Misc/observable";
  41540. import { IDisposable, Scene } from "babylonjs/scene";
  41541. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41542. /**
  41543. * Button which can be used to enter a different mode of XR
  41544. */
  41545. export class WebXREnterExitUIButton {
  41546. /** button element */
  41547. element: HTMLElement;
  41548. /** XR initialization options for the button */
  41549. initializationOptions: XRSessionCreationOptions;
  41550. /**
  41551. * Creates a WebXREnterExitUIButton
  41552. * @param element button element
  41553. * @param initializationOptions XR initialization options for the button
  41554. */
  41555. constructor(
  41556. /** button element */
  41557. element: HTMLElement,
  41558. /** XR initialization options for the button */
  41559. initializationOptions: XRSessionCreationOptions);
  41560. /**
  41561. * Overwritable function which can be used to update the button's visuals when the state changes
  41562. * @param activeButton the current active button in the UI
  41563. */
  41564. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41565. }
  41566. /**
  41567. * Options to create the webXR UI
  41568. */
  41569. export class WebXREnterExitUIOptions {
  41570. /**
  41571. * Context to enter xr with
  41572. */
  41573. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41574. /**
  41575. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41576. */
  41577. customButtons?: Array<WebXREnterExitUIButton>;
  41578. }
  41579. /**
  41580. * UI to allow the user to enter/exit XR mode
  41581. */
  41582. export class WebXREnterExitUI implements IDisposable {
  41583. private scene;
  41584. private _overlay;
  41585. private _buttons;
  41586. private _activeButton;
  41587. /**
  41588. * Fired every time the active button is changed.
  41589. *
  41590. * When xr is entered via a button that launches xr that button will be the callback parameter
  41591. *
  41592. * When exiting xr the callback parameter will be null)
  41593. */
  41594. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41595. /**
  41596. * Creates UI to allow the user to enter/exit XR mode
  41597. * @param scene the scene to add the ui to
  41598. * @param helper the xr experience helper to enter/exit xr with
  41599. * @param options options to configure the UI
  41600. * @returns the created ui
  41601. */
  41602. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41603. private constructor();
  41604. private _updateButtons;
  41605. /**
  41606. * Disposes of the object
  41607. */
  41608. dispose(): void;
  41609. }
  41610. }
  41611. declare module "babylonjs/Cameras/XR/webXRInput" {
  41612. import { IDisposable, Scene } from "babylonjs/scene";
  41613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41614. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41615. /**
  41616. * Represents an XR input
  41617. */
  41618. export class WebXRController {
  41619. /**
  41620. * 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
  41621. */
  41622. grip?: AbstractMesh;
  41623. /**
  41624. * Pointer which can be used to select objects or attach a visible laser to
  41625. */
  41626. pointer: AbstractMesh;
  41627. /**
  41628. * Creates the controller
  41629. * @see https://doc.babylonjs.com/how_to/webxr
  41630. * @param scene the scene which the controller should be associated to
  41631. */
  41632. constructor(scene: Scene);
  41633. /**
  41634. * Disposes of the object
  41635. */
  41636. dispose(): void;
  41637. }
  41638. /**
  41639. * XR input used to track XR inputs such as controllers/rays
  41640. */
  41641. export class WebXRInput implements IDisposable {
  41642. private helper;
  41643. /**
  41644. * XR controllers being tracked
  41645. */
  41646. controllers: Array<WebXRController>;
  41647. private _tmpMatrix;
  41648. private _frameObserver;
  41649. /**
  41650. * Initializes the WebXRInput
  41651. * @param helper experience helper which the input should be created for
  41652. */
  41653. constructor(helper: WebXRExperienceHelper);
  41654. /**
  41655. * Disposes of the object
  41656. */
  41657. dispose(): void;
  41658. }
  41659. }
  41660. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41661. import { Nullable } from "babylonjs/types";
  41662. import { IDisposable } from "babylonjs/scene";
  41663. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41664. /**
  41665. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41666. */
  41667. export class WebXRManagedOutputCanvas implements IDisposable {
  41668. private _canvas;
  41669. /**
  41670. * xrpresent context of the canvas which can be used to display/mirror xr content
  41671. */
  41672. canvasContext: Nullable<WebGLRenderingContext>;
  41673. /**
  41674. * Initializes the canvas to be added/removed upon entering/exiting xr
  41675. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41676. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41677. */
  41678. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41679. /**
  41680. * Disposes of the object
  41681. */
  41682. dispose(): void;
  41683. private _setManagedOutputCanvas;
  41684. private _addCanvas;
  41685. private _removeCanvas;
  41686. }
  41687. }
  41688. declare module "babylonjs/Cameras/XR/index" {
  41689. export * from "babylonjs/Cameras/XR/webXRCamera";
  41690. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41691. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41692. export * from "babylonjs/Cameras/XR/webXRInput";
  41693. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41694. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41695. }
  41696. declare module "babylonjs/Cameras/RigModes/index" {
  41697. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41698. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41699. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41700. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41701. }
  41702. declare module "babylonjs/Cameras/index" {
  41703. export * from "babylonjs/Cameras/Inputs/index";
  41704. export * from "babylonjs/Cameras/cameraInputsManager";
  41705. export * from "babylonjs/Cameras/camera";
  41706. export * from "babylonjs/Cameras/targetCamera";
  41707. export * from "babylonjs/Cameras/freeCamera";
  41708. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41709. export * from "babylonjs/Cameras/touchCamera";
  41710. export * from "babylonjs/Cameras/arcRotateCamera";
  41711. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41712. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41713. export * from "babylonjs/Cameras/flyCamera";
  41714. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41715. export * from "babylonjs/Cameras/followCamera";
  41716. export * from "babylonjs/Cameras/gamepadCamera";
  41717. export * from "babylonjs/Cameras/Stereoscopic/index";
  41718. export * from "babylonjs/Cameras/universalCamera";
  41719. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41720. export * from "babylonjs/Cameras/VR/index";
  41721. export * from "babylonjs/Cameras/XR/index";
  41722. export * from "babylonjs/Cameras/RigModes/index";
  41723. }
  41724. declare module "babylonjs/Collisions/index" {
  41725. export * from "babylonjs/Collisions/collider";
  41726. export * from "babylonjs/Collisions/collisionCoordinator";
  41727. export * from "babylonjs/Collisions/pickingInfo";
  41728. export * from "babylonjs/Collisions/intersectionInfo";
  41729. }
  41730. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41731. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41732. import { Vector3, Plane } from "babylonjs/Maths/math";
  41733. import { Ray } from "babylonjs/Culling/ray";
  41734. /**
  41735. * Contains an array of blocks representing the octree
  41736. */
  41737. export interface IOctreeContainer<T> {
  41738. /**
  41739. * Blocks within the octree
  41740. */
  41741. blocks: Array<OctreeBlock<T>>;
  41742. }
  41743. /**
  41744. * Class used to store a cell in an octree
  41745. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41746. */
  41747. export class OctreeBlock<T> {
  41748. /**
  41749. * Gets the content of the current block
  41750. */
  41751. entries: T[];
  41752. /**
  41753. * Gets the list of block children
  41754. */
  41755. blocks: Array<OctreeBlock<T>>;
  41756. private _depth;
  41757. private _maxDepth;
  41758. private _capacity;
  41759. private _minPoint;
  41760. private _maxPoint;
  41761. private _boundingVectors;
  41762. private _creationFunc;
  41763. /**
  41764. * Creates a new block
  41765. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41766. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41767. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41768. * @param depth defines the current depth of this block in the octree
  41769. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41770. * @param creationFunc defines a callback to call when an element is added to the block
  41771. */
  41772. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41773. /**
  41774. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41775. */
  41776. readonly capacity: number;
  41777. /**
  41778. * Gets the minimum vector (in world space) of the block's bounding box
  41779. */
  41780. readonly minPoint: Vector3;
  41781. /**
  41782. * Gets the maximum vector (in world space) of the block's bounding box
  41783. */
  41784. readonly maxPoint: Vector3;
  41785. /**
  41786. * Add a new element to this block
  41787. * @param entry defines the element to add
  41788. */
  41789. addEntry(entry: T): void;
  41790. /**
  41791. * Remove an element from this block
  41792. * @param entry defines the element to remove
  41793. */
  41794. removeEntry(entry: T): void;
  41795. /**
  41796. * Add an array of elements to this block
  41797. * @param entries defines the array of elements to add
  41798. */
  41799. addEntries(entries: T[]): void;
  41800. /**
  41801. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41802. * @param frustumPlanes defines the frustum planes to test
  41803. * @param selection defines the array to store current content if selection is positive
  41804. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41805. */
  41806. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41807. /**
  41808. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41809. * @param sphereCenter defines the bounding sphere center
  41810. * @param sphereRadius defines the bounding sphere radius
  41811. * @param selection defines the array to store current content if selection is positive
  41812. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41813. */
  41814. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41815. /**
  41816. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41817. * @param ray defines the ray to test with
  41818. * @param selection defines the array to store current content if selection is positive
  41819. */
  41820. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41821. /**
  41822. * Subdivide the content into child blocks (this block will then be empty)
  41823. */
  41824. createInnerBlocks(): void;
  41825. /**
  41826. * @hidden
  41827. */
  41828. 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;
  41829. }
  41830. }
  41831. declare module "babylonjs/Culling/Octrees/octree" {
  41832. import { SmartArray } from "babylonjs/Misc/smartArray";
  41833. import { Vector3, Plane } from "babylonjs/Maths/math";
  41834. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41836. import { Ray } from "babylonjs/Culling/ray";
  41837. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41838. /**
  41839. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41840. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41841. */
  41842. export class Octree<T> {
  41843. /** 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.) */
  41844. maxDepth: number;
  41845. /**
  41846. * Blocks within the octree containing objects
  41847. */
  41848. blocks: Array<OctreeBlock<T>>;
  41849. /**
  41850. * Content stored in the octree
  41851. */
  41852. dynamicContent: T[];
  41853. private _maxBlockCapacity;
  41854. private _selectionContent;
  41855. private _creationFunc;
  41856. /**
  41857. * Creates a octree
  41858. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41859. * @param creationFunc function to be used to instatiate the octree
  41860. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41861. * @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.)
  41862. */
  41863. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41864. /** 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.) */
  41865. maxDepth?: number);
  41866. /**
  41867. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41868. * @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);
  41869. * @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);
  41870. * @param entries meshes to be added to the octree blocks
  41871. */
  41872. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41873. /**
  41874. * Adds a mesh to the octree
  41875. * @param entry Mesh to add to the octree
  41876. */
  41877. addMesh(entry: T): void;
  41878. /**
  41879. * Remove an element from the octree
  41880. * @param entry defines the element to remove
  41881. */
  41882. removeMesh(entry: T): void;
  41883. /**
  41884. * Selects an array of meshes within the frustum
  41885. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41886. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41887. * @returns array of meshes within the frustum
  41888. */
  41889. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41890. /**
  41891. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41892. * @param sphereCenter defines the bounding sphere center
  41893. * @param sphereRadius defines the bounding sphere radius
  41894. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41895. * @returns an array of objects that intersect the sphere
  41896. */
  41897. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41898. /**
  41899. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41900. * @param ray defines the ray to test with
  41901. * @returns array of intersected objects
  41902. */
  41903. intersectsRay(ray: Ray): SmartArray<T>;
  41904. /**
  41905. * Adds a mesh into the octree block if it intersects the block
  41906. */
  41907. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41908. /**
  41909. * Adds a submesh into the octree block if it intersects the block
  41910. */
  41911. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41912. }
  41913. }
  41914. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41915. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41916. import { Scene } from "babylonjs/scene";
  41917. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41919. import { Ray } from "babylonjs/Culling/ray";
  41920. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41921. import { Collider } from "babylonjs/Collisions/collider";
  41922. module "babylonjs/scene" {
  41923. interface Scene {
  41924. /**
  41925. * @hidden
  41926. * Backing Filed
  41927. */
  41928. _selectionOctree: Octree<AbstractMesh>;
  41929. /**
  41930. * Gets the octree used to boost mesh selection (picking)
  41931. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41932. */
  41933. selectionOctree: Octree<AbstractMesh>;
  41934. /**
  41935. * Creates or updates the octree used to boost selection (picking)
  41936. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41937. * @param maxCapacity defines the maximum capacity per leaf
  41938. * @param maxDepth defines the maximum depth of the octree
  41939. * @returns an octree of AbstractMesh
  41940. */
  41941. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41942. }
  41943. }
  41944. module "babylonjs/Meshes/abstractMesh" {
  41945. interface AbstractMesh {
  41946. /**
  41947. * @hidden
  41948. * Backing Field
  41949. */
  41950. _submeshesOctree: Octree<SubMesh>;
  41951. /**
  41952. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41953. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41954. * @param maxCapacity defines the maximum size of each block (64 by default)
  41955. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41956. * @returns the new octree
  41957. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41958. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41959. */
  41960. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41961. }
  41962. }
  41963. /**
  41964. * Defines the octree scene component responsible to manage any octrees
  41965. * in a given scene.
  41966. */
  41967. export class OctreeSceneComponent {
  41968. /**
  41969. * The component name help to identify the component in the list of scene components.
  41970. */
  41971. readonly name: string;
  41972. /**
  41973. * The scene the component belongs to.
  41974. */
  41975. scene: Scene;
  41976. /**
  41977. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41978. */
  41979. readonly checksIsEnabled: boolean;
  41980. /**
  41981. * Creates a new instance of the component for the given scene
  41982. * @param scene Defines the scene to register the component in
  41983. */
  41984. constructor(scene: Scene);
  41985. /**
  41986. * Registers the component in a given scene
  41987. */
  41988. register(): void;
  41989. /**
  41990. * Return the list of active meshes
  41991. * @returns the list of active meshes
  41992. */
  41993. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41994. /**
  41995. * Return the list of active sub meshes
  41996. * @param mesh The mesh to get the candidates sub meshes from
  41997. * @returns the list of active sub meshes
  41998. */
  41999. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42000. private _tempRay;
  42001. /**
  42002. * Return the list of sub meshes intersecting with a given local ray
  42003. * @param mesh defines the mesh to find the submesh for
  42004. * @param localRay defines the ray in local space
  42005. * @returns the list of intersecting sub meshes
  42006. */
  42007. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42008. /**
  42009. * Return the list of sub meshes colliding with a collider
  42010. * @param mesh defines the mesh to find the submesh for
  42011. * @param collider defines the collider to evaluate the collision against
  42012. * @returns the list of colliding sub meshes
  42013. */
  42014. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42015. /**
  42016. * Rebuilds the elements related to this component in case of
  42017. * context lost for instance.
  42018. */
  42019. rebuild(): void;
  42020. /**
  42021. * Disposes the component and the associated ressources.
  42022. */
  42023. dispose(): void;
  42024. }
  42025. }
  42026. declare module "babylonjs/Culling/Octrees/index" {
  42027. export * from "babylonjs/Culling/Octrees/octree";
  42028. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42029. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42030. }
  42031. declare module "babylonjs/Culling/index" {
  42032. export * from "babylonjs/Culling/boundingBox";
  42033. export * from "babylonjs/Culling/boundingInfo";
  42034. export * from "babylonjs/Culling/boundingSphere";
  42035. export * from "babylonjs/Culling/Octrees/index";
  42036. export * from "babylonjs/Culling/ray";
  42037. }
  42038. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42039. import { IDisposable, Scene } from "babylonjs/scene";
  42040. import { Nullable } from "babylonjs/types";
  42041. import { Observable } from "babylonjs/Misc/observable";
  42042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42043. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42044. /**
  42045. * Renders a layer on top of an existing scene
  42046. */
  42047. export class UtilityLayerRenderer implements IDisposable {
  42048. /** the original scene that will be rendered on top of */
  42049. originalScene: Scene;
  42050. private _pointerCaptures;
  42051. private _lastPointerEvents;
  42052. private static _DefaultUtilityLayer;
  42053. private static _DefaultKeepDepthUtilityLayer;
  42054. private _sharedGizmoLight;
  42055. /**
  42056. * @hidden
  42057. * Light which used by gizmos to get light shading
  42058. */
  42059. _getSharedGizmoLight(): HemisphericLight;
  42060. /**
  42061. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42062. */
  42063. pickUtilitySceneFirst: boolean;
  42064. /**
  42065. * 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)
  42066. */
  42067. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42068. /**
  42069. * 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)
  42070. */
  42071. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42072. /**
  42073. * The scene that is rendered on top of the original scene
  42074. */
  42075. utilityLayerScene: Scene;
  42076. /**
  42077. * If the utility layer should automatically be rendered on top of existing scene
  42078. */
  42079. shouldRender: boolean;
  42080. /**
  42081. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42082. */
  42083. onlyCheckPointerDownEvents: boolean;
  42084. /**
  42085. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42086. */
  42087. processAllEvents: boolean;
  42088. /**
  42089. * Observable raised when the pointer move from the utility layer scene to the main scene
  42090. */
  42091. onPointerOutObservable: Observable<number>;
  42092. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42093. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42094. private _afterRenderObserver;
  42095. private _sceneDisposeObserver;
  42096. private _originalPointerObserver;
  42097. /**
  42098. * Instantiates a UtilityLayerRenderer
  42099. * @param originalScene the original scene that will be rendered on top of
  42100. * @param handleEvents boolean indicating if the utility layer should handle events
  42101. */
  42102. constructor(
  42103. /** the original scene that will be rendered on top of */
  42104. originalScene: Scene, handleEvents?: boolean);
  42105. private _notifyObservers;
  42106. /**
  42107. * Renders the utility layers scene on top of the original scene
  42108. */
  42109. render(): void;
  42110. /**
  42111. * Disposes of the renderer
  42112. */
  42113. dispose(): void;
  42114. private _updateCamera;
  42115. }
  42116. }
  42117. declare module "babylonjs/Gizmos/gizmo" {
  42118. import { Nullable } from "babylonjs/types";
  42119. import { IDisposable } from "babylonjs/scene";
  42120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42121. import { Mesh } from "babylonjs/Meshes/mesh";
  42122. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42123. /**
  42124. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42125. */
  42126. export class Gizmo implements IDisposable {
  42127. /** The utility layer the gizmo will be added to */
  42128. gizmoLayer: UtilityLayerRenderer;
  42129. /**
  42130. * The root mesh of the gizmo
  42131. */
  42132. _rootMesh: Mesh;
  42133. private _attachedMesh;
  42134. /**
  42135. * Ratio for the scale of the gizmo (Default: 1)
  42136. */
  42137. scaleRatio: number;
  42138. /**
  42139. * If a custom mesh has been set (Default: false)
  42140. */
  42141. protected _customMeshSet: boolean;
  42142. /**
  42143. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42144. * * When set, interactions will be enabled
  42145. */
  42146. attachedMesh: Nullable<AbstractMesh>;
  42147. /**
  42148. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42149. * @param mesh The mesh to replace the default mesh of the gizmo
  42150. */
  42151. setCustomMesh(mesh: Mesh): void;
  42152. /**
  42153. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42154. */
  42155. updateGizmoRotationToMatchAttachedMesh: boolean;
  42156. /**
  42157. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42158. */
  42159. updateGizmoPositionToMatchAttachedMesh: boolean;
  42160. /**
  42161. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42162. */
  42163. protected _updateScale: boolean;
  42164. protected _interactionsEnabled: boolean;
  42165. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42166. private _beforeRenderObserver;
  42167. private _tempVector;
  42168. /**
  42169. * Creates a gizmo
  42170. * @param gizmoLayer The utility layer the gizmo will be added to
  42171. */
  42172. constructor(
  42173. /** The utility layer the gizmo will be added to */
  42174. gizmoLayer?: UtilityLayerRenderer);
  42175. /**
  42176. * Updates the gizmo to match the attached mesh's position/rotation
  42177. */
  42178. protected _update(): void;
  42179. /**
  42180. * Disposes of the gizmo
  42181. */
  42182. dispose(): void;
  42183. }
  42184. }
  42185. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42186. import { Observable } from "babylonjs/Misc/observable";
  42187. import { Nullable } from "babylonjs/types";
  42188. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42189. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42191. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42192. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42193. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42194. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42195. import { Scene } from "babylonjs/scene";
  42196. /**
  42197. * Single axis drag gizmo
  42198. */
  42199. export class AxisDragGizmo extends Gizmo {
  42200. /**
  42201. * Drag behavior responsible for the gizmos dragging interactions
  42202. */
  42203. dragBehavior: PointerDragBehavior;
  42204. private _pointerObserver;
  42205. /**
  42206. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42207. */
  42208. snapDistance: number;
  42209. /**
  42210. * Event that fires each time the gizmo snaps to a new location.
  42211. * * snapDistance is the the change in distance
  42212. */
  42213. onSnapObservable: Observable<{
  42214. snapDistance: number;
  42215. }>;
  42216. /** @hidden */
  42217. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42218. /** @hidden */
  42219. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42220. /**
  42221. * Creates an AxisDragGizmo
  42222. * @param gizmoLayer The utility layer the gizmo will be added to
  42223. * @param dragAxis The axis which the gizmo will be able to drag on
  42224. * @param color The color of the gizmo
  42225. */
  42226. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42227. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42228. /**
  42229. * Disposes of the gizmo
  42230. */
  42231. dispose(): void;
  42232. }
  42233. }
  42234. declare module "babylonjs/Debug/axesViewer" {
  42235. import { Vector3 } from "babylonjs/Maths/math";
  42236. import { Nullable } from "babylonjs/types";
  42237. import { Scene } from "babylonjs/scene";
  42238. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42239. /**
  42240. * The Axes viewer will show 3 axes in a specific point in space
  42241. */
  42242. export class AxesViewer {
  42243. private _xAxis;
  42244. private _yAxis;
  42245. private _zAxis;
  42246. private _scaleLinesFactor;
  42247. private _instanced;
  42248. /**
  42249. * Gets the hosting scene
  42250. */
  42251. scene: Scene;
  42252. /**
  42253. * Gets or sets a number used to scale line length
  42254. */
  42255. scaleLines: number;
  42256. /** Gets the node hierarchy used to render x-axis */
  42257. readonly xAxis: TransformNode;
  42258. /** Gets the node hierarchy used to render y-axis */
  42259. readonly yAxis: TransformNode;
  42260. /** Gets the node hierarchy used to render z-axis */
  42261. readonly zAxis: TransformNode;
  42262. /**
  42263. * Creates a new AxesViewer
  42264. * @param scene defines the hosting scene
  42265. * @param scaleLines defines a number used to scale line length (1 by default)
  42266. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42267. * @param xAxis defines the node hierarchy used to render the x-axis
  42268. * @param yAxis defines the node hierarchy used to render the y-axis
  42269. * @param zAxis defines the node hierarchy used to render the z-axis
  42270. */
  42271. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42272. /**
  42273. * Force the viewer to update
  42274. * @param position defines the position of the viewer
  42275. * @param xaxis defines the x axis of the viewer
  42276. * @param yaxis defines the y axis of the viewer
  42277. * @param zaxis defines the z axis of the viewer
  42278. */
  42279. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42280. /**
  42281. * Creates an instance of this axes viewer.
  42282. * @returns a new axes viewer with instanced meshes
  42283. */
  42284. createInstance(): AxesViewer;
  42285. /** Releases resources */
  42286. dispose(): void;
  42287. private static _SetRenderingGroupId;
  42288. }
  42289. }
  42290. declare module "babylonjs/Debug/boneAxesViewer" {
  42291. import { Nullable } from "babylonjs/types";
  42292. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42293. import { Vector3 } from "babylonjs/Maths/math";
  42294. import { Mesh } from "babylonjs/Meshes/mesh";
  42295. import { Bone } from "babylonjs/Bones/bone";
  42296. import { Scene } from "babylonjs/scene";
  42297. /**
  42298. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42299. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42300. */
  42301. export class BoneAxesViewer extends AxesViewer {
  42302. /**
  42303. * Gets or sets the target mesh where to display the axes viewer
  42304. */
  42305. mesh: Nullable<Mesh>;
  42306. /**
  42307. * Gets or sets the target bone where to display the axes viewer
  42308. */
  42309. bone: Nullable<Bone>;
  42310. /** Gets current position */
  42311. pos: Vector3;
  42312. /** Gets direction of X axis */
  42313. xaxis: Vector3;
  42314. /** Gets direction of Y axis */
  42315. yaxis: Vector3;
  42316. /** Gets direction of Z axis */
  42317. zaxis: Vector3;
  42318. /**
  42319. * Creates a new BoneAxesViewer
  42320. * @param scene defines the hosting scene
  42321. * @param bone defines the target bone
  42322. * @param mesh defines the target mesh
  42323. * @param scaleLines defines a scaling factor for line length (1 by default)
  42324. */
  42325. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42326. /**
  42327. * Force the viewer to update
  42328. */
  42329. update(): void;
  42330. /** Releases resources */
  42331. dispose(): void;
  42332. }
  42333. }
  42334. declare module "babylonjs/Debug/debugLayer" {
  42335. import { Observable } from "babylonjs/Misc/observable";
  42336. import { Scene } from "babylonjs/scene";
  42337. /**
  42338. * Interface used to define scene explorer extensibility option
  42339. */
  42340. export interface IExplorerExtensibilityOption {
  42341. /**
  42342. * Define the option label
  42343. */
  42344. label: string;
  42345. /**
  42346. * Defines the action to execute on click
  42347. */
  42348. action: (entity: any) => void;
  42349. }
  42350. /**
  42351. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42352. */
  42353. export interface IExplorerExtensibilityGroup {
  42354. /**
  42355. * Defines a predicate to test if a given type mut be extended
  42356. */
  42357. predicate: (entity: any) => boolean;
  42358. /**
  42359. * Gets the list of options added to a type
  42360. */
  42361. entries: IExplorerExtensibilityOption[];
  42362. }
  42363. /**
  42364. * Interface used to define the options to use to create the Inspector
  42365. */
  42366. export interface IInspectorOptions {
  42367. /**
  42368. * Display in overlay mode (default: false)
  42369. */
  42370. overlay?: boolean;
  42371. /**
  42372. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42373. */
  42374. globalRoot?: HTMLElement;
  42375. /**
  42376. * Display the Scene explorer
  42377. */
  42378. showExplorer?: boolean;
  42379. /**
  42380. * Display the property inspector
  42381. */
  42382. showInspector?: boolean;
  42383. /**
  42384. * Display in embed mode (both panes on the right)
  42385. */
  42386. embedMode?: boolean;
  42387. /**
  42388. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42389. */
  42390. handleResize?: boolean;
  42391. /**
  42392. * Allow the panes to popup (default: true)
  42393. */
  42394. enablePopup?: boolean;
  42395. /**
  42396. * Allow the panes to be closed by users (default: true)
  42397. */
  42398. enableClose?: boolean;
  42399. /**
  42400. * Optional list of extensibility entries
  42401. */
  42402. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42403. /**
  42404. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42405. */
  42406. inspectorURL?: string;
  42407. }
  42408. module "babylonjs/scene" {
  42409. interface Scene {
  42410. /**
  42411. * @hidden
  42412. * Backing field
  42413. */
  42414. _debugLayer: DebugLayer;
  42415. /**
  42416. * Gets the debug layer (aka Inspector) associated with the scene
  42417. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42418. */
  42419. debugLayer: DebugLayer;
  42420. }
  42421. }
  42422. /**
  42423. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42424. * what is happening in your scene
  42425. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42426. */
  42427. export class DebugLayer {
  42428. /**
  42429. * Define the url to get the inspector script from.
  42430. * By default it uses the babylonjs CDN.
  42431. * @ignoreNaming
  42432. */
  42433. static InspectorURL: string;
  42434. private _scene;
  42435. private BJSINSPECTOR;
  42436. /**
  42437. * Observable triggered when a property is changed through the inspector.
  42438. */
  42439. onPropertyChangedObservable: Observable<{
  42440. object: any;
  42441. property: string;
  42442. value: any;
  42443. initialValue: any;
  42444. }>;
  42445. /**
  42446. * Instantiates a new debug layer.
  42447. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42448. * what is happening in your scene
  42449. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42450. * @param scene Defines the scene to inspect
  42451. */
  42452. constructor(scene: Scene);
  42453. /** Creates the inspector window. */
  42454. private _createInspector;
  42455. /**
  42456. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42457. * @param entity defines the entity to select
  42458. * @param lineContainerTitle defines the specific block to highlight
  42459. */
  42460. select(entity: any, lineContainerTitle?: string): void;
  42461. /** Get the inspector from bundle or global */
  42462. private _getGlobalInspector;
  42463. /**
  42464. * Get if the inspector is visible or not.
  42465. * @returns true if visible otherwise, false
  42466. */
  42467. isVisible(): boolean;
  42468. /**
  42469. * Hide the inspector and close its window.
  42470. */
  42471. hide(): void;
  42472. /**
  42473. * Launch the debugLayer.
  42474. * @param config Define the configuration of the inspector
  42475. * @return a promise fulfilled when the debug layer is visible
  42476. */
  42477. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42478. }
  42479. }
  42480. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42481. import { Nullable } from "babylonjs/types";
  42482. import { Scene } from "babylonjs/scene";
  42483. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42484. import { Mesh } from "babylonjs/Meshes/mesh";
  42485. /**
  42486. * Class containing static functions to help procedurally build meshes
  42487. */
  42488. export class BoxBuilder {
  42489. /**
  42490. * Creates a box mesh
  42491. * * The parameter `size` sets the size (float) of each box side (default 1)
  42492. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42493. * * 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)
  42494. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42496. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42498. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42499. * @param name defines the name of the mesh
  42500. * @param options defines the options used to create the mesh
  42501. * @param scene defines the hosting scene
  42502. * @returns the box mesh
  42503. */
  42504. static CreateBox(name: string, options: {
  42505. size?: number;
  42506. width?: number;
  42507. height?: number;
  42508. depth?: number;
  42509. faceUV?: Vector4[];
  42510. faceColors?: Color4[];
  42511. sideOrientation?: number;
  42512. frontUVs?: Vector4;
  42513. backUVs?: Vector4;
  42514. wrap?: boolean;
  42515. topBaseAt?: number;
  42516. bottomBaseAt?: number;
  42517. updatable?: boolean;
  42518. }, scene?: Nullable<Scene>): Mesh;
  42519. }
  42520. }
  42521. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42522. import { Vector4 } from "babylonjs/Maths/math";
  42523. import { Mesh } from "babylonjs/Meshes/mesh";
  42524. /**
  42525. * Class containing static functions to help procedurally build meshes
  42526. */
  42527. export class SphereBuilder {
  42528. /**
  42529. * Creates a sphere mesh
  42530. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42531. * * 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`)
  42532. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42533. * * 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
  42534. * * 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)
  42535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42536. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42538. * @param name defines the name of the mesh
  42539. * @param options defines the options used to create the mesh
  42540. * @param scene defines the hosting scene
  42541. * @returns the sphere mesh
  42542. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42543. */
  42544. static CreateSphere(name: string, options: {
  42545. segments?: number;
  42546. diameter?: number;
  42547. diameterX?: number;
  42548. diameterY?: number;
  42549. diameterZ?: number;
  42550. arc?: number;
  42551. slice?: number;
  42552. sideOrientation?: number;
  42553. frontUVs?: Vector4;
  42554. backUVs?: Vector4;
  42555. updatable?: boolean;
  42556. }, scene: any): Mesh;
  42557. }
  42558. }
  42559. declare module "babylonjs/Debug/physicsViewer" {
  42560. import { Nullable } from "babylonjs/types";
  42561. import { Scene } from "babylonjs/scene";
  42562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42563. import { Mesh } from "babylonjs/Meshes/mesh";
  42564. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42565. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42566. /**
  42567. * Used to show the physics impostor around the specific mesh
  42568. */
  42569. export class PhysicsViewer {
  42570. /** @hidden */
  42571. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42572. /** @hidden */
  42573. protected _meshes: Array<Nullable<AbstractMesh>>;
  42574. /** @hidden */
  42575. protected _scene: Nullable<Scene>;
  42576. /** @hidden */
  42577. protected _numMeshes: number;
  42578. /** @hidden */
  42579. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42580. private _renderFunction;
  42581. private _utilityLayer;
  42582. private _debugBoxMesh;
  42583. private _debugSphereMesh;
  42584. private _debugCylinderMesh;
  42585. private _debugMaterial;
  42586. private _debugMeshMeshes;
  42587. /**
  42588. * Creates a new PhysicsViewer
  42589. * @param scene defines the hosting scene
  42590. */
  42591. constructor(scene: Scene);
  42592. /** @hidden */
  42593. protected _updateDebugMeshes(): void;
  42594. /**
  42595. * Renders a specified physic impostor
  42596. * @param impostor defines the impostor to render
  42597. * @param targetMesh defines the mesh represented by the impostor
  42598. * @returns the new debug mesh used to render the impostor
  42599. */
  42600. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42601. /**
  42602. * Hides a specified physic impostor
  42603. * @param impostor defines the impostor to hide
  42604. */
  42605. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42606. private _getDebugMaterial;
  42607. private _getDebugBoxMesh;
  42608. private _getDebugSphereMesh;
  42609. private _getDebugCylinderMesh;
  42610. private _getDebugMeshMesh;
  42611. private _getDebugMesh;
  42612. /** Releases all resources */
  42613. dispose(): void;
  42614. }
  42615. }
  42616. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42617. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42618. import { Nullable } from "babylonjs/types";
  42619. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42620. import { Scene } from "babylonjs/scene";
  42621. /**
  42622. * Class containing static functions to help procedurally build meshes
  42623. */
  42624. export class LinesBuilder {
  42625. /**
  42626. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42627. * * 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
  42628. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42629. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42630. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42631. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42632. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42633. * * 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
  42634. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42637. * @param name defines the name of the new line system
  42638. * @param options defines the options used to create the line system
  42639. * @param scene defines the hosting scene
  42640. * @returns a new line system mesh
  42641. */
  42642. static CreateLineSystem(name: string, options: {
  42643. lines: Vector3[][];
  42644. updatable?: boolean;
  42645. instance?: Nullable<LinesMesh>;
  42646. colors?: Nullable<Color4[][]>;
  42647. useVertexAlpha?: boolean;
  42648. }, scene: Nullable<Scene>): LinesMesh;
  42649. /**
  42650. * Creates a line mesh
  42651. * 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
  42652. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42653. * * The parameter `points` is an array successive Vector3
  42654. * * 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
  42655. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42656. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42657. * * When updating an instance, remember that only point positions can change, not the number of points
  42658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42659. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42660. * @param name defines the name of the new line system
  42661. * @param options defines the options used to create the line system
  42662. * @param scene defines the hosting scene
  42663. * @returns a new line mesh
  42664. */
  42665. static CreateLines(name: string, options: {
  42666. points: Vector3[];
  42667. updatable?: boolean;
  42668. instance?: Nullable<LinesMesh>;
  42669. colors?: Color4[];
  42670. useVertexAlpha?: boolean;
  42671. }, scene?: Nullable<Scene>): LinesMesh;
  42672. /**
  42673. * Creates a dashed line mesh
  42674. * * 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
  42675. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42676. * * The parameter `points` is an array successive Vector3
  42677. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42678. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42679. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42680. * * 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
  42681. * * When updating an instance, remember that only point positions can change, not the number of points
  42682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42683. * @param name defines the name of the mesh
  42684. * @param options defines the options used to create the mesh
  42685. * @param scene defines the hosting scene
  42686. * @returns the dashed line mesh
  42687. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42688. */
  42689. static CreateDashedLines(name: string, options: {
  42690. points: Vector3[];
  42691. dashSize?: number;
  42692. gapSize?: number;
  42693. dashNb?: number;
  42694. updatable?: boolean;
  42695. instance?: LinesMesh;
  42696. }, scene?: Nullable<Scene>): LinesMesh;
  42697. }
  42698. }
  42699. declare module "babylonjs/Debug/rayHelper" {
  42700. import { Nullable } from "babylonjs/types";
  42701. import { Ray } from "babylonjs/Culling/ray";
  42702. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42703. import { Scene } from "babylonjs/scene";
  42704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42705. import "babylonjs/Meshes/Builders/linesBuilder";
  42706. /**
  42707. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42708. * in order to better appreciate the issue one might have.
  42709. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42710. */
  42711. export class RayHelper {
  42712. /**
  42713. * Defines the ray we are currently tryin to visualize.
  42714. */
  42715. ray: Nullable<Ray>;
  42716. private _renderPoints;
  42717. private _renderLine;
  42718. private _renderFunction;
  42719. private _scene;
  42720. private _updateToMeshFunction;
  42721. private _attachedToMesh;
  42722. private _meshSpaceDirection;
  42723. private _meshSpaceOrigin;
  42724. /**
  42725. * Helper function to create a colored helper in a scene in one line.
  42726. * @param ray Defines the ray we are currently tryin to visualize
  42727. * @param scene Defines the scene the ray is used in
  42728. * @param color Defines the color we want to see the ray in
  42729. * @returns The newly created ray helper.
  42730. */
  42731. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42732. /**
  42733. * Instantiate a new ray helper.
  42734. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42735. * in order to better appreciate the issue one might have.
  42736. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42737. * @param ray Defines the ray we are currently tryin to visualize
  42738. */
  42739. constructor(ray: Ray);
  42740. /**
  42741. * Shows the ray we are willing to debug.
  42742. * @param scene Defines the scene the ray needs to be rendered in
  42743. * @param color Defines the color the ray needs to be rendered in
  42744. */
  42745. show(scene: Scene, color?: Color3): void;
  42746. /**
  42747. * Hides the ray we are debugging.
  42748. */
  42749. hide(): void;
  42750. private _render;
  42751. /**
  42752. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42753. * @param mesh Defines the mesh we want the helper attached to
  42754. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42755. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42756. * @param length Defines the length of the ray
  42757. */
  42758. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42759. /**
  42760. * Detach the ray helper from the mesh it has previously been attached to.
  42761. */
  42762. detachFromMesh(): void;
  42763. private _updateToMesh;
  42764. /**
  42765. * Dispose the helper and release its associated resources.
  42766. */
  42767. dispose(): void;
  42768. }
  42769. }
  42770. declare module "babylonjs/Debug/skeletonViewer" {
  42771. import { Color3 } from "babylonjs/Maths/math";
  42772. import { Scene } from "babylonjs/scene";
  42773. import { Nullable } from "babylonjs/types";
  42774. import { Skeleton } from "babylonjs/Bones/skeleton";
  42775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42776. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42777. /**
  42778. * Class used to render a debug view of a given skeleton
  42779. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42780. */
  42781. export class SkeletonViewer {
  42782. /** defines the skeleton to render */
  42783. skeleton: Skeleton;
  42784. /** defines the mesh attached to the skeleton */
  42785. mesh: AbstractMesh;
  42786. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42787. autoUpdateBonesMatrices: boolean;
  42788. /** defines the rendering group id to use with the viewer */
  42789. renderingGroupId: number;
  42790. /** Gets or sets the color used to render the skeleton */
  42791. color: Color3;
  42792. private _scene;
  42793. private _debugLines;
  42794. private _debugMesh;
  42795. private _isEnabled;
  42796. private _renderFunction;
  42797. private _utilityLayer;
  42798. /**
  42799. * Returns the mesh used to render the bones
  42800. */
  42801. readonly debugMesh: Nullable<LinesMesh>;
  42802. /**
  42803. * Creates a new SkeletonViewer
  42804. * @param skeleton defines the skeleton to render
  42805. * @param mesh defines the mesh attached to the skeleton
  42806. * @param scene defines the hosting scene
  42807. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42808. * @param renderingGroupId defines the rendering group id to use with the viewer
  42809. */
  42810. constructor(
  42811. /** defines the skeleton to render */
  42812. skeleton: Skeleton,
  42813. /** defines the mesh attached to the skeleton */
  42814. mesh: AbstractMesh, scene: Scene,
  42815. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42816. autoUpdateBonesMatrices?: boolean,
  42817. /** defines the rendering group id to use with the viewer */
  42818. renderingGroupId?: number);
  42819. /** Gets or sets a boolean indicating if the viewer is enabled */
  42820. isEnabled: boolean;
  42821. private _getBonePosition;
  42822. private _getLinesForBonesWithLength;
  42823. private _getLinesForBonesNoLength;
  42824. /** Update the viewer to sync with current skeleton state */
  42825. update(): void;
  42826. /** Release associated resources */
  42827. dispose(): void;
  42828. }
  42829. }
  42830. declare module "babylonjs/Debug/index" {
  42831. export * from "babylonjs/Debug/axesViewer";
  42832. export * from "babylonjs/Debug/boneAxesViewer";
  42833. export * from "babylonjs/Debug/debugLayer";
  42834. export * from "babylonjs/Debug/physicsViewer";
  42835. export * from "babylonjs/Debug/rayHelper";
  42836. export * from "babylonjs/Debug/skeletonViewer";
  42837. }
  42838. declare module "babylonjs/Engines/nullEngine" {
  42839. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42840. import { Scene } from "babylonjs/scene";
  42841. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42842. import { Engine } from "babylonjs/Engines/engine";
  42843. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42844. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42845. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42846. import { Effect } from "babylonjs/Materials/effect";
  42847. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42848. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42849. /**
  42850. * Options to create the null engine
  42851. */
  42852. export class NullEngineOptions {
  42853. /**
  42854. * Render width (Default: 512)
  42855. */
  42856. renderWidth: number;
  42857. /**
  42858. * Render height (Default: 256)
  42859. */
  42860. renderHeight: number;
  42861. /**
  42862. * Texture size (Default: 512)
  42863. */
  42864. textureSize: number;
  42865. /**
  42866. * If delta time between frames should be constant
  42867. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42868. */
  42869. deterministicLockstep: boolean;
  42870. /**
  42871. * Maximum about of steps between frames (Default: 4)
  42872. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42873. */
  42874. lockstepMaxSteps: number;
  42875. }
  42876. /**
  42877. * The null engine class provides support for headless version of babylon.js.
  42878. * This can be used in server side scenario or for testing purposes
  42879. */
  42880. export class NullEngine extends Engine {
  42881. private _options;
  42882. /**
  42883. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42884. */
  42885. isDeterministicLockStep(): boolean;
  42886. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42887. getLockstepMaxSteps(): number;
  42888. /**
  42889. * Sets hardware scaling, used to save performance if needed
  42890. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42891. */
  42892. getHardwareScalingLevel(): number;
  42893. constructor(options?: NullEngineOptions);
  42894. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42895. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42896. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42897. getRenderWidth(useScreen?: boolean): number;
  42898. getRenderHeight(useScreen?: boolean): number;
  42899. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42900. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42901. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42902. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42903. bindSamplers(effect: Effect): void;
  42904. enableEffect(effect: Effect): void;
  42905. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42906. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42907. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42908. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42909. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42910. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42911. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42912. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42913. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42914. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42915. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42916. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42917. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42918. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42919. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42920. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42921. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42922. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42923. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42924. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42925. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42926. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42927. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42928. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42929. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42930. bindBuffers(vertexBuffers: {
  42931. [key: string]: VertexBuffer;
  42932. }, indexBuffer: DataBuffer, effect: Effect): void;
  42933. wipeCaches(bruteForce?: boolean): void;
  42934. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42935. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42936. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42937. /** @hidden */
  42938. _createTexture(): WebGLTexture;
  42939. /** @hidden */
  42940. _releaseTexture(texture: InternalTexture): void;
  42941. 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;
  42942. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42943. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42944. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42945. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42946. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42947. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42948. areAllEffectsReady(): boolean;
  42949. /**
  42950. * @hidden
  42951. * Get the current error code of the webGL context
  42952. * @returns the error code
  42953. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42954. */
  42955. getError(): number;
  42956. /** @hidden */
  42957. _getUnpackAlignement(): number;
  42958. /** @hidden */
  42959. _unpackFlipY(value: boolean): void;
  42960. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42961. /**
  42962. * Updates a dynamic vertex buffer.
  42963. * @param vertexBuffer the vertex buffer to update
  42964. * @param data the data used to update the vertex buffer
  42965. * @param byteOffset the byte offset of the data (optional)
  42966. * @param byteLength the byte length of the data (optional)
  42967. */
  42968. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42969. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42970. /** @hidden */
  42971. _bindTexture(channel: number, texture: InternalTexture): void;
  42972. /** @hidden */
  42973. _releaseBuffer(buffer: DataBuffer): boolean;
  42974. releaseEffects(): void;
  42975. displayLoadingUI(): void;
  42976. hideLoadingUI(): void;
  42977. /** @hidden */
  42978. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42979. /** @hidden */
  42980. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42981. /** @hidden */
  42982. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42983. /** @hidden */
  42984. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42985. }
  42986. }
  42987. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42988. import { Nullable, int } from "babylonjs/types";
  42989. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42990. /** @hidden */
  42991. export class _OcclusionDataStorage {
  42992. /** @hidden */
  42993. occlusionInternalRetryCounter: number;
  42994. /** @hidden */
  42995. isOcclusionQueryInProgress: boolean;
  42996. /** @hidden */
  42997. isOccluded: boolean;
  42998. /** @hidden */
  42999. occlusionRetryCount: number;
  43000. /** @hidden */
  43001. occlusionType: number;
  43002. /** @hidden */
  43003. occlusionQueryAlgorithmType: number;
  43004. }
  43005. module "babylonjs/Engines/engine" {
  43006. interface Engine {
  43007. /**
  43008. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43009. * @return the new query
  43010. */
  43011. createQuery(): WebGLQuery;
  43012. /**
  43013. * Delete and release a webGL query
  43014. * @param query defines the query to delete
  43015. * @return the current engine
  43016. */
  43017. deleteQuery(query: WebGLQuery): Engine;
  43018. /**
  43019. * Check if a given query has resolved and got its value
  43020. * @param query defines the query to check
  43021. * @returns true if the query got its value
  43022. */
  43023. isQueryResultAvailable(query: WebGLQuery): boolean;
  43024. /**
  43025. * Gets the value of a given query
  43026. * @param query defines the query to check
  43027. * @returns the value of the query
  43028. */
  43029. getQueryResult(query: WebGLQuery): number;
  43030. /**
  43031. * Initiates an occlusion query
  43032. * @param algorithmType defines the algorithm to use
  43033. * @param query defines the query to use
  43034. * @returns the current engine
  43035. * @see http://doc.babylonjs.com/features/occlusionquery
  43036. */
  43037. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43038. /**
  43039. * Ends an occlusion query
  43040. * @see http://doc.babylonjs.com/features/occlusionquery
  43041. * @param algorithmType defines the algorithm to use
  43042. * @returns the current engine
  43043. */
  43044. endOcclusionQuery(algorithmType: number): Engine;
  43045. /**
  43046. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43047. * Please note that only one query can be issued at a time
  43048. * @returns a time token used to track the time span
  43049. */
  43050. startTimeQuery(): Nullable<_TimeToken>;
  43051. /**
  43052. * Ends a time query
  43053. * @param token defines the token used to measure the time span
  43054. * @returns the time spent (in ns)
  43055. */
  43056. endTimeQuery(token: _TimeToken): int;
  43057. /** @hidden */
  43058. _currentNonTimestampToken: Nullable<_TimeToken>;
  43059. /** @hidden */
  43060. _createTimeQuery(): WebGLQuery;
  43061. /** @hidden */
  43062. _deleteTimeQuery(query: WebGLQuery): void;
  43063. /** @hidden */
  43064. _getGlAlgorithmType(algorithmType: number): number;
  43065. /** @hidden */
  43066. _getTimeQueryResult(query: WebGLQuery): any;
  43067. /** @hidden */
  43068. _getTimeQueryAvailability(query: WebGLQuery): any;
  43069. }
  43070. }
  43071. module "babylonjs/Meshes/abstractMesh" {
  43072. interface AbstractMesh {
  43073. /**
  43074. * Backing filed
  43075. * @hidden
  43076. */
  43077. __occlusionDataStorage: _OcclusionDataStorage;
  43078. /**
  43079. * Access property
  43080. * @hidden
  43081. */
  43082. _occlusionDataStorage: _OcclusionDataStorage;
  43083. /**
  43084. * 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.
  43085. * The default value is -1 which means don't break the query and wait till the result
  43086. * @see http://doc.babylonjs.com/features/occlusionquery
  43087. */
  43088. occlusionRetryCount: number;
  43089. /**
  43090. * 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:
  43091. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43092. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43093. * * 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.
  43094. * @see http://doc.babylonjs.com/features/occlusionquery
  43095. */
  43096. occlusionType: number;
  43097. /**
  43098. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43099. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43100. * * 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.
  43101. * @see http://doc.babylonjs.com/features/occlusionquery
  43102. */
  43103. occlusionQueryAlgorithmType: number;
  43104. /**
  43105. * 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
  43106. * @see http://doc.babylonjs.com/features/occlusionquery
  43107. */
  43108. isOccluded: boolean;
  43109. /**
  43110. * Flag to check the progress status of the query
  43111. * @see http://doc.babylonjs.com/features/occlusionquery
  43112. */
  43113. isOcclusionQueryInProgress: boolean;
  43114. }
  43115. }
  43116. }
  43117. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43118. import { Nullable } from "babylonjs/types";
  43119. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43120. /** @hidden */
  43121. export var _forceTransformFeedbackToBundle: boolean;
  43122. module "babylonjs/Engines/engine" {
  43123. interface Engine {
  43124. /**
  43125. * Creates a webGL transform feedback object
  43126. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43127. * @returns the webGL transform feedback object
  43128. */
  43129. createTransformFeedback(): WebGLTransformFeedback;
  43130. /**
  43131. * Delete a webGL transform feedback object
  43132. * @param value defines the webGL transform feedback object to delete
  43133. */
  43134. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43135. /**
  43136. * Bind a webGL transform feedback object to the webgl context
  43137. * @param value defines the webGL transform feedback object to bind
  43138. */
  43139. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43140. /**
  43141. * Begins a transform feedback operation
  43142. * @param usePoints defines if points or triangles must be used
  43143. */
  43144. beginTransformFeedback(usePoints: boolean): void;
  43145. /**
  43146. * Ends a transform feedback operation
  43147. */
  43148. endTransformFeedback(): void;
  43149. /**
  43150. * Specify the varyings to use with transform feedback
  43151. * @param program defines the associated webGL program
  43152. * @param value defines the list of strings representing the varying names
  43153. */
  43154. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43155. /**
  43156. * Bind a webGL buffer for a transform feedback operation
  43157. * @param value defines the webGL buffer to bind
  43158. */
  43159. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43160. }
  43161. }
  43162. }
  43163. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43164. import { Scene } from "babylonjs/scene";
  43165. import { Engine } from "babylonjs/Engines/engine";
  43166. import { Texture } from "babylonjs/Materials/Textures/texture";
  43167. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43168. import "babylonjs/Engines/Extensions/engine.multiRender";
  43169. /**
  43170. * Creation options of the multi render target texture.
  43171. */
  43172. export interface IMultiRenderTargetOptions {
  43173. /**
  43174. * Define if the texture needs to create mip maps after render.
  43175. */
  43176. generateMipMaps?: boolean;
  43177. /**
  43178. * Define the types of all the draw buffers we want to create
  43179. */
  43180. types?: number[];
  43181. /**
  43182. * Define the sampling modes of all the draw buffers we want to create
  43183. */
  43184. samplingModes?: number[];
  43185. /**
  43186. * Define if a depth buffer is required
  43187. */
  43188. generateDepthBuffer?: boolean;
  43189. /**
  43190. * Define if a stencil buffer is required
  43191. */
  43192. generateStencilBuffer?: boolean;
  43193. /**
  43194. * Define if a depth texture is required instead of a depth buffer
  43195. */
  43196. generateDepthTexture?: boolean;
  43197. /**
  43198. * Define the number of desired draw buffers
  43199. */
  43200. textureCount?: number;
  43201. /**
  43202. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43203. */
  43204. doNotChangeAspectRatio?: boolean;
  43205. /**
  43206. * Define the default type of the buffers we are creating
  43207. */
  43208. defaultType?: number;
  43209. }
  43210. /**
  43211. * A multi render target, like a render target provides the ability to render to a texture.
  43212. * Unlike the render target, it can render to several draw buffers in one draw.
  43213. * This is specially interesting in deferred rendering or for any effects requiring more than
  43214. * just one color from a single pass.
  43215. */
  43216. export class MultiRenderTarget extends RenderTargetTexture {
  43217. private _internalTextures;
  43218. private _textures;
  43219. private _multiRenderTargetOptions;
  43220. /**
  43221. * Get if draw buffers are currently supported by the used hardware and browser.
  43222. */
  43223. readonly isSupported: boolean;
  43224. /**
  43225. * Get the list of textures generated by the multi render target.
  43226. */
  43227. readonly textures: Texture[];
  43228. /**
  43229. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43230. */
  43231. readonly depthTexture: Texture;
  43232. /**
  43233. * Set the wrapping mode on U of all the textures we are rendering to.
  43234. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43235. */
  43236. wrapU: number;
  43237. /**
  43238. * Set the wrapping mode on V of all the textures we are rendering to.
  43239. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43240. */
  43241. wrapV: number;
  43242. /**
  43243. * Instantiate a new multi render target texture.
  43244. * A multi render target, like a render target provides the ability to render to a texture.
  43245. * Unlike the render target, it can render to several draw buffers in one draw.
  43246. * This is specially interesting in deferred rendering or for any effects requiring more than
  43247. * just one color from a single pass.
  43248. * @param name Define the name of the texture
  43249. * @param size Define the size of the buffers to render to
  43250. * @param count Define the number of target we are rendering into
  43251. * @param scene Define the scene the texture belongs to
  43252. * @param options Define the options used to create the multi render target
  43253. */
  43254. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43255. /** @hidden */
  43256. _rebuild(): void;
  43257. private _createInternalTextures;
  43258. private _createTextures;
  43259. /**
  43260. * Define the number of samples used if MSAA is enabled.
  43261. */
  43262. samples: number;
  43263. /**
  43264. * Resize all the textures in the multi render target.
  43265. * Be carrefull as it will recreate all the data in the new texture.
  43266. * @param size Define the new size
  43267. */
  43268. resize(size: any): void;
  43269. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43270. /**
  43271. * Dispose the render targets and their associated resources
  43272. */
  43273. dispose(): void;
  43274. /**
  43275. * Release all the underlying texture used as draw buffers.
  43276. */
  43277. releaseInternalTextures(): void;
  43278. }
  43279. }
  43280. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43281. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43282. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43283. import { Nullable } from "babylonjs/types";
  43284. module "babylonjs/Engines/engine" {
  43285. interface Engine {
  43286. /**
  43287. * Unbind a list of render target textures from the webGL context
  43288. * This is used only when drawBuffer extension or webGL2 are active
  43289. * @param textures defines the render target textures to unbind
  43290. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43291. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43292. */
  43293. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43294. /**
  43295. * Create a multi render target texture
  43296. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43297. * @param size defines the size of the texture
  43298. * @param options defines the creation options
  43299. * @returns the cube texture as an InternalTexture
  43300. */
  43301. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43302. /**
  43303. * Update the sample count for a given multiple render target texture
  43304. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43305. * @param textures defines the textures to update
  43306. * @param samples defines the sample count to set
  43307. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43308. */
  43309. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43310. }
  43311. }
  43312. }
  43313. declare module "babylonjs/Engines/Extensions/index" {
  43314. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43315. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43316. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43317. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43318. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43319. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43320. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43321. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43322. }
  43323. declare module "babylonjs/Engines/index" {
  43324. export * from "babylonjs/Engines/constants";
  43325. export * from "babylonjs/Engines/engine";
  43326. export * from "babylonjs/Engines/engineStore";
  43327. export * from "babylonjs/Engines/nullEngine";
  43328. export * from "babylonjs/Engines/Extensions/index";
  43329. export * from "babylonjs/Engines/IPipelineContext";
  43330. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43331. }
  43332. declare module "babylonjs/Events/clipboardEvents" {
  43333. /**
  43334. * Gather the list of clipboard event types as constants.
  43335. */
  43336. export class ClipboardEventTypes {
  43337. /**
  43338. * The clipboard event is fired when a copy command is active (pressed).
  43339. */
  43340. static readonly COPY: number;
  43341. /**
  43342. * The clipboard event is fired when a cut command is active (pressed).
  43343. */
  43344. static readonly CUT: number;
  43345. /**
  43346. * The clipboard event is fired when a paste command is active (pressed).
  43347. */
  43348. static readonly PASTE: number;
  43349. }
  43350. /**
  43351. * This class is used to store clipboard related info for the onClipboardObservable event.
  43352. */
  43353. export class ClipboardInfo {
  43354. /**
  43355. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43356. */
  43357. type: number;
  43358. /**
  43359. * Defines the related dom event
  43360. */
  43361. event: ClipboardEvent;
  43362. /**
  43363. *Creates an instance of ClipboardInfo.
  43364. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43365. * @param event Defines the related dom event
  43366. */
  43367. constructor(
  43368. /**
  43369. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43370. */
  43371. type: number,
  43372. /**
  43373. * Defines the related dom event
  43374. */
  43375. event: ClipboardEvent);
  43376. /**
  43377. * Get the clipboard event's type from the keycode.
  43378. * @param keyCode Defines the keyCode for the current keyboard event.
  43379. * @return {number}
  43380. */
  43381. static GetTypeFromCharacter(keyCode: number): number;
  43382. }
  43383. }
  43384. declare module "babylonjs/Events/index" {
  43385. export * from "babylonjs/Events/keyboardEvents";
  43386. export * from "babylonjs/Events/pointerEvents";
  43387. export * from "babylonjs/Events/clipboardEvents";
  43388. }
  43389. declare module "babylonjs/Loading/sceneLoader" {
  43390. import { Observable } from "babylonjs/Misc/observable";
  43391. import { Nullable } from "babylonjs/types";
  43392. import { Scene } from "babylonjs/scene";
  43393. import { Engine } from "babylonjs/Engines/engine";
  43394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43395. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43396. import { AssetContainer } from "babylonjs/assetContainer";
  43397. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43398. import { Skeleton } from "babylonjs/Bones/skeleton";
  43399. /**
  43400. * Class used to represent data loading progression
  43401. */
  43402. export class SceneLoaderProgressEvent {
  43403. /** defines if data length to load can be evaluated */
  43404. readonly lengthComputable: boolean;
  43405. /** defines the loaded data length */
  43406. readonly loaded: number;
  43407. /** defines the data length to load */
  43408. readonly total: number;
  43409. /**
  43410. * Create a new progress event
  43411. * @param lengthComputable defines if data length to load can be evaluated
  43412. * @param loaded defines the loaded data length
  43413. * @param total defines the data length to load
  43414. */
  43415. constructor(
  43416. /** defines if data length to load can be evaluated */
  43417. lengthComputable: boolean,
  43418. /** defines the loaded data length */
  43419. loaded: number,
  43420. /** defines the data length to load */
  43421. total: number);
  43422. /**
  43423. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43424. * @param event defines the source event
  43425. * @returns a new SceneLoaderProgressEvent
  43426. */
  43427. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43428. }
  43429. /**
  43430. * Interface used by SceneLoader plugins to define supported file extensions
  43431. */
  43432. export interface ISceneLoaderPluginExtensions {
  43433. /**
  43434. * Defines the list of supported extensions
  43435. */
  43436. [extension: string]: {
  43437. isBinary: boolean;
  43438. };
  43439. }
  43440. /**
  43441. * Interface used by SceneLoader plugin factory
  43442. */
  43443. export interface ISceneLoaderPluginFactory {
  43444. /**
  43445. * Defines the name of the factory
  43446. */
  43447. name: string;
  43448. /**
  43449. * Function called to create a new plugin
  43450. * @return the new plugin
  43451. */
  43452. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43453. /**
  43454. * Boolean indicating if the plugin can direct load specific data
  43455. */
  43456. canDirectLoad?: (data: string) => boolean;
  43457. }
  43458. /**
  43459. * Interface used to define a SceneLoader plugin
  43460. */
  43461. export interface ISceneLoaderPlugin {
  43462. /**
  43463. * The friendly name of this plugin.
  43464. */
  43465. name: string;
  43466. /**
  43467. * The file extensions supported by this plugin.
  43468. */
  43469. extensions: string | ISceneLoaderPluginExtensions;
  43470. /**
  43471. * Import meshes into a scene.
  43472. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43473. * @param scene The scene to import into
  43474. * @param data The data to import
  43475. * @param rootUrl The root url for scene and resources
  43476. * @param meshes The meshes array to import into
  43477. * @param particleSystems The particle systems array to import into
  43478. * @param skeletons The skeletons array to import into
  43479. * @param onError The callback when import fails
  43480. * @returns True if successful or false otherwise
  43481. */
  43482. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43483. /**
  43484. * Load into a scene.
  43485. * @param scene The scene to load into
  43486. * @param data The data to import
  43487. * @param rootUrl The root url for scene and resources
  43488. * @param onError The callback when import fails
  43489. * @returns true if successful or false otherwise
  43490. */
  43491. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43492. /**
  43493. * The callback that returns true if the data can be directly loaded.
  43494. */
  43495. canDirectLoad?: (data: string) => boolean;
  43496. /**
  43497. * The callback that allows custom handling of the root url based on the response url.
  43498. */
  43499. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43500. /**
  43501. * Load into an asset container.
  43502. * @param scene The scene to load into
  43503. * @param data The data to import
  43504. * @param rootUrl The root url for scene and resources
  43505. * @param onError The callback when import fails
  43506. * @returns The loaded asset container
  43507. */
  43508. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43509. }
  43510. /**
  43511. * Interface used to define an async SceneLoader plugin
  43512. */
  43513. export interface ISceneLoaderPluginAsync {
  43514. /**
  43515. * The friendly name of this plugin.
  43516. */
  43517. name: string;
  43518. /**
  43519. * The file extensions supported by this plugin.
  43520. */
  43521. extensions: string | ISceneLoaderPluginExtensions;
  43522. /**
  43523. * Import meshes into a scene.
  43524. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43525. * @param scene The scene to import into
  43526. * @param data The data to import
  43527. * @param rootUrl The root url for scene and resources
  43528. * @param onProgress The callback when the load progresses
  43529. * @param fileName Defines the name of the file to load
  43530. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43531. */
  43532. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43533. meshes: AbstractMesh[];
  43534. particleSystems: IParticleSystem[];
  43535. skeletons: Skeleton[];
  43536. animationGroups: AnimationGroup[];
  43537. }>;
  43538. /**
  43539. * Load into a scene.
  43540. * @param scene The scene to load into
  43541. * @param data The data to import
  43542. * @param rootUrl The root url for scene and resources
  43543. * @param onProgress The callback when the load progresses
  43544. * @param fileName Defines the name of the file to load
  43545. * @returns Nothing
  43546. */
  43547. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43548. /**
  43549. * The callback that returns true if the data can be directly loaded.
  43550. */
  43551. canDirectLoad?: (data: string) => boolean;
  43552. /**
  43553. * The callback that allows custom handling of the root url based on the response url.
  43554. */
  43555. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43556. /**
  43557. * Load into an asset container.
  43558. * @param scene The scene to load into
  43559. * @param data The data to import
  43560. * @param rootUrl The root url for scene and resources
  43561. * @param onProgress The callback when the load progresses
  43562. * @param fileName Defines the name of the file to load
  43563. * @returns The loaded asset container
  43564. */
  43565. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43566. }
  43567. /**
  43568. * Class used to load scene from various file formats using registered plugins
  43569. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43570. */
  43571. export class SceneLoader {
  43572. /**
  43573. * No logging while loading
  43574. */
  43575. static readonly NO_LOGGING: number;
  43576. /**
  43577. * Minimal logging while loading
  43578. */
  43579. static readonly MINIMAL_LOGGING: number;
  43580. /**
  43581. * Summary logging while loading
  43582. */
  43583. static readonly SUMMARY_LOGGING: number;
  43584. /**
  43585. * Detailled logging while loading
  43586. */
  43587. static readonly DETAILED_LOGGING: number;
  43588. /**
  43589. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43590. */
  43591. static ForceFullSceneLoadingForIncremental: boolean;
  43592. /**
  43593. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43594. */
  43595. static ShowLoadingScreen: boolean;
  43596. /**
  43597. * Defines the current logging level (while loading the scene)
  43598. * @ignorenaming
  43599. */
  43600. static loggingLevel: number;
  43601. /**
  43602. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43603. */
  43604. static CleanBoneMatrixWeights: boolean;
  43605. /**
  43606. * Event raised when a plugin is used to load a scene
  43607. */
  43608. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43609. private static _registeredPlugins;
  43610. private static _getDefaultPlugin;
  43611. private static _getPluginForExtension;
  43612. private static _getPluginForDirectLoad;
  43613. private static _getPluginForFilename;
  43614. private static _getDirectLoad;
  43615. private static _loadData;
  43616. private static _getFileInfo;
  43617. /**
  43618. * Gets a plugin that can load the given extension
  43619. * @param extension defines the extension to load
  43620. * @returns a plugin or null if none works
  43621. */
  43622. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43623. /**
  43624. * Gets a boolean indicating that the given extension can be loaded
  43625. * @param extension defines the extension to load
  43626. * @returns true if the extension is supported
  43627. */
  43628. static IsPluginForExtensionAvailable(extension: string): boolean;
  43629. /**
  43630. * Adds a new plugin to the list of registered plugins
  43631. * @param plugin defines the plugin to add
  43632. */
  43633. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43634. /**
  43635. * Import meshes into a scene
  43636. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43637. * @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)
  43638. * @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)
  43639. * @param scene the instance of BABYLON.Scene to append to
  43640. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43641. * @param onProgress a callback with a progress event for each file being loaded
  43642. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43643. * @param pluginExtension the extension used to determine the plugin
  43644. * @returns The loaded plugin
  43645. */
  43646. 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>;
  43647. /**
  43648. * Import meshes into a scene
  43649. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43650. * @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)
  43651. * @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)
  43652. * @param scene the instance of BABYLON.Scene to append to
  43653. * @param onProgress a callback with a progress event for each file being loaded
  43654. * @param pluginExtension the extension used to determine the plugin
  43655. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43656. */
  43657. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43658. meshes: AbstractMesh[];
  43659. particleSystems: IParticleSystem[];
  43660. skeletons: Skeleton[];
  43661. animationGroups: AnimationGroup[];
  43662. }>;
  43663. /**
  43664. * Load a scene
  43665. * @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)
  43666. * @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)
  43667. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43668. * @param onSuccess a callback with the scene when import succeeds
  43669. * @param onProgress a callback with a progress event for each file being loaded
  43670. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43671. * @param pluginExtension the extension used to determine the plugin
  43672. * @returns The loaded plugin
  43673. */
  43674. 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>;
  43675. /**
  43676. * Load a scene
  43677. * @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)
  43678. * @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)
  43679. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43680. * @param onProgress a callback with a progress event for each file being loaded
  43681. * @param pluginExtension the extension used to determine the plugin
  43682. * @returns The loaded scene
  43683. */
  43684. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43685. /**
  43686. * Append a scene
  43687. * @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)
  43688. * @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)
  43689. * @param scene is the instance of BABYLON.Scene to append to
  43690. * @param onSuccess a callback with the scene when import succeeds
  43691. * @param onProgress a callback with a progress event for each file being loaded
  43692. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43693. * @param pluginExtension the extension used to determine the plugin
  43694. * @returns The loaded plugin
  43695. */
  43696. 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>;
  43697. /**
  43698. * Append a scene
  43699. * @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)
  43700. * @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)
  43701. * @param scene is the instance of BABYLON.Scene to append to
  43702. * @param onProgress a callback with a progress event for each file being loaded
  43703. * @param pluginExtension the extension used to determine the plugin
  43704. * @returns The given scene
  43705. */
  43706. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43707. /**
  43708. * Load a scene into an asset container
  43709. * @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)
  43710. * @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)
  43711. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43712. * @param onSuccess a callback with the scene when import succeeds
  43713. * @param onProgress a callback with a progress event for each file being loaded
  43714. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43715. * @param pluginExtension the extension used to determine the plugin
  43716. * @returns The loaded plugin
  43717. */
  43718. 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>;
  43719. /**
  43720. * Load a scene into an asset container
  43721. * @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)
  43722. * @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)
  43723. * @param scene is the instance of Scene to append to
  43724. * @param onProgress a callback with a progress event for each file being loaded
  43725. * @param pluginExtension the extension used to determine the plugin
  43726. * @returns The loaded asset container
  43727. */
  43728. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43729. }
  43730. }
  43731. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43732. import { Scene } from "babylonjs/scene";
  43733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43734. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43735. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43736. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43737. /**
  43738. * Google Daydream controller
  43739. */
  43740. export class DaydreamController extends WebVRController {
  43741. /**
  43742. * Base Url for the controller model.
  43743. */
  43744. static MODEL_BASE_URL: string;
  43745. /**
  43746. * File name for the controller model.
  43747. */
  43748. static MODEL_FILENAME: string;
  43749. /**
  43750. * Gamepad Id prefix used to identify Daydream Controller.
  43751. */
  43752. static readonly GAMEPAD_ID_PREFIX: string;
  43753. /**
  43754. * Creates a new DaydreamController from a gamepad
  43755. * @param vrGamepad the gamepad that the controller should be created from
  43756. */
  43757. constructor(vrGamepad: any);
  43758. /**
  43759. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43760. * @param scene scene in which to add meshes
  43761. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43762. */
  43763. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43764. /**
  43765. * Called once for each button that changed state since the last frame
  43766. * @param buttonIdx Which button index changed
  43767. * @param state New state of the button
  43768. * @param changes Which properties on the state changed since last frame
  43769. */
  43770. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43771. }
  43772. }
  43773. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43774. import { Scene } from "babylonjs/scene";
  43775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43776. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43777. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43778. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43779. /**
  43780. * Gear VR Controller
  43781. */
  43782. export class GearVRController extends WebVRController {
  43783. /**
  43784. * Base Url for the controller model.
  43785. */
  43786. static MODEL_BASE_URL: string;
  43787. /**
  43788. * File name for the controller model.
  43789. */
  43790. static MODEL_FILENAME: string;
  43791. /**
  43792. * Gamepad Id prefix used to identify this controller.
  43793. */
  43794. static readonly GAMEPAD_ID_PREFIX: string;
  43795. private readonly _buttonIndexToObservableNameMap;
  43796. /**
  43797. * Creates a new GearVRController from a gamepad
  43798. * @param vrGamepad the gamepad that the controller should be created from
  43799. */
  43800. constructor(vrGamepad: any);
  43801. /**
  43802. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43803. * @param scene scene in which to add meshes
  43804. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43805. */
  43806. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43807. /**
  43808. * Called once for each button that changed state since the last frame
  43809. * @param buttonIdx Which button index changed
  43810. * @param state New state of the button
  43811. * @param changes Which properties on the state changed since last frame
  43812. */
  43813. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43814. }
  43815. }
  43816. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43817. import { Scene } from "babylonjs/scene";
  43818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43819. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43820. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43821. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43822. /**
  43823. * Generic Controller
  43824. */
  43825. export class GenericController extends WebVRController {
  43826. /**
  43827. * Base Url for the controller model.
  43828. */
  43829. static readonly MODEL_BASE_URL: string;
  43830. /**
  43831. * File name for the controller model.
  43832. */
  43833. static readonly MODEL_FILENAME: string;
  43834. /**
  43835. * Creates a new GenericController from a gamepad
  43836. * @param vrGamepad the gamepad that the controller should be created from
  43837. */
  43838. constructor(vrGamepad: any);
  43839. /**
  43840. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43841. * @param scene scene in which to add meshes
  43842. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43843. */
  43844. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43845. /**
  43846. * Called once for each button that changed state since the last frame
  43847. * @param buttonIdx Which button index changed
  43848. * @param state New state of the button
  43849. * @param changes Which properties on the state changed since last frame
  43850. */
  43851. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43852. }
  43853. }
  43854. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43855. import { Observable } from "babylonjs/Misc/observable";
  43856. import { Scene } from "babylonjs/scene";
  43857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43858. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43859. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43860. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43861. /**
  43862. * Oculus Touch Controller
  43863. */
  43864. export class OculusTouchController extends WebVRController {
  43865. /**
  43866. * Base Url for the controller model.
  43867. */
  43868. static MODEL_BASE_URL: string;
  43869. /**
  43870. * File name for the left controller model.
  43871. */
  43872. static MODEL_LEFT_FILENAME: string;
  43873. /**
  43874. * File name for the right controller model.
  43875. */
  43876. static MODEL_RIGHT_FILENAME: string;
  43877. /**
  43878. * Fired when the secondary trigger on this controller is modified
  43879. */
  43880. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43881. /**
  43882. * Fired when the thumb rest on this controller is modified
  43883. */
  43884. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43885. /**
  43886. * Creates a new OculusTouchController from a gamepad
  43887. * @param vrGamepad the gamepad that the controller should be created from
  43888. */
  43889. constructor(vrGamepad: any);
  43890. /**
  43891. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43892. * @param scene scene in which to add meshes
  43893. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43894. */
  43895. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43896. /**
  43897. * Fired when the A button on this controller is modified
  43898. */
  43899. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43900. /**
  43901. * Fired when the B button on this controller is modified
  43902. */
  43903. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43904. /**
  43905. * Fired when the X button on this controller is modified
  43906. */
  43907. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43908. /**
  43909. * Fired when the Y button on this controller is modified
  43910. */
  43911. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43912. /**
  43913. * Called once for each button that changed state since the last frame
  43914. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43915. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43916. * 2) secondary trigger (same)
  43917. * 3) A (right) X (left), touch, pressed = value
  43918. * 4) B / Y
  43919. * 5) thumb rest
  43920. * @param buttonIdx Which button index changed
  43921. * @param state New state of the button
  43922. * @param changes Which properties on the state changed since last frame
  43923. */
  43924. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43925. }
  43926. }
  43927. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43928. import { Scene } from "babylonjs/scene";
  43929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43930. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43931. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43932. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43933. import { Observable } from "babylonjs/Misc/observable";
  43934. /**
  43935. * Vive Controller
  43936. */
  43937. export class ViveController extends WebVRController {
  43938. /**
  43939. * Base Url for the controller model.
  43940. */
  43941. static MODEL_BASE_URL: string;
  43942. /**
  43943. * File name for the controller model.
  43944. */
  43945. static MODEL_FILENAME: string;
  43946. /**
  43947. * Creates a new ViveController from a gamepad
  43948. * @param vrGamepad the gamepad that the controller should be created from
  43949. */
  43950. constructor(vrGamepad: any);
  43951. /**
  43952. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43953. * @param scene scene in which to add meshes
  43954. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43955. */
  43956. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43957. /**
  43958. * Fired when the left button on this controller is modified
  43959. */
  43960. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43961. /**
  43962. * Fired when the right button on this controller is modified
  43963. */
  43964. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43965. /**
  43966. * Fired when the menu button on this controller is modified
  43967. */
  43968. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43969. /**
  43970. * Called once for each button that changed state since the last frame
  43971. * Vive mapping:
  43972. * 0: touchpad
  43973. * 1: trigger
  43974. * 2: left AND right buttons
  43975. * 3: menu button
  43976. * @param buttonIdx Which button index changed
  43977. * @param state New state of the button
  43978. * @param changes Which properties on the state changed since last frame
  43979. */
  43980. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43981. }
  43982. }
  43983. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43984. import { Observable } from "babylonjs/Misc/observable";
  43985. import { Scene } from "babylonjs/scene";
  43986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43987. import { Ray } from "babylonjs/Culling/ray";
  43988. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43989. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43990. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43991. /**
  43992. * Defines the WindowsMotionController object that the state of the windows motion controller
  43993. */
  43994. export class WindowsMotionController extends WebVRController {
  43995. /**
  43996. * The base url used to load the left and right controller models
  43997. */
  43998. static MODEL_BASE_URL: string;
  43999. /**
  44000. * The name of the left controller model file
  44001. */
  44002. static MODEL_LEFT_FILENAME: string;
  44003. /**
  44004. * The name of the right controller model file
  44005. */
  44006. static MODEL_RIGHT_FILENAME: string;
  44007. /**
  44008. * The controller name prefix for this controller type
  44009. */
  44010. static readonly GAMEPAD_ID_PREFIX: string;
  44011. /**
  44012. * The controller id pattern for this controller type
  44013. */
  44014. private static readonly GAMEPAD_ID_PATTERN;
  44015. private _loadedMeshInfo;
  44016. private readonly _mapping;
  44017. /**
  44018. * Fired when the trackpad on this controller is clicked
  44019. */
  44020. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44021. /**
  44022. * Fired when the trackpad on this controller is modified
  44023. */
  44024. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44025. /**
  44026. * The current x and y values of this controller's trackpad
  44027. */
  44028. trackpad: StickValues;
  44029. /**
  44030. * Creates a new WindowsMotionController from a gamepad
  44031. * @param vrGamepad the gamepad that the controller should be created from
  44032. */
  44033. constructor(vrGamepad: any);
  44034. /**
  44035. * Fired when the trigger on this controller is modified
  44036. */
  44037. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44038. /**
  44039. * Fired when the menu button on this controller is modified
  44040. */
  44041. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44042. /**
  44043. * Fired when the grip button on this controller is modified
  44044. */
  44045. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44046. /**
  44047. * Fired when the thumbstick button on this controller is modified
  44048. */
  44049. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44050. /**
  44051. * Fired when the touchpad button on this controller is modified
  44052. */
  44053. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44054. /**
  44055. * Fired when the touchpad values on this controller are modified
  44056. */
  44057. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44058. private _updateTrackpad;
  44059. /**
  44060. * Called once per frame by the engine.
  44061. */
  44062. update(): void;
  44063. /**
  44064. * Called once for each button that changed state since the last frame
  44065. * @param buttonIdx Which button index changed
  44066. * @param state New state of the button
  44067. * @param changes Which properties on the state changed since last frame
  44068. */
  44069. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44070. /**
  44071. * Moves the buttons on the controller mesh based on their current state
  44072. * @param buttonName the name of the button to move
  44073. * @param buttonValue the value of the button which determines the buttons new position
  44074. */
  44075. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44076. /**
  44077. * Moves the axis on the controller mesh based on its current state
  44078. * @param axis the index of the axis
  44079. * @param axisValue the value of the axis which determines the meshes new position
  44080. * @hidden
  44081. */
  44082. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44083. /**
  44084. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44085. * @param scene scene in which to add meshes
  44086. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44087. */
  44088. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44089. /**
  44090. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44091. * can be transformed by button presses and axes values, based on this._mapping.
  44092. *
  44093. * @param scene scene in which the meshes exist
  44094. * @param meshes list of meshes that make up the controller model to process
  44095. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44096. */
  44097. private processModel;
  44098. private createMeshInfo;
  44099. /**
  44100. * Gets the ray of the controller in the direction the controller is pointing
  44101. * @param length the length the resulting ray should be
  44102. * @returns a ray in the direction the controller is pointing
  44103. */
  44104. getForwardRay(length?: number): Ray;
  44105. /**
  44106. * Disposes of the controller
  44107. */
  44108. dispose(): void;
  44109. }
  44110. }
  44111. declare module "babylonjs/Gamepads/Controllers/index" {
  44112. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44113. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44114. export * from "babylonjs/Gamepads/Controllers/genericController";
  44115. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44116. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44117. export * from "babylonjs/Gamepads/Controllers/viveController";
  44118. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44119. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44120. }
  44121. declare module "babylonjs/Gamepads/index" {
  44122. export * from "babylonjs/Gamepads/Controllers/index";
  44123. export * from "babylonjs/Gamepads/gamepad";
  44124. export * from "babylonjs/Gamepads/gamepadManager";
  44125. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44126. export * from "babylonjs/Gamepads/xboxGamepad";
  44127. }
  44128. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44129. import { Observable } from "babylonjs/Misc/observable";
  44130. import { Nullable } from "babylonjs/types";
  44131. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44133. import { Mesh } from "babylonjs/Meshes/mesh";
  44134. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44135. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44136. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44137. /**
  44138. * Single axis scale gizmo
  44139. */
  44140. export class AxisScaleGizmo extends Gizmo {
  44141. private _coloredMaterial;
  44142. /**
  44143. * Drag behavior responsible for the gizmos dragging interactions
  44144. */
  44145. dragBehavior: PointerDragBehavior;
  44146. private _pointerObserver;
  44147. /**
  44148. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44149. */
  44150. snapDistance: number;
  44151. /**
  44152. * Event that fires each time the gizmo snaps to a new location.
  44153. * * snapDistance is the the change in distance
  44154. */
  44155. onSnapObservable: Observable<{
  44156. snapDistance: number;
  44157. }>;
  44158. /**
  44159. * If the scaling operation should be done on all axis (default: false)
  44160. */
  44161. uniformScaling: boolean;
  44162. /**
  44163. * Creates an AxisScaleGizmo
  44164. * @param gizmoLayer The utility layer the gizmo will be added to
  44165. * @param dragAxis The axis which the gizmo will be able to scale on
  44166. * @param color The color of the gizmo
  44167. */
  44168. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44169. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44170. /**
  44171. * Disposes of the gizmo
  44172. */
  44173. dispose(): void;
  44174. /**
  44175. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44176. * @param mesh The mesh to replace the default mesh of the gizmo
  44177. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44178. */
  44179. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44180. }
  44181. }
  44182. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44183. import { Observable } from "babylonjs/Misc/observable";
  44184. import { Nullable } from "babylonjs/types";
  44185. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44187. import { Mesh } from "babylonjs/Meshes/mesh";
  44188. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44189. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44190. import "babylonjs/Meshes/Builders/boxBuilder";
  44191. /**
  44192. * Bounding box gizmo
  44193. */
  44194. export class BoundingBoxGizmo extends Gizmo {
  44195. private _lineBoundingBox;
  44196. private _rotateSpheresParent;
  44197. private _scaleBoxesParent;
  44198. private _boundingDimensions;
  44199. private _renderObserver;
  44200. private _pointerObserver;
  44201. private _scaleDragSpeed;
  44202. private _tmpQuaternion;
  44203. private _tmpVector;
  44204. private _tmpRotationMatrix;
  44205. /**
  44206. * 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)
  44207. */
  44208. ignoreChildren: boolean;
  44209. /**
  44210. * 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)
  44211. */
  44212. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44213. /**
  44214. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44215. */
  44216. rotationSphereSize: number;
  44217. /**
  44218. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44219. */
  44220. scaleBoxSize: number;
  44221. /**
  44222. * 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)
  44223. */
  44224. fixedDragMeshScreenSize: boolean;
  44225. /**
  44226. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44227. */
  44228. fixedDragMeshScreenSizeDistanceFactor: number;
  44229. /**
  44230. * Fired when a rotation sphere or scale box is dragged
  44231. */
  44232. onDragStartObservable: Observable<{}>;
  44233. /**
  44234. * Fired when a scale box is dragged
  44235. */
  44236. onScaleBoxDragObservable: Observable<{}>;
  44237. /**
  44238. * Fired when a scale box drag is ended
  44239. */
  44240. onScaleBoxDragEndObservable: Observable<{}>;
  44241. /**
  44242. * Fired when a rotation sphere is dragged
  44243. */
  44244. onRotationSphereDragObservable: Observable<{}>;
  44245. /**
  44246. * Fired when a rotation sphere drag is ended
  44247. */
  44248. onRotationSphereDragEndObservable: Observable<{}>;
  44249. /**
  44250. * 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)
  44251. */
  44252. scalePivot: Nullable<Vector3>;
  44253. /**
  44254. * Mesh used as a pivot to rotate the attached mesh
  44255. */
  44256. private _anchorMesh;
  44257. private _existingMeshScale;
  44258. private _dragMesh;
  44259. private pointerDragBehavior;
  44260. private coloredMaterial;
  44261. private hoverColoredMaterial;
  44262. /**
  44263. * Sets the color of the bounding box gizmo
  44264. * @param color the color to set
  44265. */
  44266. setColor(color: Color3): void;
  44267. /**
  44268. * Creates an BoundingBoxGizmo
  44269. * @param gizmoLayer The utility layer the gizmo will be added to
  44270. * @param color The color of the gizmo
  44271. */
  44272. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44273. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44274. private _selectNode;
  44275. /**
  44276. * Updates the bounding box information for the Gizmo
  44277. */
  44278. updateBoundingBox(): void;
  44279. private _updateRotationSpheres;
  44280. private _updateScaleBoxes;
  44281. /**
  44282. * Enables rotation on the specified axis and disables rotation on the others
  44283. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44284. */
  44285. setEnabledRotationAxis(axis: string): void;
  44286. /**
  44287. * Enables/disables scaling
  44288. * @param enable if scaling should be enabled
  44289. */
  44290. setEnabledScaling(enable: boolean): void;
  44291. private _updateDummy;
  44292. /**
  44293. * Enables a pointer drag behavior on the bounding box of the gizmo
  44294. */
  44295. enableDragBehavior(): void;
  44296. /**
  44297. * Disposes of the gizmo
  44298. */
  44299. dispose(): void;
  44300. /**
  44301. * 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)
  44302. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44303. * @returns the bounding box mesh with the passed in mesh as a child
  44304. */
  44305. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44306. /**
  44307. * CustomMeshes are not supported by this gizmo
  44308. * @param mesh The mesh to replace the default mesh of the gizmo
  44309. */
  44310. setCustomMesh(mesh: Mesh): void;
  44311. }
  44312. }
  44313. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44314. import { Observable } from "babylonjs/Misc/observable";
  44315. import { Nullable } from "babylonjs/types";
  44316. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44318. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44319. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44320. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44321. import "babylonjs/Meshes/Builders/linesBuilder";
  44322. /**
  44323. * Single plane rotation gizmo
  44324. */
  44325. export class PlaneRotationGizmo extends Gizmo {
  44326. /**
  44327. * Drag behavior responsible for the gizmos dragging interactions
  44328. */
  44329. dragBehavior: PointerDragBehavior;
  44330. private _pointerObserver;
  44331. /**
  44332. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44333. */
  44334. snapDistance: number;
  44335. /**
  44336. * Event that fires each time the gizmo snaps to a new location.
  44337. * * snapDistance is the the change in distance
  44338. */
  44339. onSnapObservable: Observable<{
  44340. snapDistance: number;
  44341. }>;
  44342. /**
  44343. * Creates a PlaneRotationGizmo
  44344. * @param gizmoLayer The utility layer the gizmo will be added to
  44345. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44346. * @param color The color of the gizmo
  44347. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44348. */
  44349. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44350. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44351. /**
  44352. * Disposes of the gizmo
  44353. */
  44354. dispose(): void;
  44355. }
  44356. }
  44357. declare module "babylonjs/Gizmos/rotationGizmo" {
  44358. import { Observable } from "babylonjs/Misc/observable";
  44359. import { Nullable } from "babylonjs/types";
  44360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44361. import { Mesh } from "babylonjs/Meshes/mesh";
  44362. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44363. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44364. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44365. /**
  44366. * Gizmo that enables rotating a mesh along 3 axis
  44367. */
  44368. export class RotationGizmo extends Gizmo {
  44369. /**
  44370. * Internal gizmo used for interactions on the x axis
  44371. */
  44372. xGizmo: PlaneRotationGizmo;
  44373. /**
  44374. * Internal gizmo used for interactions on the y axis
  44375. */
  44376. yGizmo: PlaneRotationGizmo;
  44377. /**
  44378. * Internal gizmo used for interactions on the z axis
  44379. */
  44380. zGizmo: PlaneRotationGizmo;
  44381. /** Fires an event when any of it's sub gizmos are dragged */
  44382. onDragStartObservable: Observable<{}>;
  44383. /** Fires an event when any of it's sub gizmos are released from dragging */
  44384. onDragEndObservable: Observable<{}>;
  44385. attachedMesh: Nullable<AbstractMesh>;
  44386. /**
  44387. * Creates a RotationGizmo
  44388. * @param gizmoLayer The utility layer the gizmo will be added to
  44389. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44390. */
  44391. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44392. updateGizmoRotationToMatchAttachedMesh: boolean;
  44393. /**
  44394. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44395. */
  44396. snapDistance: number;
  44397. /**
  44398. * Ratio for the scale of the gizmo (Default: 1)
  44399. */
  44400. scaleRatio: number;
  44401. /**
  44402. * Disposes of the gizmo
  44403. */
  44404. dispose(): void;
  44405. /**
  44406. * CustomMeshes are not supported by this gizmo
  44407. * @param mesh The mesh to replace the default mesh of the gizmo
  44408. */
  44409. setCustomMesh(mesh: Mesh): void;
  44410. }
  44411. }
  44412. declare module "babylonjs/Gizmos/positionGizmo" {
  44413. import { Observable } from "babylonjs/Misc/observable";
  44414. import { Nullable } from "babylonjs/types";
  44415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44416. import { Mesh } from "babylonjs/Meshes/mesh";
  44417. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44418. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44419. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44420. /**
  44421. * Gizmo that enables dragging a mesh along 3 axis
  44422. */
  44423. export class PositionGizmo extends Gizmo {
  44424. /**
  44425. * Internal gizmo used for interactions on the x axis
  44426. */
  44427. xGizmo: AxisDragGizmo;
  44428. /**
  44429. * Internal gizmo used for interactions on the y axis
  44430. */
  44431. yGizmo: AxisDragGizmo;
  44432. /**
  44433. * Internal gizmo used for interactions on the z axis
  44434. */
  44435. zGizmo: AxisDragGizmo;
  44436. /** Fires an event when any of it's sub gizmos are dragged */
  44437. onDragStartObservable: Observable<{}>;
  44438. /** Fires an event when any of it's sub gizmos are released from dragging */
  44439. onDragEndObservable: Observable<{}>;
  44440. attachedMesh: Nullable<AbstractMesh>;
  44441. /**
  44442. * Creates a PositionGizmo
  44443. * @param gizmoLayer The utility layer the gizmo will be added to
  44444. */
  44445. constructor(gizmoLayer?: UtilityLayerRenderer);
  44446. updateGizmoRotationToMatchAttachedMesh: boolean;
  44447. /**
  44448. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44449. */
  44450. snapDistance: number;
  44451. /**
  44452. * Ratio for the scale of the gizmo (Default: 1)
  44453. */
  44454. scaleRatio: number;
  44455. /**
  44456. * Disposes of the gizmo
  44457. */
  44458. dispose(): void;
  44459. /**
  44460. * CustomMeshes are not supported by this gizmo
  44461. * @param mesh The mesh to replace the default mesh of the gizmo
  44462. */
  44463. setCustomMesh(mesh: Mesh): void;
  44464. }
  44465. }
  44466. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44467. import { Scene } from "babylonjs/scene";
  44468. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44469. import { Mesh } from "babylonjs/Meshes/mesh";
  44470. import { Nullable } from "babylonjs/types";
  44471. /**
  44472. * Class containing static functions to help procedurally build meshes
  44473. */
  44474. export class PolyhedronBuilder {
  44475. /**
  44476. * Creates a polyhedron mesh
  44477. * * 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
  44478. * * The parameter `size` (positive float, default 1) sets the polygon size
  44479. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44480. * * 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`
  44481. * * 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
  44482. * * 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)`)
  44483. * * 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
  44484. * * 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
  44485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44488. * @param name defines the name of the mesh
  44489. * @param options defines the options used to create the mesh
  44490. * @param scene defines the hosting scene
  44491. * @returns the polyhedron mesh
  44492. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44493. */
  44494. static CreatePolyhedron(name: string, options: {
  44495. type?: number;
  44496. size?: number;
  44497. sizeX?: number;
  44498. sizeY?: number;
  44499. sizeZ?: number;
  44500. custom?: any;
  44501. faceUV?: Vector4[];
  44502. faceColors?: Color4[];
  44503. flat?: boolean;
  44504. updatable?: boolean;
  44505. sideOrientation?: number;
  44506. frontUVs?: Vector4;
  44507. backUVs?: Vector4;
  44508. }, scene?: Nullable<Scene>): Mesh;
  44509. }
  44510. }
  44511. declare module "babylonjs/Gizmos/scaleGizmo" {
  44512. import { Observable } from "babylonjs/Misc/observable";
  44513. import { Nullable } from "babylonjs/types";
  44514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44515. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44516. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44517. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44518. /**
  44519. * Gizmo that enables scaling a mesh along 3 axis
  44520. */
  44521. export class ScaleGizmo extends Gizmo {
  44522. /**
  44523. * Internal gizmo used for interactions on the x axis
  44524. */
  44525. xGizmo: AxisScaleGizmo;
  44526. /**
  44527. * Internal gizmo used for interactions on the y axis
  44528. */
  44529. yGizmo: AxisScaleGizmo;
  44530. /**
  44531. * Internal gizmo used for interactions on the z axis
  44532. */
  44533. zGizmo: AxisScaleGizmo;
  44534. /**
  44535. * Internal gizmo used to scale all axis equally
  44536. */
  44537. uniformScaleGizmo: AxisScaleGizmo;
  44538. /** Fires an event when any of it's sub gizmos are dragged */
  44539. onDragStartObservable: Observable<{}>;
  44540. /** Fires an event when any of it's sub gizmos are released from dragging */
  44541. onDragEndObservable: Observable<{}>;
  44542. attachedMesh: Nullable<AbstractMesh>;
  44543. /**
  44544. * Creates a ScaleGizmo
  44545. * @param gizmoLayer The utility layer the gizmo will be added to
  44546. */
  44547. constructor(gizmoLayer?: UtilityLayerRenderer);
  44548. updateGizmoRotationToMatchAttachedMesh: boolean;
  44549. /**
  44550. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44551. */
  44552. snapDistance: number;
  44553. /**
  44554. * Ratio for the scale of the gizmo (Default: 1)
  44555. */
  44556. scaleRatio: number;
  44557. /**
  44558. * Disposes of the gizmo
  44559. */
  44560. dispose(): void;
  44561. }
  44562. }
  44563. declare module "babylonjs/Gizmos/gizmoManager" {
  44564. import { Observable } from "babylonjs/Misc/observable";
  44565. import { Nullable } from "babylonjs/types";
  44566. import { Scene, IDisposable } from "babylonjs/scene";
  44567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44568. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44569. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44570. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44571. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44572. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44573. /**
  44574. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44575. */
  44576. export class GizmoManager implements IDisposable {
  44577. private scene;
  44578. /**
  44579. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44580. */
  44581. gizmos: {
  44582. positionGizmo: Nullable<PositionGizmo>;
  44583. rotationGizmo: Nullable<RotationGizmo>;
  44584. scaleGizmo: Nullable<ScaleGizmo>;
  44585. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44586. };
  44587. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44588. clearGizmoOnEmptyPointerEvent: boolean;
  44589. /** Fires an event when the manager is attached to a mesh */
  44590. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44591. private _gizmosEnabled;
  44592. private _pointerObserver;
  44593. private _attachedMesh;
  44594. private _boundingBoxColor;
  44595. private _defaultUtilityLayer;
  44596. private _defaultKeepDepthUtilityLayer;
  44597. /**
  44598. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44599. */
  44600. boundingBoxDragBehavior: SixDofDragBehavior;
  44601. /**
  44602. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44603. */
  44604. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44605. /**
  44606. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44607. */
  44608. usePointerToAttachGizmos: boolean;
  44609. /**
  44610. * Instatiates a gizmo manager
  44611. * @param scene the scene to overlay the gizmos on top of
  44612. */
  44613. constructor(scene: Scene);
  44614. /**
  44615. * Attaches a set of gizmos to the specified mesh
  44616. * @param mesh The mesh the gizmo's should be attached to
  44617. */
  44618. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44619. /**
  44620. * If the position gizmo is enabled
  44621. */
  44622. positionGizmoEnabled: boolean;
  44623. /**
  44624. * If the rotation gizmo is enabled
  44625. */
  44626. rotationGizmoEnabled: boolean;
  44627. /**
  44628. * If the scale gizmo is enabled
  44629. */
  44630. scaleGizmoEnabled: boolean;
  44631. /**
  44632. * If the boundingBox gizmo is enabled
  44633. */
  44634. boundingBoxGizmoEnabled: boolean;
  44635. /**
  44636. * Disposes of the gizmo manager
  44637. */
  44638. dispose(): void;
  44639. }
  44640. }
  44641. declare module "babylonjs/Lights/directionalLight" {
  44642. import { Camera } from "babylonjs/Cameras/camera";
  44643. import { Scene } from "babylonjs/scene";
  44644. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44646. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44647. import { Effect } from "babylonjs/Materials/effect";
  44648. /**
  44649. * A directional light is defined by a direction (what a surprise!).
  44650. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44651. * 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.
  44652. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44653. */
  44654. export class DirectionalLight extends ShadowLight {
  44655. private _shadowFrustumSize;
  44656. /**
  44657. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44658. */
  44659. /**
  44660. * Specifies a fix frustum size for the shadow generation.
  44661. */
  44662. shadowFrustumSize: number;
  44663. private _shadowOrthoScale;
  44664. /**
  44665. * Gets the shadow projection scale against the optimal computed one.
  44666. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44667. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44668. */
  44669. /**
  44670. * Sets the shadow projection scale against the optimal computed one.
  44671. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44672. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44673. */
  44674. shadowOrthoScale: number;
  44675. /**
  44676. * Automatically compute the projection matrix to best fit (including all the casters)
  44677. * on each frame.
  44678. */
  44679. autoUpdateExtends: boolean;
  44680. private _orthoLeft;
  44681. private _orthoRight;
  44682. private _orthoTop;
  44683. private _orthoBottom;
  44684. /**
  44685. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44686. * The directional light is emitted from everywhere in the given direction.
  44687. * It can cast shadows.
  44688. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44689. * @param name The friendly name of the light
  44690. * @param direction The direction of the light
  44691. * @param scene The scene the light belongs to
  44692. */
  44693. constructor(name: string, direction: Vector3, scene: Scene);
  44694. /**
  44695. * Returns the string "DirectionalLight".
  44696. * @return The class name
  44697. */
  44698. getClassName(): string;
  44699. /**
  44700. * Returns the integer 1.
  44701. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44702. */
  44703. getTypeID(): number;
  44704. /**
  44705. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44706. * Returns the DirectionalLight Shadow projection matrix.
  44707. */
  44708. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44709. /**
  44710. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44711. * Returns the DirectionalLight Shadow projection matrix.
  44712. */
  44713. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44714. /**
  44715. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44716. * Returns the DirectionalLight Shadow projection matrix.
  44717. */
  44718. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44719. protected _buildUniformLayout(): void;
  44720. /**
  44721. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44722. * @param effect The effect to update
  44723. * @param lightIndex The index of the light in the effect to update
  44724. * @returns The directional light
  44725. */
  44726. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44727. /**
  44728. * Gets the minZ used for shadow according to both the scene and the light.
  44729. *
  44730. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44731. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44732. * @param activeCamera The camera we are returning the min for
  44733. * @returns the depth min z
  44734. */
  44735. getDepthMinZ(activeCamera: Camera): number;
  44736. /**
  44737. * Gets the maxZ used for shadow according to both the scene and the light.
  44738. *
  44739. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44740. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44741. * @param activeCamera The camera we are returning the max for
  44742. * @returns the depth max z
  44743. */
  44744. getDepthMaxZ(activeCamera: Camera): number;
  44745. /**
  44746. * Prepares the list of defines specific to the light type.
  44747. * @param defines the list of defines
  44748. * @param lightIndex defines the index of the light for the effect
  44749. */
  44750. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44751. }
  44752. }
  44753. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44754. import { Mesh } from "babylonjs/Meshes/mesh";
  44755. /**
  44756. * Class containing static functions to help procedurally build meshes
  44757. */
  44758. export class HemisphereBuilder {
  44759. /**
  44760. * Creates a hemisphere mesh
  44761. * @param name defines the name of the mesh
  44762. * @param options defines the options used to create the mesh
  44763. * @param scene defines the hosting scene
  44764. * @returns the hemisphere mesh
  44765. */
  44766. static CreateHemisphere(name: string, options: {
  44767. segments?: number;
  44768. diameter?: number;
  44769. sideOrientation?: number;
  44770. }, scene: any): Mesh;
  44771. }
  44772. }
  44773. declare module "babylonjs/Lights/spotLight" {
  44774. import { Nullable } from "babylonjs/types";
  44775. import { Scene } from "babylonjs/scene";
  44776. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44778. import { Effect } from "babylonjs/Materials/effect";
  44779. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44780. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44781. /**
  44782. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44783. * These values define a cone of light starting from the position, emitting toward the direction.
  44784. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44785. * and the exponent defines the speed of the decay of the light with distance (reach).
  44786. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44787. */
  44788. export class SpotLight extends ShadowLight {
  44789. private _angle;
  44790. private _innerAngle;
  44791. private _cosHalfAngle;
  44792. private _lightAngleScale;
  44793. private _lightAngleOffset;
  44794. /**
  44795. * Gets the cone angle of the spot light in Radians.
  44796. */
  44797. /**
  44798. * Sets the cone angle of the spot light in Radians.
  44799. */
  44800. angle: number;
  44801. /**
  44802. * Only used in gltf falloff mode, this defines the angle where
  44803. * the directional falloff will start before cutting at angle which could be seen
  44804. * as outer angle.
  44805. */
  44806. /**
  44807. * Only used in gltf falloff mode, this defines the angle where
  44808. * the directional falloff will start before cutting at angle which could be seen
  44809. * as outer angle.
  44810. */
  44811. innerAngle: number;
  44812. private _shadowAngleScale;
  44813. /**
  44814. * Allows scaling the angle of the light for shadow generation only.
  44815. */
  44816. /**
  44817. * Allows scaling the angle of the light for shadow generation only.
  44818. */
  44819. shadowAngleScale: number;
  44820. /**
  44821. * The light decay speed with the distance from the emission spot.
  44822. */
  44823. exponent: number;
  44824. private _projectionTextureMatrix;
  44825. /**
  44826. * Allows reading the projecton texture
  44827. */
  44828. readonly projectionTextureMatrix: Matrix;
  44829. protected _projectionTextureLightNear: number;
  44830. /**
  44831. * Gets the near clip of the Spotlight for texture projection.
  44832. */
  44833. /**
  44834. * Sets the near clip of the Spotlight for texture projection.
  44835. */
  44836. projectionTextureLightNear: number;
  44837. protected _projectionTextureLightFar: number;
  44838. /**
  44839. * Gets the far clip of the Spotlight for texture projection.
  44840. */
  44841. /**
  44842. * Sets the far clip of the Spotlight for texture projection.
  44843. */
  44844. projectionTextureLightFar: number;
  44845. protected _projectionTextureUpDirection: Vector3;
  44846. /**
  44847. * Gets the Up vector of the Spotlight for texture projection.
  44848. */
  44849. /**
  44850. * Sets the Up vector of the Spotlight for texture projection.
  44851. */
  44852. projectionTextureUpDirection: Vector3;
  44853. private _projectionTexture;
  44854. /**
  44855. * Gets the projection texture of the light.
  44856. */
  44857. /**
  44858. * Sets the projection texture of the light.
  44859. */
  44860. projectionTexture: Nullable<BaseTexture>;
  44861. private _projectionTextureViewLightDirty;
  44862. private _projectionTextureProjectionLightDirty;
  44863. private _projectionTextureDirty;
  44864. private _projectionTextureViewTargetVector;
  44865. private _projectionTextureViewLightMatrix;
  44866. private _projectionTextureProjectionLightMatrix;
  44867. private _projectionTextureScalingMatrix;
  44868. /**
  44869. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44870. * It can cast shadows.
  44871. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44872. * @param name The light friendly name
  44873. * @param position The position of the spot light in the scene
  44874. * @param direction The direction of the light in the scene
  44875. * @param angle The cone angle of the light in Radians
  44876. * @param exponent The light decay speed with the distance from the emission spot
  44877. * @param scene The scene the lights belongs to
  44878. */
  44879. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44880. /**
  44881. * Returns the string "SpotLight".
  44882. * @returns the class name
  44883. */
  44884. getClassName(): string;
  44885. /**
  44886. * Returns the integer 2.
  44887. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44888. */
  44889. getTypeID(): number;
  44890. /**
  44891. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44892. */
  44893. protected _setDirection(value: Vector3): void;
  44894. /**
  44895. * Overrides the position setter to recompute the projection texture view light Matrix.
  44896. */
  44897. protected _setPosition(value: Vector3): void;
  44898. /**
  44899. * 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.
  44900. * Returns the SpotLight.
  44901. */
  44902. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44903. protected _computeProjectionTextureViewLightMatrix(): void;
  44904. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44905. /**
  44906. * Main function for light texture projection matrix computing.
  44907. */
  44908. protected _computeProjectionTextureMatrix(): void;
  44909. protected _buildUniformLayout(): void;
  44910. private _computeAngleValues;
  44911. /**
  44912. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44913. * @param effect The effect to update
  44914. * @param lightIndex The index of the light in the effect to update
  44915. * @returns The spot light
  44916. */
  44917. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44918. /**
  44919. * Disposes the light and the associated resources.
  44920. */
  44921. dispose(): void;
  44922. /**
  44923. * Prepares the list of defines specific to the light type.
  44924. * @param defines the list of defines
  44925. * @param lightIndex defines the index of the light for the effect
  44926. */
  44927. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44928. }
  44929. }
  44930. declare module "babylonjs/Gizmos/lightGizmo" {
  44931. import { Nullable } from "babylonjs/types";
  44932. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44933. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44934. import { Light } from "babylonjs/Lights/light";
  44935. /**
  44936. * Gizmo that enables viewing a light
  44937. */
  44938. export class LightGizmo extends Gizmo {
  44939. private _lightMesh;
  44940. private _material;
  44941. /**
  44942. * Creates a LightGizmo
  44943. * @param gizmoLayer The utility layer the gizmo will be added to
  44944. */
  44945. constructor(gizmoLayer?: UtilityLayerRenderer);
  44946. private _light;
  44947. /**
  44948. * The light that the gizmo is attached to
  44949. */
  44950. light: Nullable<Light>;
  44951. /**
  44952. * @hidden
  44953. * Updates the gizmo to match the attached mesh's position/rotation
  44954. */
  44955. protected _update(): void;
  44956. private static _Scale;
  44957. /**
  44958. * Creates the lines for a light mesh
  44959. */
  44960. private static _createLightLines;
  44961. private static _CreateHemisphericLightMesh;
  44962. private static _CreatePointLightMesh;
  44963. private static _CreateSpotLightMesh;
  44964. private static _CreateDirectionalLightMesh;
  44965. }
  44966. }
  44967. declare module "babylonjs/Gizmos/index" {
  44968. export * from "babylonjs/Gizmos/axisDragGizmo";
  44969. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44970. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44971. export * from "babylonjs/Gizmos/gizmo";
  44972. export * from "babylonjs/Gizmos/gizmoManager";
  44973. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44974. export * from "babylonjs/Gizmos/positionGizmo";
  44975. export * from "babylonjs/Gizmos/rotationGizmo";
  44976. export * from "babylonjs/Gizmos/scaleGizmo";
  44977. export * from "babylonjs/Gizmos/lightGizmo";
  44978. }
  44979. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44980. /** @hidden */
  44981. export var backgroundFragmentDeclaration: {
  44982. name: string;
  44983. shader: string;
  44984. };
  44985. }
  44986. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44987. /** @hidden */
  44988. export var backgroundUboDeclaration: {
  44989. name: string;
  44990. shader: string;
  44991. };
  44992. }
  44993. declare module "babylonjs/Shaders/background.fragment" {
  44994. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44995. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44996. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44997. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44998. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44999. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45000. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45001. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45002. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45003. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45004. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45005. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45006. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45007. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45008. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45009. /** @hidden */
  45010. export var backgroundPixelShader: {
  45011. name: string;
  45012. shader: string;
  45013. };
  45014. }
  45015. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45016. /** @hidden */
  45017. export var backgroundVertexDeclaration: {
  45018. name: string;
  45019. shader: string;
  45020. };
  45021. }
  45022. declare module "babylonjs/Shaders/background.vertex" {
  45023. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45024. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45025. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45026. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45027. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45028. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45029. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45030. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45031. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45032. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45033. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45034. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45035. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45036. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45037. /** @hidden */
  45038. export var backgroundVertexShader: {
  45039. name: string;
  45040. shader: string;
  45041. };
  45042. }
  45043. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45044. import { Nullable, int, float } from "babylonjs/types";
  45045. import { Scene } from "babylonjs/scene";
  45046. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45047. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45049. import { Mesh } from "babylonjs/Meshes/mesh";
  45050. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45051. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45052. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45053. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45054. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45055. import "babylonjs/Shaders/background.fragment";
  45056. import "babylonjs/Shaders/background.vertex";
  45057. /**
  45058. * Background material used to create an efficient environement around your scene.
  45059. */
  45060. export class BackgroundMaterial extends PushMaterial {
  45061. /**
  45062. * Standard reflectance value at parallel view angle.
  45063. */
  45064. static StandardReflectance0: number;
  45065. /**
  45066. * Standard reflectance value at grazing angle.
  45067. */
  45068. static StandardReflectance90: number;
  45069. protected _primaryColor: Color3;
  45070. /**
  45071. * Key light Color (multiply against the environement texture)
  45072. */
  45073. primaryColor: Color3;
  45074. protected __perceptualColor: Nullable<Color3>;
  45075. /**
  45076. * Experimental Internal Use Only.
  45077. *
  45078. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45079. * This acts as a helper to set the primary color to a more "human friendly" value.
  45080. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45081. * output color as close as possible from the chosen value.
  45082. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45083. * part of lighting setup.)
  45084. */
  45085. _perceptualColor: Nullable<Color3>;
  45086. protected _primaryColorShadowLevel: float;
  45087. /**
  45088. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45089. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45090. */
  45091. primaryColorShadowLevel: float;
  45092. protected _primaryColorHighlightLevel: float;
  45093. /**
  45094. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45095. * The primary color is used at the level chosen to define what the white area would look.
  45096. */
  45097. primaryColorHighlightLevel: float;
  45098. protected _reflectionTexture: Nullable<BaseTexture>;
  45099. /**
  45100. * Reflection Texture used in the material.
  45101. * Should be author in a specific way for the best result (refer to the documentation).
  45102. */
  45103. reflectionTexture: Nullable<BaseTexture>;
  45104. protected _reflectionBlur: float;
  45105. /**
  45106. * Reflection Texture level of blur.
  45107. *
  45108. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45109. * texture twice.
  45110. */
  45111. reflectionBlur: float;
  45112. protected _diffuseTexture: Nullable<BaseTexture>;
  45113. /**
  45114. * Diffuse Texture used in the material.
  45115. * Should be author in a specific way for the best result (refer to the documentation).
  45116. */
  45117. diffuseTexture: Nullable<BaseTexture>;
  45118. protected _shadowLights: Nullable<IShadowLight[]>;
  45119. /**
  45120. * Specify the list of lights casting shadow on the material.
  45121. * All scene shadow lights will be included if null.
  45122. */
  45123. shadowLights: Nullable<IShadowLight[]>;
  45124. protected _shadowLevel: float;
  45125. /**
  45126. * Helps adjusting the shadow to a softer level if required.
  45127. * 0 means black shadows and 1 means no shadows.
  45128. */
  45129. shadowLevel: float;
  45130. protected _sceneCenter: Vector3;
  45131. /**
  45132. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45133. * It is usually zero but might be interesting to modify according to your setup.
  45134. */
  45135. sceneCenter: Vector3;
  45136. protected _opacityFresnel: boolean;
  45137. /**
  45138. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45139. * This helps ensuring a nice transition when the camera goes under the ground.
  45140. */
  45141. opacityFresnel: boolean;
  45142. protected _reflectionFresnel: boolean;
  45143. /**
  45144. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45145. * This helps adding a mirror texture on the ground.
  45146. */
  45147. reflectionFresnel: boolean;
  45148. protected _reflectionFalloffDistance: number;
  45149. /**
  45150. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45151. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45152. */
  45153. reflectionFalloffDistance: number;
  45154. protected _reflectionAmount: number;
  45155. /**
  45156. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45157. */
  45158. reflectionAmount: number;
  45159. protected _reflectionReflectance0: number;
  45160. /**
  45161. * This specifies the weight of the reflection at grazing angle.
  45162. */
  45163. reflectionReflectance0: number;
  45164. protected _reflectionReflectance90: number;
  45165. /**
  45166. * This specifies the weight of the reflection at a perpendicular point of view.
  45167. */
  45168. reflectionReflectance90: number;
  45169. /**
  45170. * Sets the reflection reflectance fresnel values according to the default standard
  45171. * empirically know to work well :-)
  45172. */
  45173. reflectionStandardFresnelWeight: number;
  45174. protected _useRGBColor: boolean;
  45175. /**
  45176. * Helps to directly use the maps channels instead of their level.
  45177. */
  45178. useRGBColor: boolean;
  45179. protected _enableNoise: boolean;
  45180. /**
  45181. * This helps reducing the banding effect that could occur on the background.
  45182. */
  45183. enableNoise: boolean;
  45184. /**
  45185. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45186. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45187. * Recommended to be keep at 1.0 except for special cases.
  45188. */
  45189. fovMultiplier: number;
  45190. private _fovMultiplier;
  45191. /**
  45192. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45193. */
  45194. useEquirectangularFOV: boolean;
  45195. private _maxSimultaneousLights;
  45196. /**
  45197. * Number of Simultaneous lights allowed on the material.
  45198. */
  45199. maxSimultaneousLights: int;
  45200. /**
  45201. * Default configuration related to image processing available in the Background Material.
  45202. */
  45203. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45204. /**
  45205. * Keep track of the image processing observer to allow dispose and replace.
  45206. */
  45207. private _imageProcessingObserver;
  45208. /**
  45209. * Attaches a new image processing configuration to the PBR Material.
  45210. * @param configuration (if null the scene configuration will be use)
  45211. */
  45212. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45213. /**
  45214. * Gets the image processing configuration used either in this material.
  45215. */
  45216. /**
  45217. * Sets the Default image processing configuration used either in the this material.
  45218. *
  45219. * If sets to null, the scene one is in use.
  45220. */
  45221. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45222. /**
  45223. * Gets wether the color curves effect is enabled.
  45224. */
  45225. /**
  45226. * Sets wether the color curves effect is enabled.
  45227. */
  45228. cameraColorCurvesEnabled: boolean;
  45229. /**
  45230. * Gets wether the color grading effect is enabled.
  45231. */
  45232. /**
  45233. * Gets wether the color grading effect is enabled.
  45234. */
  45235. cameraColorGradingEnabled: boolean;
  45236. /**
  45237. * Gets wether tonemapping is enabled or not.
  45238. */
  45239. /**
  45240. * Sets wether tonemapping is enabled or not
  45241. */
  45242. cameraToneMappingEnabled: boolean;
  45243. /**
  45244. * The camera exposure used on this material.
  45245. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45246. * This corresponds to a photographic exposure.
  45247. */
  45248. /**
  45249. * The camera exposure used on this material.
  45250. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45251. * This corresponds to a photographic exposure.
  45252. */
  45253. cameraExposure: float;
  45254. /**
  45255. * Gets The camera contrast used on this material.
  45256. */
  45257. /**
  45258. * Sets The camera contrast used on this material.
  45259. */
  45260. cameraContrast: float;
  45261. /**
  45262. * Gets the Color Grading 2D Lookup Texture.
  45263. */
  45264. /**
  45265. * Sets the Color Grading 2D Lookup Texture.
  45266. */
  45267. cameraColorGradingTexture: Nullable<BaseTexture>;
  45268. /**
  45269. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45270. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45271. * 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;
  45272. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45273. */
  45274. /**
  45275. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45276. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45277. * 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;
  45278. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45279. */
  45280. cameraColorCurves: Nullable<ColorCurves>;
  45281. /**
  45282. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45283. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45284. */
  45285. switchToBGR: boolean;
  45286. private _renderTargets;
  45287. private _reflectionControls;
  45288. private _white;
  45289. private _primaryShadowColor;
  45290. private _primaryHighlightColor;
  45291. /**
  45292. * Instantiates a Background Material in the given scene
  45293. * @param name The friendly name of the material
  45294. * @param scene The scene to add the material to
  45295. */
  45296. constructor(name: string, scene: Scene);
  45297. /**
  45298. * Gets a boolean indicating that current material needs to register RTT
  45299. */
  45300. readonly hasRenderTargetTextures: boolean;
  45301. /**
  45302. * The entire material has been created in order to prevent overdraw.
  45303. * @returns false
  45304. */
  45305. needAlphaTesting(): boolean;
  45306. /**
  45307. * The entire material has been created in order to prevent overdraw.
  45308. * @returns true if blending is enable
  45309. */
  45310. needAlphaBlending(): boolean;
  45311. /**
  45312. * Checks wether the material is ready to be rendered for a given mesh.
  45313. * @param mesh The mesh to render
  45314. * @param subMesh The submesh to check against
  45315. * @param useInstances Specify wether or not the material is used with instances
  45316. * @returns true if all the dependencies are ready (Textures, Effects...)
  45317. */
  45318. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45319. /**
  45320. * Compute the primary color according to the chosen perceptual color.
  45321. */
  45322. private _computePrimaryColorFromPerceptualColor;
  45323. /**
  45324. * Compute the highlights and shadow colors according to their chosen levels.
  45325. */
  45326. private _computePrimaryColors;
  45327. /**
  45328. * Build the uniform buffer used in the material.
  45329. */
  45330. buildUniformLayout(): void;
  45331. /**
  45332. * Unbind the material.
  45333. */
  45334. unbind(): void;
  45335. /**
  45336. * Bind only the world matrix to the material.
  45337. * @param world The world matrix to bind.
  45338. */
  45339. bindOnlyWorldMatrix(world: Matrix): void;
  45340. /**
  45341. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45342. * @param world The world matrix to bind.
  45343. * @param subMesh The submesh to bind for.
  45344. */
  45345. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45346. /**
  45347. * Dispose the material.
  45348. * @param forceDisposeEffect Force disposal of the associated effect.
  45349. * @param forceDisposeTextures Force disposal of the associated textures.
  45350. */
  45351. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45352. /**
  45353. * Clones the material.
  45354. * @param name The cloned name.
  45355. * @returns The cloned material.
  45356. */
  45357. clone(name: string): BackgroundMaterial;
  45358. /**
  45359. * Serializes the current material to its JSON representation.
  45360. * @returns The JSON representation.
  45361. */
  45362. serialize(): any;
  45363. /**
  45364. * Gets the class name of the material
  45365. * @returns "BackgroundMaterial"
  45366. */
  45367. getClassName(): string;
  45368. /**
  45369. * Parse a JSON input to create back a background material.
  45370. * @param source The JSON data to parse
  45371. * @param scene The scene to create the parsed material in
  45372. * @param rootUrl The root url of the assets the material depends upon
  45373. * @returns the instantiated BackgroundMaterial.
  45374. */
  45375. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45376. }
  45377. }
  45378. declare module "babylonjs/Helpers/environmentHelper" {
  45379. import { Observable } from "babylonjs/Misc/observable";
  45380. import { Nullable } from "babylonjs/types";
  45381. import { Scene } from "babylonjs/scene";
  45382. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45384. import { Mesh } from "babylonjs/Meshes/mesh";
  45385. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45386. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45387. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45388. import "babylonjs/Meshes/Builders/planeBuilder";
  45389. import "babylonjs/Meshes/Builders/boxBuilder";
  45390. /**
  45391. * Represents the different options available during the creation of
  45392. * a Environment helper.
  45393. *
  45394. * This can control the default ground, skybox and image processing setup of your scene.
  45395. */
  45396. export interface IEnvironmentHelperOptions {
  45397. /**
  45398. * Specifies wether or not to create a ground.
  45399. * True by default.
  45400. */
  45401. createGround: boolean;
  45402. /**
  45403. * Specifies the ground size.
  45404. * 15 by default.
  45405. */
  45406. groundSize: number;
  45407. /**
  45408. * The texture used on the ground for the main color.
  45409. * Comes from the BabylonJS CDN by default.
  45410. *
  45411. * Remarks: Can be either a texture or a url.
  45412. */
  45413. groundTexture: string | BaseTexture;
  45414. /**
  45415. * The color mixed in the ground texture by default.
  45416. * BabylonJS clearColor by default.
  45417. */
  45418. groundColor: Color3;
  45419. /**
  45420. * Specifies the ground opacity.
  45421. * 1 by default.
  45422. */
  45423. groundOpacity: number;
  45424. /**
  45425. * Enables the ground to receive shadows.
  45426. * True by default.
  45427. */
  45428. enableGroundShadow: boolean;
  45429. /**
  45430. * Helps preventing the shadow to be fully black on the ground.
  45431. * 0.5 by default.
  45432. */
  45433. groundShadowLevel: number;
  45434. /**
  45435. * Creates a mirror texture attach to the ground.
  45436. * false by default.
  45437. */
  45438. enableGroundMirror: boolean;
  45439. /**
  45440. * Specifies the ground mirror size ratio.
  45441. * 0.3 by default as the default kernel is 64.
  45442. */
  45443. groundMirrorSizeRatio: number;
  45444. /**
  45445. * Specifies the ground mirror blur kernel size.
  45446. * 64 by default.
  45447. */
  45448. groundMirrorBlurKernel: number;
  45449. /**
  45450. * Specifies the ground mirror visibility amount.
  45451. * 1 by default
  45452. */
  45453. groundMirrorAmount: number;
  45454. /**
  45455. * Specifies the ground mirror reflectance weight.
  45456. * This uses the standard weight of the background material to setup the fresnel effect
  45457. * of the mirror.
  45458. * 1 by default.
  45459. */
  45460. groundMirrorFresnelWeight: number;
  45461. /**
  45462. * Specifies the ground mirror Falloff distance.
  45463. * This can helps reducing the size of the reflection.
  45464. * 0 by Default.
  45465. */
  45466. groundMirrorFallOffDistance: number;
  45467. /**
  45468. * Specifies the ground mirror texture type.
  45469. * Unsigned Int by Default.
  45470. */
  45471. groundMirrorTextureType: number;
  45472. /**
  45473. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45474. * the shown objects.
  45475. */
  45476. groundYBias: number;
  45477. /**
  45478. * Specifies wether or not to create a skybox.
  45479. * True by default.
  45480. */
  45481. createSkybox: boolean;
  45482. /**
  45483. * Specifies the skybox size.
  45484. * 20 by default.
  45485. */
  45486. skyboxSize: number;
  45487. /**
  45488. * The texture used on the skybox for the main color.
  45489. * Comes from the BabylonJS CDN by default.
  45490. *
  45491. * Remarks: Can be either a texture or a url.
  45492. */
  45493. skyboxTexture: string | BaseTexture;
  45494. /**
  45495. * The color mixed in the skybox texture by default.
  45496. * BabylonJS clearColor by default.
  45497. */
  45498. skyboxColor: Color3;
  45499. /**
  45500. * The background rotation around the Y axis of the scene.
  45501. * This helps aligning the key lights of your scene with the background.
  45502. * 0 by default.
  45503. */
  45504. backgroundYRotation: number;
  45505. /**
  45506. * Compute automatically the size of the elements to best fit with the scene.
  45507. */
  45508. sizeAuto: boolean;
  45509. /**
  45510. * Default position of the rootMesh if autoSize is not true.
  45511. */
  45512. rootPosition: Vector3;
  45513. /**
  45514. * Sets up the image processing in the scene.
  45515. * true by default.
  45516. */
  45517. setupImageProcessing: boolean;
  45518. /**
  45519. * The texture used as your environment texture in the scene.
  45520. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45521. *
  45522. * Remarks: Can be either a texture or a url.
  45523. */
  45524. environmentTexture: string | BaseTexture;
  45525. /**
  45526. * The value of the exposure to apply to the scene.
  45527. * 0.6 by default if setupImageProcessing is true.
  45528. */
  45529. cameraExposure: number;
  45530. /**
  45531. * The value of the contrast to apply to the scene.
  45532. * 1.6 by default if setupImageProcessing is true.
  45533. */
  45534. cameraContrast: number;
  45535. /**
  45536. * Specifies wether or not tonemapping should be enabled in the scene.
  45537. * true by default if setupImageProcessing is true.
  45538. */
  45539. toneMappingEnabled: boolean;
  45540. }
  45541. /**
  45542. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45543. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45544. * It also helps with the default setup of your imageProcessing configuration.
  45545. */
  45546. export class EnvironmentHelper {
  45547. /**
  45548. * Default ground texture URL.
  45549. */
  45550. private static _groundTextureCDNUrl;
  45551. /**
  45552. * Default skybox texture URL.
  45553. */
  45554. private static _skyboxTextureCDNUrl;
  45555. /**
  45556. * Default environment texture URL.
  45557. */
  45558. private static _environmentTextureCDNUrl;
  45559. /**
  45560. * Creates the default options for the helper.
  45561. */
  45562. private static _getDefaultOptions;
  45563. private _rootMesh;
  45564. /**
  45565. * Gets the root mesh created by the helper.
  45566. */
  45567. readonly rootMesh: Mesh;
  45568. private _skybox;
  45569. /**
  45570. * Gets the skybox created by the helper.
  45571. */
  45572. readonly skybox: Nullable<Mesh>;
  45573. private _skyboxTexture;
  45574. /**
  45575. * Gets the skybox texture created by the helper.
  45576. */
  45577. readonly skyboxTexture: Nullable<BaseTexture>;
  45578. private _skyboxMaterial;
  45579. /**
  45580. * Gets the skybox material created by the helper.
  45581. */
  45582. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45583. private _ground;
  45584. /**
  45585. * Gets the ground mesh created by the helper.
  45586. */
  45587. readonly ground: Nullable<Mesh>;
  45588. private _groundTexture;
  45589. /**
  45590. * Gets the ground texture created by the helper.
  45591. */
  45592. readonly groundTexture: Nullable<BaseTexture>;
  45593. private _groundMirror;
  45594. /**
  45595. * Gets the ground mirror created by the helper.
  45596. */
  45597. readonly groundMirror: Nullable<MirrorTexture>;
  45598. /**
  45599. * Gets the ground mirror render list to helps pushing the meshes
  45600. * you wish in the ground reflection.
  45601. */
  45602. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45603. private _groundMaterial;
  45604. /**
  45605. * Gets the ground material created by the helper.
  45606. */
  45607. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45608. /**
  45609. * Stores the creation options.
  45610. */
  45611. private readonly _scene;
  45612. private _options;
  45613. /**
  45614. * This observable will be notified with any error during the creation of the environment,
  45615. * mainly texture creation errors.
  45616. */
  45617. onErrorObservable: Observable<{
  45618. message?: string;
  45619. exception?: any;
  45620. }>;
  45621. /**
  45622. * constructor
  45623. * @param options Defines the options we want to customize the helper
  45624. * @param scene The scene to add the material to
  45625. */
  45626. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45627. /**
  45628. * Updates the background according to the new options
  45629. * @param options
  45630. */
  45631. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45632. /**
  45633. * Sets the primary color of all the available elements.
  45634. * @param color the main color to affect to the ground and the background
  45635. */
  45636. setMainColor(color: Color3): void;
  45637. /**
  45638. * Setup the image processing according to the specified options.
  45639. */
  45640. private _setupImageProcessing;
  45641. /**
  45642. * Setup the environment texture according to the specified options.
  45643. */
  45644. private _setupEnvironmentTexture;
  45645. /**
  45646. * Setup the background according to the specified options.
  45647. */
  45648. private _setupBackground;
  45649. /**
  45650. * Get the scene sizes according to the setup.
  45651. */
  45652. private _getSceneSize;
  45653. /**
  45654. * Setup the ground according to the specified options.
  45655. */
  45656. private _setupGround;
  45657. /**
  45658. * Setup the ground material according to the specified options.
  45659. */
  45660. private _setupGroundMaterial;
  45661. /**
  45662. * Setup the ground diffuse texture according to the specified options.
  45663. */
  45664. private _setupGroundDiffuseTexture;
  45665. /**
  45666. * Setup the ground mirror texture according to the specified options.
  45667. */
  45668. private _setupGroundMirrorTexture;
  45669. /**
  45670. * Setup the ground to receive the mirror texture.
  45671. */
  45672. private _setupMirrorInGroundMaterial;
  45673. /**
  45674. * Setup the skybox according to the specified options.
  45675. */
  45676. private _setupSkybox;
  45677. /**
  45678. * Setup the skybox material according to the specified options.
  45679. */
  45680. private _setupSkyboxMaterial;
  45681. /**
  45682. * Setup the skybox reflection texture according to the specified options.
  45683. */
  45684. private _setupSkyboxReflectionTexture;
  45685. private _errorHandler;
  45686. /**
  45687. * Dispose all the elements created by the Helper.
  45688. */
  45689. dispose(): void;
  45690. }
  45691. }
  45692. declare module "babylonjs/Helpers/photoDome" {
  45693. import { Observable } from "babylonjs/Misc/observable";
  45694. import { Nullable } from "babylonjs/types";
  45695. import { Scene } from "babylonjs/scene";
  45696. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45697. import { Mesh } from "babylonjs/Meshes/mesh";
  45698. import { Texture } from "babylonjs/Materials/Textures/texture";
  45699. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45700. import "babylonjs/Meshes/Builders/sphereBuilder";
  45701. /**
  45702. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45703. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45704. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45705. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45706. */
  45707. export class PhotoDome extends TransformNode {
  45708. private _useDirectMapping;
  45709. /**
  45710. * The texture being displayed on the sphere
  45711. */
  45712. protected _photoTexture: Texture;
  45713. /**
  45714. * Gets or sets the texture being displayed on the sphere
  45715. */
  45716. photoTexture: Texture;
  45717. /**
  45718. * Observable raised when an error occured while loading the 360 image
  45719. */
  45720. onLoadErrorObservable: Observable<string>;
  45721. /**
  45722. * The skybox material
  45723. */
  45724. protected _material: BackgroundMaterial;
  45725. /**
  45726. * The surface used for the skybox
  45727. */
  45728. protected _mesh: Mesh;
  45729. /**
  45730. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45731. * Also see the options.resolution property.
  45732. */
  45733. fovMultiplier: number;
  45734. /**
  45735. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45736. * @param name Element's name, child elements will append suffixes for their own names.
  45737. * @param urlsOfPhoto defines the url of the photo to display
  45738. * @param options defines an object containing optional or exposed sub element properties
  45739. * @param onError defines a callback called when an error occured while loading the texture
  45740. */
  45741. constructor(name: string, urlOfPhoto: string, options: {
  45742. resolution?: number;
  45743. size?: number;
  45744. useDirectMapping?: boolean;
  45745. faceForward?: boolean;
  45746. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45747. /**
  45748. * Releases resources associated with this node.
  45749. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45750. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45751. */
  45752. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45753. }
  45754. }
  45755. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45756. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45757. /** @hidden */
  45758. export var rgbdDecodePixelShader: {
  45759. name: string;
  45760. shader: string;
  45761. };
  45762. }
  45763. declare module "babylonjs/Misc/brdfTextureTools" {
  45764. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45765. import { Scene } from "babylonjs/scene";
  45766. import "babylonjs/Shaders/rgbdDecode.fragment";
  45767. /**
  45768. * Class used to host texture specific utilities
  45769. */
  45770. export class BRDFTextureTools {
  45771. /**
  45772. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45773. * @param texture the texture to expand.
  45774. */
  45775. private static _ExpandDefaultBRDFTexture;
  45776. /**
  45777. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45778. * @param scene defines the hosting scene
  45779. * @returns the environment BRDF texture
  45780. */
  45781. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45782. private static _environmentBRDFBase64Texture;
  45783. }
  45784. }
  45785. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45786. import { Nullable } from "babylonjs/types";
  45787. import { IAnimatable } from "babylonjs/Misc/tools";
  45788. import { Color3 } from "babylonjs/Maths/math";
  45789. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45790. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45791. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45792. import { Engine } from "babylonjs/Engines/engine";
  45793. import { Scene } from "babylonjs/scene";
  45794. /**
  45795. * @hidden
  45796. */
  45797. export interface IMaterialClearCoatDefines {
  45798. CLEARCOAT: boolean;
  45799. CLEARCOAT_DEFAULTIOR: boolean;
  45800. CLEARCOAT_TEXTURE: boolean;
  45801. CLEARCOAT_TEXTUREDIRECTUV: number;
  45802. CLEARCOAT_BUMP: boolean;
  45803. CLEARCOAT_BUMPDIRECTUV: number;
  45804. CLEARCOAT_TINT: boolean;
  45805. CLEARCOAT_TINT_TEXTURE: boolean;
  45806. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45807. /** @hidden */
  45808. _areTexturesDirty: boolean;
  45809. }
  45810. /**
  45811. * Define the code related to the clear coat parameters of the pbr material.
  45812. */
  45813. export class PBRClearCoatConfiguration {
  45814. /**
  45815. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45816. * The default fits with a polyurethane material.
  45817. */
  45818. private static readonly _DefaultIndiceOfRefraction;
  45819. private _isEnabled;
  45820. /**
  45821. * Defines if the clear coat is enabled in the material.
  45822. */
  45823. isEnabled: boolean;
  45824. /**
  45825. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45826. */
  45827. intensity: number;
  45828. /**
  45829. * Defines the clear coat layer roughness.
  45830. */
  45831. roughness: number;
  45832. private _indiceOfRefraction;
  45833. /**
  45834. * Defines the indice of refraction of the clear coat.
  45835. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45836. * The default fits with a polyurethane material.
  45837. * Changing the default value is more performance intensive.
  45838. */
  45839. indiceOfRefraction: number;
  45840. private _texture;
  45841. /**
  45842. * Stores the clear coat values in a texture.
  45843. */
  45844. texture: Nullable<BaseTexture>;
  45845. private _bumpTexture;
  45846. /**
  45847. * Define the clear coat specific bump texture.
  45848. */
  45849. bumpTexture: Nullable<BaseTexture>;
  45850. private _isTintEnabled;
  45851. /**
  45852. * Defines if the clear coat tint is enabled in the material.
  45853. */
  45854. isTintEnabled: boolean;
  45855. /**
  45856. * Defines the clear coat tint of the material.
  45857. * This is only use if tint is enabled
  45858. */
  45859. tintColor: Color3;
  45860. /**
  45861. * Defines the distance at which the tint color should be found in the
  45862. * clear coat media.
  45863. * This is only use if tint is enabled
  45864. */
  45865. tintColorAtDistance: number;
  45866. /**
  45867. * Defines the clear coat layer thickness.
  45868. * This is only use if tint is enabled
  45869. */
  45870. tintThickness: number;
  45871. private _tintTexture;
  45872. /**
  45873. * Stores the clear tint values in a texture.
  45874. * rgb is tint
  45875. * a is a thickness factor
  45876. */
  45877. tintTexture: Nullable<BaseTexture>;
  45878. /** @hidden */
  45879. private _internalMarkAllSubMeshesAsTexturesDirty;
  45880. /** @hidden */
  45881. _markAllSubMeshesAsTexturesDirty(): void;
  45882. /**
  45883. * Instantiate a new istance of clear coat configuration.
  45884. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45885. */
  45886. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45887. /**
  45888. * Gets wehter the submesh is ready to be used or not.
  45889. * @param defines the list of "defines" to update.
  45890. * @param scene defines the scene the material belongs to.
  45891. * @param engine defines the engine the material belongs to.
  45892. * @param disableBumpMap defines wether the material disables bump or not.
  45893. * @returns - boolean indicating that the submesh is ready or not.
  45894. */
  45895. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45896. /**
  45897. * Checks to see if a texture is used in the material.
  45898. * @param defines the list of "defines" to update.
  45899. * @param scene defines the scene to the material belongs to.
  45900. */
  45901. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45902. /**
  45903. * Binds the material data.
  45904. * @param uniformBuffer defines the Uniform buffer to fill in.
  45905. * @param scene defines the scene the material belongs to.
  45906. * @param engine defines the engine the material belongs to.
  45907. * @param disableBumpMap defines wether the material disables bump or not.
  45908. * @param isFrozen defines wether the material is frozen or not.
  45909. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45910. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45911. */
  45912. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45913. /**
  45914. * Checks to see if a texture is used in the material.
  45915. * @param texture - Base texture to use.
  45916. * @returns - Boolean specifying if a texture is used in the material.
  45917. */
  45918. hasTexture(texture: BaseTexture): boolean;
  45919. /**
  45920. * Returns an array of the actively used textures.
  45921. * @param activeTextures Array of BaseTextures
  45922. */
  45923. getActiveTextures(activeTextures: BaseTexture[]): void;
  45924. /**
  45925. * Returns the animatable textures.
  45926. * @param animatables Array of animatable textures.
  45927. */
  45928. getAnimatables(animatables: IAnimatable[]): void;
  45929. /**
  45930. * Disposes the resources of the material.
  45931. * @param forceDisposeTextures - Forces the disposal of all textures.
  45932. */
  45933. dispose(forceDisposeTextures?: boolean): void;
  45934. /**
  45935. * Get the current class name of the texture useful for serialization or dynamic coding.
  45936. * @returns "PBRClearCoatConfiguration"
  45937. */
  45938. getClassName(): string;
  45939. /**
  45940. * Add fallbacks to the effect fallbacks list.
  45941. * @param defines defines the Base texture to use.
  45942. * @param fallbacks defines the current fallback list.
  45943. * @param currentRank defines the current fallback rank.
  45944. * @returns the new fallback rank.
  45945. */
  45946. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45947. /**
  45948. * Add the required uniforms to the current list.
  45949. * @param uniforms defines the current uniform list.
  45950. */
  45951. static AddUniforms(uniforms: string[]): void;
  45952. /**
  45953. * Add the required samplers to the current list.
  45954. * @param samplers defines the current sampler list.
  45955. */
  45956. static AddSamplers(samplers: string[]): void;
  45957. /**
  45958. * Add the required uniforms to the current buffer.
  45959. * @param uniformBuffer defines the current uniform buffer.
  45960. */
  45961. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45962. /**
  45963. * Makes a duplicate of the current configuration into another one.
  45964. * @param clearCoatConfiguration define the config where to copy the info
  45965. */
  45966. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45967. /**
  45968. * Serializes this clear coat configuration.
  45969. * @returns - An object with the serialized config.
  45970. */
  45971. serialize(): any;
  45972. /**
  45973. * Parses a Clear Coat Configuration from a serialized object.
  45974. * @param source - Serialized object.
  45975. */
  45976. parse(source: any): void;
  45977. }
  45978. }
  45979. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45980. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45981. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45983. import { Vector2 } from "babylonjs/Maths/math";
  45984. import { Scene } from "babylonjs/scene";
  45985. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45986. import { IAnimatable } from "babylonjs/Misc/tools";
  45987. import { Nullable } from "babylonjs/types";
  45988. /**
  45989. * @hidden
  45990. */
  45991. export interface IMaterialAnisotropicDefines {
  45992. ANISOTROPIC: boolean;
  45993. ANISOTROPIC_TEXTURE: boolean;
  45994. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45995. MAINUV1: boolean;
  45996. _areTexturesDirty: boolean;
  45997. _needUVs: boolean;
  45998. }
  45999. /**
  46000. * Define the code related to the anisotropic parameters of the pbr material.
  46001. */
  46002. export class PBRAnisotropicConfiguration {
  46003. private _isEnabled;
  46004. /**
  46005. * Defines if the anisotropy is enabled in the material.
  46006. */
  46007. isEnabled: boolean;
  46008. /**
  46009. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46010. */
  46011. intensity: number;
  46012. /**
  46013. * Defines if the effect is along the tangents, bitangents or in between.
  46014. * By default, the effect is "strectching" the highlights along the tangents.
  46015. */
  46016. direction: Vector2;
  46017. private _texture;
  46018. /**
  46019. * Stores the anisotropy values in a texture.
  46020. * rg is direction (like normal from -1 to 1)
  46021. * b is a intensity
  46022. */
  46023. texture: Nullable<BaseTexture>;
  46024. /** @hidden */
  46025. private _internalMarkAllSubMeshesAsTexturesDirty;
  46026. /** @hidden */
  46027. _markAllSubMeshesAsTexturesDirty(): void;
  46028. /**
  46029. * Instantiate a new istance of anisotropy configuration.
  46030. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46031. */
  46032. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46033. /**
  46034. * Specifies that the submesh is ready to be used.
  46035. * @param defines the list of "defines" to update.
  46036. * @param scene defines the scene the material belongs to.
  46037. * @returns - boolean indicating that the submesh is ready or not.
  46038. */
  46039. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46040. /**
  46041. * Checks to see if a texture is used in the material.
  46042. * @param defines the list of "defines" to update.
  46043. * @param mesh the mesh we are preparing the defines for.
  46044. * @param scene defines the scene the material belongs to.
  46045. */
  46046. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46047. /**
  46048. * Binds the material data.
  46049. * @param uniformBuffer defines the Uniform buffer to fill in.
  46050. * @param scene defines the scene the material belongs to.
  46051. * @param isFrozen defines wether the material is frozen or not.
  46052. */
  46053. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46054. /**
  46055. * Checks to see if a texture is used in the material.
  46056. * @param texture - Base texture to use.
  46057. * @returns - Boolean specifying if a texture is used in the material.
  46058. */
  46059. hasTexture(texture: BaseTexture): boolean;
  46060. /**
  46061. * Returns an array of the actively used textures.
  46062. * @param activeTextures Array of BaseTextures
  46063. */
  46064. getActiveTextures(activeTextures: BaseTexture[]): void;
  46065. /**
  46066. * Returns the animatable textures.
  46067. * @param animatables Array of animatable textures.
  46068. */
  46069. getAnimatables(animatables: IAnimatable[]): void;
  46070. /**
  46071. * Disposes the resources of the material.
  46072. * @param forceDisposeTextures - Forces the disposal of all textures.
  46073. */
  46074. dispose(forceDisposeTextures?: boolean): void;
  46075. /**
  46076. * Get the current class name of the texture useful for serialization or dynamic coding.
  46077. * @returns "PBRAnisotropicConfiguration"
  46078. */
  46079. getClassName(): string;
  46080. /**
  46081. * Add fallbacks to the effect fallbacks list.
  46082. * @param defines defines the Base texture to use.
  46083. * @param fallbacks defines the current fallback list.
  46084. * @param currentRank defines the current fallback rank.
  46085. * @returns the new fallback rank.
  46086. */
  46087. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46088. /**
  46089. * Add the required uniforms to the current list.
  46090. * @param uniforms defines the current uniform list.
  46091. */
  46092. static AddUniforms(uniforms: string[]): void;
  46093. /**
  46094. * Add the required uniforms to the current buffer.
  46095. * @param uniformBuffer defines the current uniform buffer.
  46096. */
  46097. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46098. /**
  46099. * Add the required samplers to the current list.
  46100. * @param samplers defines the current sampler list.
  46101. */
  46102. static AddSamplers(samplers: string[]): void;
  46103. /**
  46104. * Makes a duplicate of the current configuration into another one.
  46105. * @param anisotropicConfiguration define the config where to copy the info
  46106. */
  46107. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46108. /**
  46109. * Serializes this anisotropy configuration.
  46110. * @returns - An object with the serialized config.
  46111. */
  46112. serialize(): any;
  46113. /**
  46114. * Parses a anisotropy Configuration from a serialized object.
  46115. * @param source - Serialized object.
  46116. */
  46117. parse(source: any): void;
  46118. }
  46119. }
  46120. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46121. /**
  46122. * @hidden
  46123. */
  46124. export interface IMaterialBRDFDefines {
  46125. BRDF_V_HEIGHT_CORRELATED: boolean;
  46126. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46127. SPHERICAL_HARMONICS: boolean;
  46128. /** @hidden */
  46129. _areMiscDirty: boolean;
  46130. }
  46131. /**
  46132. * Define the code related to the BRDF parameters of the pbr material.
  46133. */
  46134. export class PBRBRDFConfiguration {
  46135. /**
  46136. * Default value used for the energy conservation.
  46137. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46138. */
  46139. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46140. /**
  46141. * Default value used for the Smith Visibility Height Correlated mode.
  46142. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46143. */
  46144. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46145. /**
  46146. * Default value used for the IBL diffuse part.
  46147. * This can help switching back to the polynomials mode globally which is a tiny bit
  46148. * less GPU intensive at the drawback of a lower quality.
  46149. */
  46150. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46151. private _useEnergyConservation;
  46152. /**
  46153. * Defines if the material uses energy conservation.
  46154. */
  46155. useEnergyConservation: boolean;
  46156. private _useSmithVisibilityHeightCorrelated;
  46157. /**
  46158. * LEGACY Mode set to false
  46159. * Defines if the material uses height smith correlated visibility term.
  46160. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46161. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46162. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46163. * Not relying on height correlated will also disable energy conservation.
  46164. */
  46165. useSmithVisibilityHeightCorrelated: boolean;
  46166. private _useSphericalHarmonics;
  46167. /**
  46168. * LEGACY Mode set to false
  46169. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46170. * diffuse part of the IBL.
  46171. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46172. * to the ground truth.
  46173. */
  46174. useSphericalHarmonics: boolean;
  46175. /** @hidden */
  46176. private _internalMarkAllSubMeshesAsMiscDirty;
  46177. /** @hidden */
  46178. _markAllSubMeshesAsMiscDirty(): void;
  46179. /**
  46180. * Instantiate a new istance of clear coat configuration.
  46181. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46182. */
  46183. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46184. /**
  46185. * Checks to see if a texture is used in the material.
  46186. * @param defines the list of "defines" to update.
  46187. */
  46188. prepareDefines(defines: IMaterialBRDFDefines): void;
  46189. /**
  46190. * Get the current class name of the texture useful for serialization or dynamic coding.
  46191. * @returns "PBRClearCoatConfiguration"
  46192. */
  46193. getClassName(): string;
  46194. /**
  46195. * Makes a duplicate of the current configuration into another one.
  46196. * @param brdfConfiguration define the config where to copy the info
  46197. */
  46198. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46199. /**
  46200. * Serializes this BRDF configuration.
  46201. * @returns - An object with the serialized config.
  46202. */
  46203. serialize(): any;
  46204. /**
  46205. * Parses a BRDF Configuration from a serialized object.
  46206. * @param source - Serialized object.
  46207. */
  46208. parse(source: any): void;
  46209. }
  46210. }
  46211. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46212. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46213. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46214. import { Color3 } from "babylonjs/Maths/math";
  46215. import { Scene } from "babylonjs/scene";
  46216. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46217. import { IAnimatable } from "babylonjs/Misc/tools";
  46218. import { Nullable } from "babylonjs/types";
  46219. /**
  46220. * @hidden
  46221. */
  46222. export interface IMaterialSheenDefines {
  46223. SHEEN: boolean;
  46224. SHEEN_TEXTURE: boolean;
  46225. SHEEN_TEXTUREDIRECTUV: number;
  46226. SHEEN_LINKWITHALBEDO: boolean;
  46227. /** @hidden */
  46228. _areTexturesDirty: boolean;
  46229. }
  46230. /**
  46231. * Define the code related to the Sheen parameters of the pbr material.
  46232. */
  46233. export class PBRSheenConfiguration {
  46234. private _isEnabled;
  46235. /**
  46236. * Defines if the material uses sheen.
  46237. */
  46238. isEnabled: boolean;
  46239. private _linkSheenWithAlbedo;
  46240. /**
  46241. * Defines if the sheen is linked to the sheen color.
  46242. */
  46243. linkSheenWithAlbedo: boolean;
  46244. /**
  46245. * Defines the sheen intensity.
  46246. */
  46247. intensity: number;
  46248. /**
  46249. * Defines the sheen color.
  46250. */
  46251. color: Color3;
  46252. private _texture;
  46253. /**
  46254. * Stores the sheen tint values in a texture.
  46255. * rgb is tint
  46256. * a is a intensity
  46257. */
  46258. texture: Nullable<BaseTexture>;
  46259. /** @hidden */
  46260. private _internalMarkAllSubMeshesAsTexturesDirty;
  46261. /** @hidden */
  46262. _markAllSubMeshesAsTexturesDirty(): void;
  46263. /**
  46264. * Instantiate a new istance of clear coat configuration.
  46265. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46266. */
  46267. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46268. /**
  46269. * Specifies that the submesh is ready to be used.
  46270. * @param defines the list of "defines" to update.
  46271. * @param scene defines the scene the material belongs to.
  46272. * @returns - boolean indicating that the submesh is ready or not.
  46273. */
  46274. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46275. /**
  46276. * Checks to see if a texture is used in the material.
  46277. * @param defines the list of "defines" to update.
  46278. * @param scene defines the scene the material belongs to.
  46279. */
  46280. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46281. /**
  46282. * Binds the material data.
  46283. * @param uniformBuffer defines the Uniform buffer to fill in.
  46284. * @param scene defines the scene the material belongs to.
  46285. * @param isFrozen defines wether the material is frozen or not.
  46286. */
  46287. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46288. /**
  46289. * Checks to see if a texture is used in the material.
  46290. * @param texture - Base texture to use.
  46291. * @returns - Boolean specifying if a texture is used in the material.
  46292. */
  46293. hasTexture(texture: BaseTexture): boolean;
  46294. /**
  46295. * Returns an array of the actively used textures.
  46296. * @param activeTextures Array of BaseTextures
  46297. */
  46298. getActiveTextures(activeTextures: BaseTexture[]): void;
  46299. /**
  46300. * Returns the animatable textures.
  46301. * @param animatables Array of animatable textures.
  46302. */
  46303. getAnimatables(animatables: IAnimatable[]): void;
  46304. /**
  46305. * Disposes the resources of the material.
  46306. * @param forceDisposeTextures - Forces the disposal of all textures.
  46307. */
  46308. dispose(forceDisposeTextures?: boolean): void;
  46309. /**
  46310. * Get the current class name of the texture useful for serialization or dynamic coding.
  46311. * @returns "PBRSheenConfiguration"
  46312. */
  46313. getClassName(): string;
  46314. /**
  46315. * Add fallbacks to the effect fallbacks list.
  46316. * @param defines defines the Base texture to use.
  46317. * @param fallbacks defines the current fallback list.
  46318. * @param currentRank defines the current fallback rank.
  46319. * @returns the new fallback rank.
  46320. */
  46321. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46322. /**
  46323. * Add the required uniforms to the current list.
  46324. * @param uniforms defines the current uniform list.
  46325. */
  46326. static AddUniforms(uniforms: string[]): void;
  46327. /**
  46328. * Add the required uniforms to the current buffer.
  46329. * @param uniformBuffer defines the current uniform buffer.
  46330. */
  46331. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46332. /**
  46333. * Add the required samplers to the current list.
  46334. * @param samplers defines the current sampler list.
  46335. */
  46336. static AddSamplers(samplers: string[]): void;
  46337. /**
  46338. * Makes a duplicate of the current configuration into another one.
  46339. * @param sheenConfiguration define the config where to copy the info
  46340. */
  46341. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46342. /**
  46343. * Serializes this BRDF configuration.
  46344. * @returns - An object with the serialized config.
  46345. */
  46346. serialize(): any;
  46347. /**
  46348. * Parses a Sheen Configuration from a serialized object.
  46349. * @param source - Serialized object.
  46350. */
  46351. parse(source: any): void;
  46352. }
  46353. }
  46354. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46355. import { Nullable } from "babylonjs/types";
  46356. import { IAnimatable } from "babylonjs/Misc/tools";
  46357. import { Color3 } from "babylonjs/Maths/math";
  46358. import { SmartArray } from "babylonjs/Misc/smartArray";
  46359. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46360. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46361. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46362. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46363. import { Engine } from "babylonjs/Engines/engine";
  46364. import { Scene } from "babylonjs/scene";
  46365. /**
  46366. * @hidden
  46367. */
  46368. export interface IMaterialSubSurfaceDefines {
  46369. SUBSURFACE: boolean;
  46370. SS_REFRACTION: boolean;
  46371. SS_TRANSLUCENCY: boolean;
  46372. SS_SCATERRING: boolean;
  46373. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46374. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46375. SS_REFRACTIONMAP_3D: boolean;
  46376. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46377. SS_LODINREFRACTIONALPHA: boolean;
  46378. SS_GAMMAREFRACTION: boolean;
  46379. SS_RGBDREFRACTION: boolean;
  46380. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46381. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46382. /** @hidden */
  46383. _areTexturesDirty: boolean;
  46384. }
  46385. /**
  46386. * Define the code related to the sub surface parameters of the pbr material.
  46387. */
  46388. export class PBRSubSurfaceConfiguration {
  46389. private _isRefractionEnabled;
  46390. /**
  46391. * Defines if the refraction is enabled in the material.
  46392. */
  46393. isRefractionEnabled: boolean;
  46394. private _isTranslucencyEnabled;
  46395. /**
  46396. * Defines if the translucency is enabled in the material.
  46397. */
  46398. isTranslucencyEnabled: boolean;
  46399. private _isScatteringEnabled;
  46400. /**
  46401. * Defines the refraction intensity of the material.
  46402. * The refraction when enabled replaces the Diffuse part of the material.
  46403. * The intensity helps transitionning between diffuse and refraction.
  46404. */
  46405. refractionIntensity: number;
  46406. /**
  46407. * Defines the translucency intensity of the material.
  46408. * When translucency has been enabled, this defines how much of the "translucency"
  46409. * is addded to the diffuse part of the material.
  46410. */
  46411. translucencyIntensity: number;
  46412. /**
  46413. * Defines the scattering intensity of the material.
  46414. * When scattering has been enabled, this defines how much of the "scattered light"
  46415. * is addded to the diffuse part of the material.
  46416. */
  46417. scatteringIntensity: number;
  46418. private _thicknessTexture;
  46419. /**
  46420. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46421. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46422. * 0 would mean minimumThickness
  46423. * 1 would mean maximumThickness
  46424. * The other channels might be use as a mask to vary the different effects intensity.
  46425. */
  46426. thicknessTexture: Nullable<BaseTexture>;
  46427. private _refractionTexture;
  46428. /**
  46429. * Defines the texture to use for refraction.
  46430. */
  46431. refractionTexture: Nullable<BaseTexture>;
  46432. private _indexOfRefraction;
  46433. /**
  46434. * Defines the indice of refraction used in the material.
  46435. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46436. */
  46437. indexOfRefraction: number;
  46438. private _invertRefractionY;
  46439. /**
  46440. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46441. */
  46442. invertRefractionY: boolean;
  46443. private _linkRefractionWithTransparency;
  46444. /**
  46445. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46446. * Materials half opaque for instance using refraction could benefit from this control.
  46447. */
  46448. linkRefractionWithTransparency: boolean;
  46449. /**
  46450. * Defines the minimum thickness stored in the thickness map.
  46451. * If no thickness map is defined, this value will be used to simulate thickness.
  46452. */
  46453. minimumThickness: number;
  46454. /**
  46455. * Defines the maximum thickness stored in the thickness map.
  46456. */
  46457. maximumThickness: number;
  46458. /**
  46459. * Defines the volume tint of the material.
  46460. * This is used for both translucency and scattering.
  46461. */
  46462. tintColor: Color3;
  46463. /**
  46464. * Defines the distance at which the tint color should be found in the media.
  46465. * This is used for refraction only.
  46466. */
  46467. tintColorAtDistance: number;
  46468. /**
  46469. * Defines how far each channel transmit through the media.
  46470. * It is defined as a color to simplify it selection.
  46471. */
  46472. diffusionDistance: Color3;
  46473. private _useMaskFromThicknessTexture;
  46474. /**
  46475. * Stores the intensity of the different subsurface effects in the thickness texture.
  46476. * * the green channel is the translucency intensity.
  46477. * * the blue channel is the scattering intensity.
  46478. * * the alpha channel is the refraction intensity.
  46479. */
  46480. useMaskFromThicknessTexture: boolean;
  46481. /** @hidden */
  46482. private _internalMarkAllSubMeshesAsTexturesDirty;
  46483. /** @hidden */
  46484. _markAllSubMeshesAsTexturesDirty(): void;
  46485. /**
  46486. * Instantiate a new istance of sub surface configuration.
  46487. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46488. */
  46489. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46490. /**
  46491. * Gets wehter the submesh is ready to be used or not.
  46492. * @param defines the list of "defines" to update.
  46493. * @param scene defines the scene the material belongs to.
  46494. * @returns - boolean indicating that the submesh is ready or not.
  46495. */
  46496. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46497. /**
  46498. * Checks to see if a texture is used in the material.
  46499. * @param defines the list of "defines" to update.
  46500. * @param scene defines the scene to the material belongs to.
  46501. */
  46502. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46503. /**
  46504. * Binds the material data.
  46505. * @param uniformBuffer defines the Uniform buffer to fill in.
  46506. * @param scene defines the scene the material belongs to.
  46507. * @param engine defines the engine the material belongs to.
  46508. * @param isFrozen defines wether the material is frozen or not.
  46509. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46510. */
  46511. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46512. /**
  46513. * Unbinds the material from the mesh.
  46514. * @param activeEffect defines the effect that should be unbound from.
  46515. * @returns true if unbound, otherwise false
  46516. */
  46517. unbind(activeEffect: Effect): boolean;
  46518. /**
  46519. * Returns the texture used for refraction or null if none is used.
  46520. * @param scene defines the scene the material belongs to.
  46521. * @returns - Refraction texture if present. If no refraction texture and refraction
  46522. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46523. */
  46524. private _getRefractionTexture;
  46525. /**
  46526. * Returns true if alpha blending should be disabled.
  46527. */
  46528. readonly disableAlphaBlending: boolean;
  46529. /**
  46530. * Fills the list of render target textures.
  46531. * @param renderTargets the list of render targets to update
  46532. */
  46533. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46534. /**
  46535. * Checks to see if a texture is used in the material.
  46536. * @param texture - Base texture to use.
  46537. * @returns - Boolean specifying if a texture is used in the material.
  46538. */
  46539. hasTexture(texture: BaseTexture): boolean;
  46540. /**
  46541. * Gets a boolean indicating that current material needs to register RTT
  46542. * @returns true if this uses a render target otherwise false.
  46543. */
  46544. hasRenderTargetTextures(): boolean;
  46545. /**
  46546. * Returns an array of the actively used textures.
  46547. * @param activeTextures Array of BaseTextures
  46548. */
  46549. getActiveTextures(activeTextures: BaseTexture[]): void;
  46550. /**
  46551. * Returns the animatable textures.
  46552. * @param animatables Array of animatable textures.
  46553. */
  46554. getAnimatables(animatables: IAnimatable[]): void;
  46555. /**
  46556. * Disposes the resources of the material.
  46557. * @param forceDisposeTextures - Forces the disposal of all textures.
  46558. */
  46559. dispose(forceDisposeTextures?: boolean): void;
  46560. /**
  46561. * Get the current class name of the texture useful for serialization or dynamic coding.
  46562. * @returns "PBRSubSurfaceConfiguration"
  46563. */
  46564. getClassName(): string;
  46565. /**
  46566. * Add fallbacks to the effect fallbacks list.
  46567. * @param defines defines the Base texture to use.
  46568. * @param fallbacks defines the current fallback list.
  46569. * @param currentRank defines the current fallback rank.
  46570. * @returns the new fallback rank.
  46571. */
  46572. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46573. /**
  46574. * Add the required uniforms to the current list.
  46575. * @param uniforms defines the current uniform list.
  46576. */
  46577. static AddUniforms(uniforms: string[]): void;
  46578. /**
  46579. * Add the required samplers to the current list.
  46580. * @param samplers defines the current sampler list.
  46581. */
  46582. static AddSamplers(samplers: string[]): void;
  46583. /**
  46584. * Add the required uniforms to the current buffer.
  46585. * @param uniformBuffer defines the current uniform buffer.
  46586. */
  46587. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46588. /**
  46589. * Makes a duplicate of the current configuration into another one.
  46590. * @param configuration define the config where to copy the info
  46591. */
  46592. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46593. /**
  46594. * Serializes this Sub Surface configuration.
  46595. * @returns - An object with the serialized config.
  46596. */
  46597. serialize(): any;
  46598. /**
  46599. * Parses a Sub Surface Configuration from a serialized object.
  46600. * @param source - Serialized object.
  46601. */
  46602. parse(source: any): void;
  46603. }
  46604. }
  46605. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46606. /** @hidden */
  46607. export var pbrFragmentDeclaration: {
  46608. name: string;
  46609. shader: string;
  46610. };
  46611. }
  46612. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46613. /** @hidden */
  46614. export var pbrUboDeclaration: {
  46615. name: string;
  46616. shader: string;
  46617. };
  46618. }
  46619. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46620. /** @hidden */
  46621. export var pbrFragmentExtraDeclaration: {
  46622. name: string;
  46623. shader: string;
  46624. };
  46625. }
  46626. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46627. /** @hidden */
  46628. export var pbrFragmentSamplersDeclaration: {
  46629. name: string;
  46630. shader: string;
  46631. };
  46632. }
  46633. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46634. /** @hidden */
  46635. export var pbrHelperFunctions: {
  46636. name: string;
  46637. shader: string;
  46638. };
  46639. }
  46640. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46641. /** @hidden */
  46642. export var harmonicsFunctions: {
  46643. name: string;
  46644. shader: string;
  46645. };
  46646. }
  46647. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46648. /** @hidden */
  46649. export var pbrDirectLightingSetupFunctions: {
  46650. name: string;
  46651. shader: string;
  46652. };
  46653. }
  46654. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46655. /** @hidden */
  46656. export var pbrDirectLightingFalloffFunctions: {
  46657. name: string;
  46658. shader: string;
  46659. };
  46660. }
  46661. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46662. /** @hidden */
  46663. export var pbrBRDFFunctions: {
  46664. name: string;
  46665. shader: string;
  46666. };
  46667. }
  46668. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46669. /** @hidden */
  46670. export var pbrDirectLightingFunctions: {
  46671. name: string;
  46672. shader: string;
  46673. };
  46674. }
  46675. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46676. /** @hidden */
  46677. export var pbrIBLFunctions: {
  46678. name: string;
  46679. shader: string;
  46680. };
  46681. }
  46682. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46683. /** @hidden */
  46684. export var pbrDebug: {
  46685. name: string;
  46686. shader: string;
  46687. };
  46688. }
  46689. declare module "babylonjs/Shaders/pbr.fragment" {
  46690. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46691. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46692. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46693. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46694. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46695. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46696. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46697. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46698. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46699. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46700. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46701. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46702. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46703. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46704. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46705. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46706. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46707. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46708. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46709. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46710. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46711. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46712. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46713. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46714. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46715. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46716. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46717. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46718. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46719. /** @hidden */
  46720. export var pbrPixelShader: {
  46721. name: string;
  46722. shader: string;
  46723. };
  46724. }
  46725. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46726. /** @hidden */
  46727. export var pbrVertexDeclaration: {
  46728. name: string;
  46729. shader: string;
  46730. };
  46731. }
  46732. declare module "babylonjs/Shaders/pbr.vertex" {
  46733. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46734. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46735. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46736. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46737. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46738. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46739. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46740. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46741. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46742. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46743. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46744. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46745. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46746. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46747. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46748. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46749. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46750. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46751. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46752. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46753. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46754. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46755. /** @hidden */
  46756. export var pbrVertexShader: {
  46757. name: string;
  46758. shader: string;
  46759. };
  46760. }
  46761. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46762. import { IAnimatable } from "babylonjs/Misc/tools";
  46763. import { Nullable } from "babylonjs/types";
  46764. import { Scene } from "babylonjs/scene";
  46765. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46766. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46768. import { Mesh } from "babylonjs/Meshes/mesh";
  46769. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46770. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46771. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46772. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46773. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46774. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46775. import { Material } from "babylonjs/Materials/material";
  46776. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46777. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46778. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46779. import "babylonjs/Shaders/pbr.fragment";
  46780. import "babylonjs/Shaders/pbr.vertex";
  46781. /**
  46782. * Manages the defines for the PBR Material.
  46783. * @hidden
  46784. */
  46785. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46786. PBR: boolean;
  46787. MAINUV1: boolean;
  46788. MAINUV2: boolean;
  46789. UV1: boolean;
  46790. UV2: boolean;
  46791. ALBEDO: boolean;
  46792. ALBEDODIRECTUV: number;
  46793. VERTEXCOLOR: boolean;
  46794. AMBIENT: boolean;
  46795. AMBIENTDIRECTUV: number;
  46796. AMBIENTINGRAYSCALE: boolean;
  46797. OPACITY: boolean;
  46798. VERTEXALPHA: boolean;
  46799. OPACITYDIRECTUV: number;
  46800. OPACITYRGB: boolean;
  46801. ALPHATEST: boolean;
  46802. DEPTHPREPASS: boolean;
  46803. ALPHABLEND: boolean;
  46804. ALPHAFROMALBEDO: boolean;
  46805. ALPHATESTVALUE: string;
  46806. SPECULAROVERALPHA: boolean;
  46807. RADIANCEOVERALPHA: boolean;
  46808. ALPHAFRESNEL: boolean;
  46809. LINEARALPHAFRESNEL: boolean;
  46810. PREMULTIPLYALPHA: boolean;
  46811. EMISSIVE: boolean;
  46812. EMISSIVEDIRECTUV: number;
  46813. REFLECTIVITY: boolean;
  46814. REFLECTIVITYDIRECTUV: number;
  46815. SPECULARTERM: boolean;
  46816. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46817. MICROSURFACEAUTOMATIC: boolean;
  46818. LODBASEDMICROSFURACE: boolean;
  46819. MICROSURFACEMAP: boolean;
  46820. MICROSURFACEMAPDIRECTUV: number;
  46821. METALLICWORKFLOW: boolean;
  46822. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46823. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46824. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46825. AOSTOREINMETALMAPRED: boolean;
  46826. ENVIRONMENTBRDF: boolean;
  46827. ENVIRONMENTBRDF_RGBD: boolean;
  46828. NORMAL: boolean;
  46829. TANGENT: boolean;
  46830. BUMP: boolean;
  46831. BUMPDIRECTUV: number;
  46832. OBJECTSPACE_NORMALMAP: boolean;
  46833. PARALLAX: boolean;
  46834. PARALLAXOCCLUSION: boolean;
  46835. NORMALXYSCALE: boolean;
  46836. LIGHTMAP: boolean;
  46837. LIGHTMAPDIRECTUV: number;
  46838. USELIGHTMAPASSHADOWMAP: boolean;
  46839. GAMMALIGHTMAP: boolean;
  46840. REFLECTION: boolean;
  46841. REFLECTIONMAP_3D: boolean;
  46842. REFLECTIONMAP_SPHERICAL: boolean;
  46843. REFLECTIONMAP_PLANAR: boolean;
  46844. REFLECTIONMAP_CUBIC: boolean;
  46845. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46846. REFLECTIONMAP_PROJECTION: boolean;
  46847. REFLECTIONMAP_SKYBOX: boolean;
  46848. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46849. REFLECTIONMAP_EXPLICIT: boolean;
  46850. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46851. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46852. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46853. INVERTCUBICMAP: boolean;
  46854. USESPHERICALFROMREFLECTIONMAP: boolean;
  46855. SPHERICAL_HARMONICS: boolean;
  46856. USESPHERICALINVERTEX: boolean;
  46857. REFLECTIONMAP_OPPOSITEZ: boolean;
  46858. LODINREFLECTIONALPHA: boolean;
  46859. GAMMAREFLECTION: boolean;
  46860. RGBDREFLECTION: boolean;
  46861. RADIANCEOCCLUSION: boolean;
  46862. HORIZONOCCLUSION: boolean;
  46863. INSTANCES: boolean;
  46864. NUM_BONE_INFLUENCERS: number;
  46865. BonesPerMesh: number;
  46866. BONETEXTURE: boolean;
  46867. NONUNIFORMSCALING: boolean;
  46868. MORPHTARGETS: boolean;
  46869. MORPHTARGETS_NORMAL: boolean;
  46870. MORPHTARGETS_TANGENT: boolean;
  46871. NUM_MORPH_INFLUENCERS: number;
  46872. IMAGEPROCESSING: boolean;
  46873. VIGNETTE: boolean;
  46874. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46875. VIGNETTEBLENDMODEOPAQUE: boolean;
  46876. TONEMAPPING: boolean;
  46877. TONEMAPPING_ACES: boolean;
  46878. CONTRAST: boolean;
  46879. COLORCURVES: boolean;
  46880. COLORGRADING: boolean;
  46881. COLORGRADING3D: boolean;
  46882. SAMPLER3DGREENDEPTH: boolean;
  46883. SAMPLER3DBGRMAP: boolean;
  46884. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46885. EXPOSURE: boolean;
  46886. MULTIVIEW: boolean;
  46887. USEPHYSICALLIGHTFALLOFF: boolean;
  46888. USEGLTFLIGHTFALLOFF: boolean;
  46889. TWOSIDEDLIGHTING: boolean;
  46890. SHADOWFLOAT: boolean;
  46891. CLIPPLANE: boolean;
  46892. CLIPPLANE2: boolean;
  46893. CLIPPLANE3: boolean;
  46894. CLIPPLANE4: boolean;
  46895. POINTSIZE: boolean;
  46896. FOG: boolean;
  46897. LOGARITHMICDEPTH: boolean;
  46898. FORCENORMALFORWARD: boolean;
  46899. SPECULARAA: boolean;
  46900. CLEARCOAT: boolean;
  46901. CLEARCOAT_DEFAULTIOR: boolean;
  46902. CLEARCOAT_TEXTURE: boolean;
  46903. CLEARCOAT_TEXTUREDIRECTUV: number;
  46904. CLEARCOAT_BUMP: boolean;
  46905. CLEARCOAT_BUMPDIRECTUV: number;
  46906. CLEARCOAT_TINT: boolean;
  46907. CLEARCOAT_TINT_TEXTURE: boolean;
  46908. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46909. ANISOTROPIC: boolean;
  46910. ANISOTROPIC_TEXTURE: boolean;
  46911. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46912. BRDF_V_HEIGHT_CORRELATED: boolean;
  46913. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46914. SHEEN: boolean;
  46915. SHEEN_TEXTURE: boolean;
  46916. SHEEN_TEXTUREDIRECTUV: number;
  46917. SHEEN_LINKWITHALBEDO: boolean;
  46918. SUBSURFACE: boolean;
  46919. SS_REFRACTION: boolean;
  46920. SS_TRANSLUCENCY: boolean;
  46921. SS_SCATERRING: boolean;
  46922. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46923. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46924. SS_REFRACTIONMAP_3D: boolean;
  46925. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46926. SS_LODINREFRACTIONALPHA: boolean;
  46927. SS_GAMMAREFRACTION: boolean;
  46928. SS_RGBDREFRACTION: boolean;
  46929. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46930. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46931. UNLIT: boolean;
  46932. DEBUGMODE: number;
  46933. /**
  46934. * Initializes the PBR Material defines.
  46935. */
  46936. constructor();
  46937. /**
  46938. * Resets the PBR Material defines.
  46939. */
  46940. reset(): void;
  46941. }
  46942. /**
  46943. * The Physically based material base class of BJS.
  46944. *
  46945. * This offers the main features of a standard PBR material.
  46946. * For more information, please refer to the documentation :
  46947. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46948. */
  46949. export abstract class PBRBaseMaterial extends PushMaterial {
  46950. /**
  46951. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46952. */
  46953. static readonly PBRMATERIAL_OPAQUE: number;
  46954. /**
  46955. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46956. */
  46957. static readonly PBRMATERIAL_ALPHATEST: number;
  46958. /**
  46959. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46960. */
  46961. static readonly PBRMATERIAL_ALPHABLEND: number;
  46962. /**
  46963. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46964. * They are also discarded below the alpha cutoff threshold to improve performances.
  46965. */
  46966. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46967. /**
  46968. * Defines the default value of how much AO map is occluding the analytical lights
  46969. * (point spot...).
  46970. */
  46971. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46972. /**
  46973. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46974. */
  46975. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46976. /**
  46977. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46978. * to enhance interoperability with other engines.
  46979. */
  46980. static readonly LIGHTFALLOFF_GLTF: number;
  46981. /**
  46982. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46983. * to enhance interoperability with other materials.
  46984. */
  46985. static readonly LIGHTFALLOFF_STANDARD: number;
  46986. /**
  46987. * Intensity of the direct lights e.g. the four lights available in your scene.
  46988. * This impacts both the direct diffuse and specular highlights.
  46989. */
  46990. protected _directIntensity: number;
  46991. /**
  46992. * Intensity of the emissive part of the material.
  46993. * This helps controlling the emissive effect without modifying the emissive color.
  46994. */
  46995. protected _emissiveIntensity: number;
  46996. /**
  46997. * Intensity of the environment e.g. how much the environment will light the object
  46998. * either through harmonics for rough material or through the refelction for shiny ones.
  46999. */
  47000. protected _environmentIntensity: number;
  47001. /**
  47002. * This is a special control allowing the reduction of the specular highlights coming from the
  47003. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47004. */
  47005. protected _specularIntensity: number;
  47006. /**
  47007. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47008. */
  47009. private _lightingInfos;
  47010. /**
  47011. * Debug Control allowing disabling the bump map on this material.
  47012. */
  47013. protected _disableBumpMap: boolean;
  47014. /**
  47015. * AKA Diffuse Texture in standard nomenclature.
  47016. */
  47017. protected _albedoTexture: Nullable<BaseTexture>;
  47018. /**
  47019. * AKA Occlusion Texture in other nomenclature.
  47020. */
  47021. protected _ambientTexture: Nullable<BaseTexture>;
  47022. /**
  47023. * AKA Occlusion Texture Intensity in other nomenclature.
  47024. */
  47025. protected _ambientTextureStrength: number;
  47026. /**
  47027. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47028. * 1 means it completely occludes it
  47029. * 0 mean it has no impact
  47030. */
  47031. protected _ambientTextureImpactOnAnalyticalLights: number;
  47032. /**
  47033. * Stores the alpha values in a texture.
  47034. */
  47035. protected _opacityTexture: Nullable<BaseTexture>;
  47036. /**
  47037. * Stores the reflection values in a texture.
  47038. */
  47039. protected _reflectionTexture: Nullable<BaseTexture>;
  47040. /**
  47041. * Stores the emissive values in a texture.
  47042. */
  47043. protected _emissiveTexture: Nullable<BaseTexture>;
  47044. /**
  47045. * AKA Specular texture in other nomenclature.
  47046. */
  47047. protected _reflectivityTexture: Nullable<BaseTexture>;
  47048. /**
  47049. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47050. */
  47051. protected _metallicTexture: Nullable<BaseTexture>;
  47052. /**
  47053. * Specifies the metallic scalar of the metallic/roughness workflow.
  47054. * Can also be used to scale the metalness values of the metallic texture.
  47055. */
  47056. protected _metallic: Nullable<number>;
  47057. /**
  47058. * Specifies the roughness scalar of the metallic/roughness workflow.
  47059. * Can also be used to scale the roughness values of the metallic texture.
  47060. */
  47061. protected _roughness: Nullable<number>;
  47062. /**
  47063. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47064. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47065. */
  47066. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47067. /**
  47068. * Stores surface normal data used to displace a mesh in a texture.
  47069. */
  47070. protected _bumpTexture: Nullable<BaseTexture>;
  47071. /**
  47072. * Stores the pre-calculated light information of a mesh in a texture.
  47073. */
  47074. protected _lightmapTexture: Nullable<BaseTexture>;
  47075. /**
  47076. * The color of a material in ambient lighting.
  47077. */
  47078. protected _ambientColor: Color3;
  47079. /**
  47080. * AKA Diffuse Color in other nomenclature.
  47081. */
  47082. protected _albedoColor: Color3;
  47083. /**
  47084. * AKA Specular Color in other nomenclature.
  47085. */
  47086. protected _reflectivityColor: Color3;
  47087. /**
  47088. * The color applied when light is reflected from a material.
  47089. */
  47090. protected _reflectionColor: Color3;
  47091. /**
  47092. * The color applied when light is emitted from a material.
  47093. */
  47094. protected _emissiveColor: Color3;
  47095. /**
  47096. * AKA Glossiness in other nomenclature.
  47097. */
  47098. protected _microSurface: number;
  47099. /**
  47100. * Specifies that the material will use the light map as a show map.
  47101. */
  47102. protected _useLightmapAsShadowmap: boolean;
  47103. /**
  47104. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47105. * makes the reflect vector face the model (under horizon).
  47106. */
  47107. protected _useHorizonOcclusion: boolean;
  47108. /**
  47109. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47110. * too much the area relying on ambient texture to define their ambient occlusion.
  47111. */
  47112. protected _useRadianceOcclusion: boolean;
  47113. /**
  47114. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47115. */
  47116. protected _useAlphaFromAlbedoTexture: boolean;
  47117. /**
  47118. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47119. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47120. */
  47121. protected _useSpecularOverAlpha: boolean;
  47122. /**
  47123. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47124. */
  47125. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47126. /**
  47127. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47128. */
  47129. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47130. /**
  47131. * Specifies if the metallic texture contains the roughness information in its green channel.
  47132. */
  47133. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47134. /**
  47135. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47136. */
  47137. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47138. /**
  47139. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47140. */
  47141. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47142. /**
  47143. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47144. */
  47145. protected _useAmbientInGrayScale: boolean;
  47146. /**
  47147. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47148. * The material will try to infer what glossiness each pixel should be.
  47149. */
  47150. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47151. /**
  47152. * Defines the falloff type used in this material.
  47153. * It by default is Physical.
  47154. */
  47155. protected _lightFalloff: number;
  47156. /**
  47157. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47158. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47159. */
  47160. protected _useRadianceOverAlpha: boolean;
  47161. /**
  47162. * Allows using an object space normal map (instead of tangent space).
  47163. */
  47164. protected _useObjectSpaceNormalMap: boolean;
  47165. /**
  47166. * Allows using the bump map in parallax mode.
  47167. */
  47168. protected _useParallax: boolean;
  47169. /**
  47170. * Allows using the bump map in parallax occlusion mode.
  47171. */
  47172. protected _useParallaxOcclusion: boolean;
  47173. /**
  47174. * Controls the scale bias of the parallax mode.
  47175. */
  47176. protected _parallaxScaleBias: number;
  47177. /**
  47178. * If sets to true, disables all the lights affecting the material.
  47179. */
  47180. protected _disableLighting: boolean;
  47181. /**
  47182. * Number of Simultaneous lights allowed on the material.
  47183. */
  47184. protected _maxSimultaneousLights: number;
  47185. /**
  47186. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47187. */
  47188. protected _invertNormalMapX: boolean;
  47189. /**
  47190. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47191. */
  47192. protected _invertNormalMapY: boolean;
  47193. /**
  47194. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47195. */
  47196. protected _twoSidedLighting: boolean;
  47197. /**
  47198. * Defines the alpha limits in alpha test mode.
  47199. */
  47200. protected _alphaCutOff: number;
  47201. /**
  47202. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47203. */
  47204. protected _forceAlphaTest: boolean;
  47205. /**
  47206. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47207. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47208. */
  47209. protected _useAlphaFresnel: boolean;
  47210. /**
  47211. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47212. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47213. */
  47214. protected _useLinearAlphaFresnel: boolean;
  47215. /**
  47216. * The transparency mode of the material.
  47217. */
  47218. protected _transparencyMode: Nullable<number>;
  47219. /**
  47220. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47221. * from cos thetav and roughness:
  47222. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47223. */
  47224. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47225. /**
  47226. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47227. */
  47228. protected _forceIrradianceInFragment: boolean;
  47229. /**
  47230. * Force normal to face away from face.
  47231. */
  47232. protected _forceNormalForward: boolean;
  47233. /**
  47234. * Enables specular anti aliasing in the PBR shader.
  47235. * It will both interacts on the Geometry for analytical and IBL lighting.
  47236. * It also prefilter the roughness map based on the bump values.
  47237. */
  47238. protected _enableSpecularAntiAliasing: boolean;
  47239. /**
  47240. * Default configuration related to image processing available in the PBR Material.
  47241. */
  47242. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47243. /**
  47244. * Keep track of the image processing observer to allow dispose and replace.
  47245. */
  47246. private _imageProcessingObserver;
  47247. /**
  47248. * Attaches a new image processing configuration to the PBR Material.
  47249. * @param configuration
  47250. */
  47251. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47252. /**
  47253. * Stores the available render targets.
  47254. */
  47255. private _renderTargets;
  47256. /**
  47257. * Sets the global ambient color for the material used in lighting calculations.
  47258. */
  47259. private _globalAmbientColor;
  47260. /**
  47261. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47262. */
  47263. private _useLogarithmicDepth;
  47264. /**
  47265. * If set to true, no lighting calculations will be applied.
  47266. */
  47267. private _unlit;
  47268. private _debugMode;
  47269. /**
  47270. * @hidden
  47271. * This is reserved for the inspector.
  47272. * Defines the material debug mode.
  47273. * It helps seeing only some components of the material while troubleshooting.
  47274. */
  47275. debugMode: number;
  47276. /**
  47277. * @hidden
  47278. * This is reserved for the inspector.
  47279. * Specify from where on screen the debug mode should start.
  47280. * The value goes from -1 (full screen) to 1 (not visible)
  47281. * It helps with side by side comparison against the final render
  47282. * This defaults to -1
  47283. */
  47284. private debugLimit;
  47285. /**
  47286. * @hidden
  47287. * This is reserved for the inspector.
  47288. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47289. * You can use the factor to better multiply the final value.
  47290. */
  47291. private debugFactor;
  47292. /**
  47293. * Defines the clear coat layer parameters for the material.
  47294. */
  47295. readonly clearCoat: PBRClearCoatConfiguration;
  47296. /**
  47297. * Defines the anisotropic parameters for the material.
  47298. */
  47299. readonly anisotropy: PBRAnisotropicConfiguration;
  47300. /**
  47301. * Defines the BRDF parameters for the material.
  47302. */
  47303. readonly brdf: PBRBRDFConfiguration;
  47304. /**
  47305. * Defines the Sheen parameters for the material.
  47306. */
  47307. readonly sheen: PBRSheenConfiguration;
  47308. /**
  47309. * Defines the SubSurface parameters for the material.
  47310. */
  47311. readonly subSurface: PBRSubSurfaceConfiguration;
  47312. /**
  47313. * Custom callback helping to override the default shader used in the material.
  47314. */
  47315. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47316. /**
  47317. * Instantiates a new PBRMaterial instance.
  47318. *
  47319. * @param name The material name
  47320. * @param scene The scene the material will be use in.
  47321. */
  47322. constructor(name: string, scene: Scene);
  47323. /**
  47324. * Gets a boolean indicating that current material needs to register RTT
  47325. */
  47326. readonly hasRenderTargetTextures: boolean;
  47327. /**
  47328. * Gets the name of the material class.
  47329. */
  47330. getClassName(): string;
  47331. /**
  47332. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47333. */
  47334. /**
  47335. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47336. */
  47337. useLogarithmicDepth: boolean;
  47338. /**
  47339. * Gets the current transparency mode.
  47340. */
  47341. /**
  47342. * Sets the transparency mode of the material.
  47343. *
  47344. * | Value | Type | Description |
  47345. * | ----- | ----------------------------------- | ----------- |
  47346. * | 0 | OPAQUE | |
  47347. * | 1 | ALPHATEST | |
  47348. * | 2 | ALPHABLEND | |
  47349. * | 3 | ALPHATESTANDBLEND | |
  47350. *
  47351. */
  47352. transparencyMode: Nullable<number>;
  47353. /**
  47354. * Returns true if alpha blending should be disabled.
  47355. */
  47356. private readonly _disableAlphaBlending;
  47357. /**
  47358. * Specifies whether or not this material should be rendered in alpha blend mode.
  47359. */
  47360. needAlphaBlending(): boolean;
  47361. /**
  47362. * Specifies if the mesh will require alpha blending.
  47363. * @param mesh - BJS mesh.
  47364. */
  47365. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47366. /**
  47367. * Specifies whether or not this material should be rendered in alpha test mode.
  47368. */
  47369. needAlphaTesting(): boolean;
  47370. /**
  47371. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47372. */
  47373. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47374. /**
  47375. * Gets the texture used for the alpha test.
  47376. */
  47377. getAlphaTestTexture(): Nullable<BaseTexture>;
  47378. /**
  47379. * Specifies that the submesh is ready to be used.
  47380. * @param mesh - BJS mesh.
  47381. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47382. * @param useInstances - Specifies that instances should be used.
  47383. * @returns - boolean indicating that the submesh is ready or not.
  47384. */
  47385. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47386. /**
  47387. * Specifies if the material uses metallic roughness workflow.
  47388. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47389. */
  47390. isMetallicWorkflow(): boolean;
  47391. private _prepareEffect;
  47392. private _prepareDefines;
  47393. /**
  47394. * Force shader compilation
  47395. */
  47396. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47397. clipPlane: boolean;
  47398. }>): void;
  47399. /**
  47400. * Initializes the uniform buffer layout for the shader.
  47401. */
  47402. buildUniformLayout(): void;
  47403. /**
  47404. * Unbinds the material from the mesh
  47405. */
  47406. unbind(): void;
  47407. /**
  47408. * Binds the submesh data.
  47409. * @param world - The world matrix.
  47410. * @param mesh - The BJS mesh.
  47411. * @param subMesh - A submesh of the BJS mesh.
  47412. */
  47413. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47414. /**
  47415. * Returns the animatable textures.
  47416. * @returns - Array of animatable textures.
  47417. */
  47418. getAnimatables(): IAnimatable[];
  47419. /**
  47420. * Returns the texture used for reflections.
  47421. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47422. */
  47423. private _getReflectionTexture;
  47424. /**
  47425. * Returns an array of the actively used textures.
  47426. * @returns - Array of BaseTextures
  47427. */
  47428. getActiveTextures(): BaseTexture[];
  47429. /**
  47430. * Checks to see if a texture is used in the material.
  47431. * @param texture - Base texture to use.
  47432. * @returns - Boolean specifying if a texture is used in the material.
  47433. */
  47434. hasTexture(texture: BaseTexture): boolean;
  47435. /**
  47436. * Disposes the resources of the material.
  47437. * @param forceDisposeEffect - Forces the disposal of effects.
  47438. * @param forceDisposeTextures - Forces the disposal of all textures.
  47439. */
  47440. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47441. }
  47442. }
  47443. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47444. import { Nullable } from "babylonjs/types";
  47445. import { Scene } from "babylonjs/scene";
  47446. import { Color3 } from "babylonjs/Maths/math";
  47447. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47448. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47450. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47451. /**
  47452. * The Physically based material of BJS.
  47453. *
  47454. * This offers the main features of a standard PBR material.
  47455. * For more information, please refer to the documentation :
  47456. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47457. */
  47458. export class PBRMaterial extends PBRBaseMaterial {
  47459. /**
  47460. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47461. */
  47462. static readonly PBRMATERIAL_OPAQUE: number;
  47463. /**
  47464. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47465. */
  47466. static readonly PBRMATERIAL_ALPHATEST: number;
  47467. /**
  47468. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47469. */
  47470. static readonly PBRMATERIAL_ALPHABLEND: number;
  47471. /**
  47472. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47473. * They are also discarded below the alpha cutoff threshold to improve performances.
  47474. */
  47475. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47476. /**
  47477. * Defines the default value of how much AO map is occluding the analytical lights
  47478. * (point spot...).
  47479. */
  47480. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47481. /**
  47482. * Intensity of the direct lights e.g. the four lights available in your scene.
  47483. * This impacts both the direct diffuse and specular highlights.
  47484. */
  47485. directIntensity: number;
  47486. /**
  47487. * Intensity of the emissive part of the material.
  47488. * This helps controlling the emissive effect without modifying the emissive color.
  47489. */
  47490. emissiveIntensity: number;
  47491. /**
  47492. * Intensity of the environment e.g. how much the environment will light the object
  47493. * either through harmonics for rough material or through the refelction for shiny ones.
  47494. */
  47495. environmentIntensity: number;
  47496. /**
  47497. * This is a special control allowing the reduction of the specular highlights coming from the
  47498. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47499. */
  47500. specularIntensity: number;
  47501. /**
  47502. * Debug Control allowing disabling the bump map on this material.
  47503. */
  47504. disableBumpMap: boolean;
  47505. /**
  47506. * AKA Diffuse Texture in standard nomenclature.
  47507. */
  47508. albedoTexture: BaseTexture;
  47509. /**
  47510. * AKA Occlusion Texture in other nomenclature.
  47511. */
  47512. ambientTexture: BaseTexture;
  47513. /**
  47514. * AKA Occlusion Texture Intensity in other nomenclature.
  47515. */
  47516. ambientTextureStrength: number;
  47517. /**
  47518. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47519. * 1 means it completely occludes it
  47520. * 0 mean it has no impact
  47521. */
  47522. ambientTextureImpactOnAnalyticalLights: number;
  47523. /**
  47524. * Stores the alpha values in a texture.
  47525. */
  47526. opacityTexture: BaseTexture;
  47527. /**
  47528. * Stores the reflection values in a texture.
  47529. */
  47530. reflectionTexture: Nullable<BaseTexture>;
  47531. /**
  47532. * Stores the emissive values in a texture.
  47533. */
  47534. emissiveTexture: BaseTexture;
  47535. /**
  47536. * AKA Specular texture in other nomenclature.
  47537. */
  47538. reflectivityTexture: BaseTexture;
  47539. /**
  47540. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47541. */
  47542. metallicTexture: BaseTexture;
  47543. /**
  47544. * Specifies the metallic scalar of the metallic/roughness workflow.
  47545. * Can also be used to scale the metalness values of the metallic texture.
  47546. */
  47547. metallic: Nullable<number>;
  47548. /**
  47549. * Specifies the roughness scalar of the metallic/roughness workflow.
  47550. * Can also be used to scale the roughness values of the metallic texture.
  47551. */
  47552. roughness: Nullable<number>;
  47553. /**
  47554. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47555. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47556. */
  47557. microSurfaceTexture: BaseTexture;
  47558. /**
  47559. * Stores surface normal data used to displace a mesh in a texture.
  47560. */
  47561. bumpTexture: BaseTexture;
  47562. /**
  47563. * Stores the pre-calculated light information of a mesh in a texture.
  47564. */
  47565. lightmapTexture: BaseTexture;
  47566. /**
  47567. * Stores the refracted light information in a texture.
  47568. */
  47569. refractionTexture: Nullable<BaseTexture>;
  47570. /**
  47571. * The color of a material in ambient lighting.
  47572. */
  47573. ambientColor: Color3;
  47574. /**
  47575. * AKA Diffuse Color in other nomenclature.
  47576. */
  47577. albedoColor: Color3;
  47578. /**
  47579. * AKA Specular Color in other nomenclature.
  47580. */
  47581. reflectivityColor: Color3;
  47582. /**
  47583. * The color reflected from the material.
  47584. */
  47585. reflectionColor: Color3;
  47586. /**
  47587. * The color emitted from the material.
  47588. */
  47589. emissiveColor: Color3;
  47590. /**
  47591. * AKA Glossiness in other nomenclature.
  47592. */
  47593. microSurface: number;
  47594. /**
  47595. * source material index of refraction (IOR)' / 'destination material IOR.
  47596. */
  47597. indexOfRefraction: number;
  47598. /**
  47599. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47600. */
  47601. invertRefractionY: boolean;
  47602. /**
  47603. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47604. * Materials half opaque for instance using refraction could benefit from this control.
  47605. */
  47606. linkRefractionWithTransparency: boolean;
  47607. /**
  47608. * If true, the light map contains occlusion information instead of lighting info.
  47609. */
  47610. useLightmapAsShadowmap: boolean;
  47611. /**
  47612. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47613. */
  47614. useAlphaFromAlbedoTexture: boolean;
  47615. /**
  47616. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47617. */
  47618. forceAlphaTest: boolean;
  47619. /**
  47620. * Defines the alpha limits in alpha test mode.
  47621. */
  47622. alphaCutOff: number;
  47623. /**
  47624. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47625. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47626. */
  47627. useSpecularOverAlpha: boolean;
  47628. /**
  47629. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47630. */
  47631. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47632. /**
  47633. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47634. */
  47635. useRoughnessFromMetallicTextureAlpha: boolean;
  47636. /**
  47637. * Specifies if the metallic texture contains the roughness information in its green channel.
  47638. */
  47639. useRoughnessFromMetallicTextureGreen: boolean;
  47640. /**
  47641. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47642. */
  47643. useMetallnessFromMetallicTextureBlue: boolean;
  47644. /**
  47645. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47646. */
  47647. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47648. /**
  47649. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47650. */
  47651. useAmbientInGrayScale: boolean;
  47652. /**
  47653. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47654. * The material will try to infer what glossiness each pixel should be.
  47655. */
  47656. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47657. /**
  47658. * BJS is using an harcoded light falloff based on a manually sets up range.
  47659. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47660. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47661. */
  47662. /**
  47663. * BJS is using an harcoded light falloff based on a manually sets up range.
  47664. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47665. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47666. */
  47667. usePhysicalLightFalloff: boolean;
  47668. /**
  47669. * In order to support the falloff compatibility with gltf, a special mode has been added
  47670. * to reproduce the gltf light falloff.
  47671. */
  47672. /**
  47673. * In order to support the falloff compatibility with gltf, a special mode has been added
  47674. * to reproduce the gltf light falloff.
  47675. */
  47676. useGLTFLightFalloff: boolean;
  47677. /**
  47678. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47679. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47680. */
  47681. useRadianceOverAlpha: boolean;
  47682. /**
  47683. * Allows using an object space normal map (instead of tangent space).
  47684. */
  47685. useObjectSpaceNormalMap: boolean;
  47686. /**
  47687. * Allows using the bump map in parallax mode.
  47688. */
  47689. useParallax: boolean;
  47690. /**
  47691. * Allows using the bump map in parallax occlusion mode.
  47692. */
  47693. useParallaxOcclusion: boolean;
  47694. /**
  47695. * Controls the scale bias of the parallax mode.
  47696. */
  47697. parallaxScaleBias: number;
  47698. /**
  47699. * If sets to true, disables all the lights affecting the material.
  47700. */
  47701. disableLighting: boolean;
  47702. /**
  47703. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47704. */
  47705. forceIrradianceInFragment: boolean;
  47706. /**
  47707. * Number of Simultaneous lights allowed on the material.
  47708. */
  47709. maxSimultaneousLights: number;
  47710. /**
  47711. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47712. */
  47713. invertNormalMapX: boolean;
  47714. /**
  47715. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47716. */
  47717. invertNormalMapY: boolean;
  47718. /**
  47719. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47720. */
  47721. twoSidedLighting: boolean;
  47722. /**
  47723. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47724. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47725. */
  47726. useAlphaFresnel: boolean;
  47727. /**
  47728. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47729. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47730. */
  47731. useLinearAlphaFresnel: boolean;
  47732. /**
  47733. * Let user defines the brdf lookup texture used for IBL.
  47734. * A default 8bit version is embedded but you could point at :
  47735. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47736. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47737. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47738. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47739. */
  47740. environmentBRDFTexture: Nullable<BaseTexture>;
  47741. /**
  47742. * Force normal to face away from face.
  47743. */
  47744. forceNormalForward: boolean;
  47745. /**
  47746. * Enables specular anti aliasing in the PBR shader.
  47747. * It will both interacts on the Geometry for analytical and IBL lighting.
  47748. * It also prefilter the roughness map based on the bump values.
  47749. */
  47750. enableSpecularAntiAliasing: boolean;
  47751. /**
  47752. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47753. * makes the reflect vector face the model (under horizon).
  47754. */
  47755. useHorizonOcclusion: boolean;
  47756. /**
  47757. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47758. * too much the area relying on ambient texture to define their ambient occlusion.
  47759. */
  47760. useRadianceOcclusion: boolean;
  47761. /**
  47762. * If set to true, no lighting calculations will be applied.
  47763. */
  47764. unlit: boolean;
  47765. /**
  47766. * Gets the image processing configuration used either in this material.
  47767. */
  47768. /**
  47769. * Sets the Default image processing configuration used either in the this material.
  47770. *
  47771. * If sets to null, the scene one is in use.
  47772. */
  47773. imageProcessingConfiguration: ImageProcessingConfiguration;
  47774. /**
  47775. * Gets wether the color curves effect is enabled.
  47776. */
  47777. /**
  47778. * Sets wether the color curves effect is enabled.
  47779. */
  47780. cameraColorCurvesEnabled: boolean;
  47781. /**
  47782. * Gets wether the color grading effect is enabled.
  47783. */
  47784. /**
  47785. * Gets wether the color grading effect is enabled.
  47786. */
  47787. cameraColorGradingEnabled: boolean;
  47788. /**
  47789. * Gets wether tonemapping is enabled or not.
  47790. */
  47791. /**
  47792. * Sets wether tonemapping is enabled or not
  47793. */
  47794. cameraToneMappingEnabled: boolean;
  47795. /**
  47796. * The camera exposure used on this material.
  47797. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47798. * This corresponds to a photographic exposure.
  47799. */
  47800. /**
  47801. * The camera exposure used on this material.
  47802. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47803. * This corresponds to a photographic exposure.
  47804. */
  47805. cameraExposure: number;
  47806. /**
  47807. * Gets The camera contrast used on this material.
  47808. */
  47809. /**
  47810. * Sets The camera contrast used on this material.
  47811. */
  47812. cameraContrast: number;
  47813. /**
  47814. * Gets the Color Grading 2D Lookup Texture.
  47815. */
  47816. /**
  47817. * Sets the Color Grading 2D Lookup Texture.
  47818. */
  47819. cameraColorGradingTexture: Nullable<BaseTexture>;
  47820. /**
  47821. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47822. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47823. * 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;
  47824. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47825. */
  47826. /**
  47827. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47828. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47829. * 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;
  47830. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47831. */
  47832. cameraColorCurves: Nullable<ColorCurves>;
  47833. /**
  47834. * Instantiates a new PBRMaterial instance.
  47835. *
  47836. * @param name The material name
  47837. * @param scene The scene the material will be use in.
  47838. */
  47839. constructor(name: string, scene: Scene);
  47840. /**
  47841. * Returns the name of this material class.
  47842. */
  47843. getClassName(): string;
  47844. /**
  47845. * Makes a duplicate of the current material.
  47846. * @param name - name to use for the new material.
  47847. */
  47848. clone(name: string): PBRMaterial;
  47849. /**
  47850. * Serializes this PBR Material.
  47851. * @returns - An object with the serialized material.
  47852. */
  47853. serialize(): any;
  47854. /**
  47855. * Parses a PBR Material from a serialized object.
  47856. * @param source - Serialized object.
  47857. * @param scene - BJS scene instance.
  47858. * @param rootUrl - url for the scene object
  47859. * @returns - PBRMaterial
  47860. */
  47861. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47862. }
  47863. }
  47864. declare module "babylonjs/Misc/dds" {
  47865. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47866. import { Engine } from "babylonjs/Engines/engine";
  47867. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47868. import { Nullable } from "babylonjs/types";
  47869. import { Scene } from "babylonjs/scene";
  47870. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  47871. /**
  47872. * Direct draw surface info
  47873. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47874. */
  47875. export interface DDSInfo {
  47876. /**
  47877. * Width of the texture
  47878. */
  47879. width: number;
  47880. /**
  47881. * Width of the texture
  47882. */
  47883. height: number;
  47884. /**
  47885. * Number of Mipmaps for the texture
  47886. * @see https://en.wikipedia.org/wiki/Mipmap
  47887. */
  47888. mipmapCount: number;
  47889. /**
  47890. * If the textures format is a known fourCC format
  47891. * @see https://www.fourcc.org/
  47892. */
  47893. isFourCC: boolean;
  47894. /**
  47895. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47896. */
  47897. isRGB: boolean;
  47898. /**
  47899. * If the texture is a lumincance format
  47900. */
  47901. isLuminance: boolean;
  47902. /**
  47903. * If this is a cube texture
  47904. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47905. */
  47906. isCube: boolean;
  47907. /**
  47908. * If the texture is a compressed format eg. FOURCC_DXT1
  47909. */
  47910. isCompressed: boolean;
  47911. /**
  47912. * The dxgiFormat of the texture
  47913. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47914. */
  47915. dxgiFormat: number;
  47916. /**
  47917. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47918. */
  47919. textureType: number;
  47920. /**
  47921. * Sphericle polynomial created for the dds texture
  47922. */
  47923. sphericalPolynomial?: SphericalPolynomial;
  47924. }
  47925. /**
  47926. * Class used to provide DDS decompression tools
  47927. */
  47928. export class DDSTools {
  47929. /**
  47930. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47931. */
  47932. static StoreLODInAlphaChannel: boolean;
  47933. /**
  47934. * Gets DDS information from an array buffer
  47935. * @param arrayBuffer defines the array buffer to read data from
  47936. * @returns the DDS information
  47937. */
  47938. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47939. private static _FloatView;
  47940. private static _Int32View;
  47941. private static _ToHalfFloat;
  47942. private static _FromHalfFloat;
  47943. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47944. private static _GetHalfFloatRGBAArrayBuffer;
  47945. private static _GetFloatRGBAArrayBuffer;
  47946. private static _GetFloatAsUIntRGBAArrayBuffer;
  47947. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47948. private static _GetRGBAArrayBuffer;
  47949. private static _ExtractLongWordOrder;
  47950. private static _GetRGBArrayBuffer;
  47951. private static _GetLuminanceArrayBuffer;
  47952. /**
  47953. * Uploads DDS Levels to a Babylon Texture
  47954. * @hidden
  47955. */
  47956. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47957. }
  47958. module "babylonjs/Engines/engine" {
  47959. interface Engine {
  47960. /**
  47961. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47962. * @param rootUrl defines the url where the file to load is located
  47963. * @param scene defines the current scene
  47964. * @param lodScale defines scale to apply to the mip map selection
  47965. * @param lodOffset defines offset to apply to the mip map selection
  47966. * @param onLoad defines an optional callback raised when the texture is loaded
  47967. * @param onError defines an optional callback raised if there is an issue to load the texture
  47968. * @param format defines the format of the data
  47969. * @param forcedExtension defines the extension to use to pick the right loader
  47970. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47971. * @returns the cube texture as an InternalTexture
  47972. */
  47973. 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;
  47974. }
  47975. }
  47976. }
  47977. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47978. import { Nullable } from "babylonjs/types";
  47979. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47980. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47981. /**
  47982. * Implementation of the DDS Texture Loader.
  47983. * @hidden
  47984. */
  47985. export class _DDSTextureLoader implements IInternalTextureLoader {
  47986. /**
  47987. * Defines wether the loader supports cascade loading the different faces.
  47988. */
  47989. readonly supportCascades: boolean;
  47990. /**
  47991. * This returns if the loader support the current file information.
  47992. * @param extension defines the file extension of the file being loaded
  47993. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47994. * @param fallback defines the fallback internal texture if any
  47995. * @param isBase64 defines whether the texture is encoded as a base64
  47996. * @param isBuffer defines whether the texture data are stored as a buffer
  47997. * @returns true if the loader can load the specified file
  47998. */
  47999. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48000. /**
  48001. * Transform the url before loading if required.
  48002. * @param rootUrl the url of the texture
  48003. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48004. * @returns the transformed texture
  48005. */
  48006. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48007. /**
  48008. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48009. * @param rootUrl the url of the texture
  48010. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48011. * @returns the fallback texture
  48012. */
  48013. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48014. /**
  48015. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48016. * @param data contains the texture data
  48017. * @param texture defines the BabylonJS internal texture
  48018. * @param createPolynomials will be true if polynomials have been requested
  48019. * @param onLoad defines the callback to trigger once the texture is ready
  48020. * @param onError defines the callback to trigger in case of error
  48021. */
  48022. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48023. /**
  48024. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48025. * @param data contains the texture data
  48026. * @param texture defines the BabylonJS internal texture
  48027. * @param callback defines the method to call once ready to upload
  48028. */
  48029. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48030. }
  48031. }
  48032. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48033. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48034. /** @hidden */
  48035. export var rgbdEncodePixelShader: {
  48036. name: string;
  48037. shader: string;
  48038. };
  48039. }
  48040. declare module "babylonjs/Misc/environmentTextureTools" {
  48041. import { Nullable } from "babylonjs/types";
  48042. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48043. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48044. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48045. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48046. import "babylonjs/Shaders/rgbdEncode.fragment";
  48047. import "babylonjs/Shaders/rgbdDecode.fragment";
  48048. /**
  48049. * Raw texture data and descriptor sufficient for WebGL texture upload
  48050. */
  48051. export interface EnvironmentTextureInfo {
  48052. /**
  48053. * Version of the environment map
  48054. */
  48055. version: number;
  48056. /**
  48057. * Width of image
  48058. */
  48059. width: number;
  48060. /**
  48061. * Irradiance information stored in the file.
  48062. */
  48063. irradiance: any;
  48064. /**
  48065. * Specular information stored in the file.
  48066. */
  48067. specular: any;
  48068. }
  48069. /**
  48070. * Sets of helpers addressing the serialization and deserialization of environment texture
  48071. * stored in a BabylonJS env file.
  48072. * Those files are usually stored as .env files.
  48073. */
  48074. export class EnvironmentTextureTools {
  48075. /**
  48076. * Magic number identifying the env file.
  48077. */
  48078. private static _MagicBytes;
  48079. /**
  48080. * Gets the environment info from an env file.
  48081. * @param data The array buffer containing the .env bytes.
  48082. * @returns the environment file info (the json header) if successfully parsed.
  48083. */
  48084. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48085. /**
  48086. * Creates an environment texture from a loaded cube texture.
  48087. * @param texture defines the cube texture to convert in env file
  48088. * @return a promise containing the environment data if succesfull.
  48089. */
  48090. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48091. /**
  48092. * Creates a JSON representation of the spherical data.
  48093. * @param texture defines the texture containing the polynomials
  48094. * @return the JSON representation of the spherical info
  48095. */
  48096. private static _CreateEnvTextureIrradiance;
  48097. /**
  48098. * Uploads the texture info contained in the env file to the GPU.
  48099. * @param texture defines the internal texture to upload to
  48100. * @param arrayBuffer defines the buffer cotaining the data to load
  48101. * @param info defines the texture info retrieved through the GetEnvInfo method
  48102. * @returns a promise
  48103. */
  48104. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48105. /**
  48106. * Uploads the levels of image data to the GPU.
  48107. * @param texture defines the internal texture to upload to
  48108. * @param imageData defines the array buffer views of image data [mipmap][face]
  48109. * @returns a promise
  48110. */
  48111. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48112. /**
  48113. * Uploads spherical polynomials information to the texture.
  48114. * @param texture defines the texture we are trying to upload the information to
  48115. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48116. */
  48117. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48118. /** @hidden */
  48119. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48120. }
  48121. }
  48122. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48123. import { Nullable } from "babylonjs/types";
  48124. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48125. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48126. /**
  48127. * Implementation of the ENV Texture Loader.
  48128. * @hidden
  48129. */
  48130. export class _ENVTextureLoader implements IInternalTextureLoader {
  48131. /**
  48132. * Defines wether the loader supports cascade loading the different faces.
  48133. */
  48134. readonly supportCascades: boolean;
  48135. /**
  48136. * This returns if the loader support the current file information.
  48137. * @param extension defines the file extension of the file being loaded
  48138. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48139. * @param fallback defines the fallback internal texture if any
  48140. * @param isBase64 defines whether the texture is encoded as a base64
  48141. * @param isBuffer defines whether the texture data are stored as a buffer
  48142. * @returns true if the loader can load the specified file
  48143. */
  48144. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48145. /**
  48146. * Transform the url before loading if required.
  48147. * @param rootUrl the url of the texture
  48148. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48149. * @returns the transformed texture
  48150. */
  48151. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48152. /**
  48153. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48154. * @param rootUrl the url of the texture
  48155. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48156. * @returns the fallback texture
  48157. */
  48158. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48159. /**
  48160. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48161. * @param data contains the texture data
  48162. * @param texture defines the BabylonJS internal texture
  48163. * @param createPolynomials will be true if polynomials have been requested
  48164. * @param onLoad defines the callback to trigger once the texture is ready
  48165. * @param onError defines the callback to trigger in case of error
  48166. */
  48167. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48168. /**
  48169. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48170. * @param data contains the texture data
  48171. * @param texture defines the BabylonJS internal texture
  48172. * @param callback defines the method to call once ready to upload
  48173. */
  48174. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48175. }
  48176. }
  48177. declare module "babylonjs/Misc/khronosTextureContainer" {
  48178. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48179. /**
  48180. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48181. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48182. */
  48183. export class KhronosTextureContainer {
  48184. /** contents of the KTX container file */
  48185. arrayBuffer: any;
  48186. private static HEADER_LEN;
  48187. private static COMPRESSED_2D;
  48188. private static COMPRESSED_3D;
  48189. private static TEX_2D;
  48190. private static TEX_3D;
  48191. /**
  48192. * Gets the openGL type
  48193. */
  48194. glType: number;
  48195. /**
  48196. * Gets the openGL type size
  48197. */
  48198. glTypeSize: number;
  48199. /**
  48200. * Gets the openGL format
  48201. */
  48202. glFormat: number;
  48203. /**
  48204. * Gets the openGL internal format
  48205. */
  48206. glInternalFormat: number;
  48207. /**
  48208. * Gets the base internal format
  48209. */
  48210. glBaseInternalFormat: number;
  48211. /**
  48212. * Gets image width in pixel
  48213. */
  48214. pixelWidth: number;
  48215. /**
  48216. * Gets image height in pixel
  48217. */
  48218. pixelHeight: number;
  48219. /**
  48220. * Gets image depth in pixels
  48221. */
  48222. pixelDepth: number;
  48223. /**
  48224. * Gets the number of array elements
  48225. */
  48226. numberOfArrayElements: number;
  48227. /**
  48228. * Gets the number of faces
  48229. */
  48230. numberOfFaces: number;
  48231. /**
  48232. * Gets the number of mipmap levels
  48233. */
  48234. numberOfMipmapLevels: number;
  48235. /**
  48236. * Gets the bytes of key value data
  48237. */
  48238. bytesOfKeyValueData: number;
  48239. /**
  48240. * Gets the load type
  48241. */
  48242. loadType: number;
  48243. /**
  48244. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48245. */
  48246. isInvalid: boolean;
  48247. /**
  48248. * Creates a new KhronosTextureContainer
  48249. * @param arrayBuffer contents of the KTX container file
  48250. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48251. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48252. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48253. */
  48254. constructor(
  48255. /** contents of the KTX container file */
  48256. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48257. /**
  48258. * Uploads KTX content to a Babylon Texture.
  48259. * It is assumed that the texture has already been created & is currently bound
  48260. * @hidden
  48261. */
  48262. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48263. private _upload2DCompressedLevels;
  48264. }
  48265. }
  48266. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48267. import { Nullable } from "babylonjs/types";
  48268. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48269. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48270. /**
  48271. * Implementation of the KTX Texture Loader.
  48272. * @hidden
  48273. */
  48274. export class _KTXTextureLoader implements IInternalTextureLoader {
  48275. /**
  48276. * Defines wether the loader supports cascade loading the different faces.
  48277. */
  48278. readonly supportCascades: boolean;
  48279. /**
  48280. * This returns if the loader support the current file information.
  48281. * @param extension defines the file extension of the file being loaded
  48282. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48283. * @param fallback defines the fallback internal texture if any
  48284. * @param isBase64 defines whether the texture is encoded as a base64
  48285. * @param isBuffer defines whether the texture data are stored as a buffer
  48286. * @returns true if the loader can load the specified file
  48287. */
  48288. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48289. /**
  48290. * Transform the url before loading if required.
  48291. * @param rootUrl the url of the texture
  48292. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48293. * @returns the transformed texture
  48294. */
  48295. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48296. /**
  48297. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48298. * @param rootUrl the url of the texture
  48299. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48300. * @returns the fallback texture
  48301. */
  48302. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48303. /**
  48304. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48305. * @param data contains the texture data
  48306. * @param texture defines the BabylonJS internal texture
  48307. * @param createPolynomials will be true if polynomials have been requested
  48308. * @param onLoad defines the callback to trigger once the texture is ready
  48309. * @param onError defines the callback to trigger in case of error
  48310. */
  48311. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48312. /**
  48313. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48314. * @param data contains the texture data
  48315. * @param texture defines the BabylonJS internal texture
  48316. * @param callback defines the method to call once ready to upload
  48317. */
  48318. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48319. }
  48320. }
  48321. declare module "babylonjs/Helpers/sceneHelpers" {
  48322. import { Nullable } from "babylonjs/types";
  48323. import { Mesh } from "babylonjs/Meshes/mesh";
  48324. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48325. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48326. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48327. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48328. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48329. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48330. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48331. import "babylonjs/Meshes/Builders/boxBuilder";
  48332. /** @hidden */
  48333. export var _forceSceneHelpersToBundle: boolean;
  48334. module "babylonjs/scene" {
  48335. interface Scene {
  48336. /**
  48337. * Creates a default light for the scene.
  48338. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48339. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48340. */
  48341. createDefaultLight(replace?: boolean): void;
  48342. /**
  48343. * Creates a default camera for the scene.
  48344. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48345. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48346. * @param replace has default false, when true replaces the active camera in the scene
  48347. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48348. */
  48349. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48350. /**
  48351. * Creates a default camera and a default light.
  48352. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48353. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48354. * @param replace has the default false, when true replaces the active camera/light in the scene
  48355. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48356. */
  48357. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48358. /**
  48359. * Creates a new sky box
  48360. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48361. * @param environmentTexture defines the texture to use as environment texture
  48362. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48363. * @param scale defines the overall scale of the skybox
  48364. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48365. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48366. * @returns a new mesh holding the sky box
  48367. */
  48368. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48369. /**
  48370. * Creates a new environment
  48371. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48372. * @param options defines the options you can use to configure the environment
  48373. * @returns the new EnvironmentHelper
  48374. */
  48375. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48376. /**
  48377. * Creates a new VREXperienceHelper
  48378. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48379. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48380. * @returns a new VREXperienceHelper
  48381. */
  48382. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48383. /**
  48384. * Creates a new XREXperienceHelper
  48385. * @see http://doc.babylonjs.com/how_to/webxr
  48386. * @returns a promise for a new XREXperienceHelper
  48387. */
  48388. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48389. }
  48390. }
  48391. }
  48392. declare module "babylonjs/Helpers/videoDome" {
  48393. import { Scene } from "babylonjs/scene";
  48394. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48395. import { Mesh } from "babylonjs/Meshes/mesh";
  48396. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48397. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48398. import "babylonjs/Meshes/Builders/sphereBuilder";
  48399. /**
  48400. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48401. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48402. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48403. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48404. */
  48405. export class VideoDome extends TransformNode {
  48406. /**
  48407. * Define the video source as a Monoscopic panoramic 360 video.
  48408. */
  48409. static readonly MODE_MONOSCOPIC: number;
  48410. /**
  48411. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48412. */
  48413. static readonly MODE_TOPBOTTOM: number;
  48414. /**
  48415. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48416. */
  48417. static readonly MODE_SIDEBYSIDE: number;
  48418. private _useDirectMapping;
  48419. /**
  48420. * The video texture being displayed on the sphere
  48421. */
  48422. protected _videoTexture: VideoTexture;
  48423. /**
  48424. * Gets the video texture being displayed on the sphere
  48425. */
  48426. readonly videoTexture: VideoTexture;
  48427. /**
  48428. * The skybox material
  48429. */
  48430. protected _material: BackgroundMaterial;
  48431. /**
  48432. * The surface used for the skybox
  48433. */
  48434. protected _mesh: Mesh;
  48435. /**
  48436. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48437. * Also see the options.resolution property.
  48438. */
  48439. fovMultiplier: number;
  48440. private _videoMode;
  48441. /**
  48442. * Gets or set the current video mode for the video. It can be:
  48443. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48444. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48445. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48446. */
  48447. videoMode: number;
  48448. /**
  48449. * Oberserver used in Stereoscopic VR Mode.
  48450. */
  48451. private _onBeforeCameraRenderObserver;
  48452. /**
  48453. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48454. * @param name Element's name, child elements will append suffixes for their own names.
  48455. * @param urlsOrVideo defines the url(s) or the video element to use
  48456. * @param options An object containing optional or exposed sub element properties
  48457. */
  48458. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48459. resolution?: number;
  48460. clickToPlay?: boolean;
  48461. autoPlay?: boolean;
  48462. loop?: boolean;
  48463. size?: number;
  48464. poster?: string;
  48465. faceForward?: boolean;
  48466. useDirectMapping?: boolean;
  48467. }, scene: Scene);
  48468. private _changeVideoMode;
  48469. /**
  48470. * Releases resources associated with this node.
  48471. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48472. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48473. */
  48474. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48475. }
  48476. }
  48477. declare module "babylonjs/Helpers/index" {
  48478. export * from "babylonjs/Helpers/environmentHelper";
  48479. export * from "babylonjs/Helpers/photoDome";
  48480. export * from "babylonjs/Helpers/sceneHelpers";
  48481. export * from "babylonjs/Helpers/videoDome";
  48482. }
  48483. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48484. import { PerfCounter } from "babylonjs/Misc/tools";
  48485. import { IDisposable } from "babylonjs/scene";
  48486. import { Engine } from "babylonjs/Engines/engine";
  48487. /**
  48488. * This class can be used to get instrumentation data from a Babylon engine
  48489. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48490. */
  48491. export class EngineInstrumentation implements IDisposable {
  48492. /**
  48493. * Define the instrumented engine.
  48494. */
  48495. engine: Engine;
  48496. private _captureGPUFrameTime;
  48497. private _gpuFrameTimeToken;
  48498. private _gpuFrameTime;
  48499. private _captureShaderCompilationTime;
  48500. private _shaderCompilationTime;
  48501. private _onBeginFrameObserver;
  48502. private _onEndFrameObserver;
  48503. private _onBeforeShaderCompilationObserver;
  48504. private _onAfterShaderCompilationObserver;
  48505. /**
  48506. * Gets the perf counter used for GPU frame time
  48507. */
  48508. readonly gpuFrameTimeCounter: PerfCounter;
  48509. /**
  48510. * Gets the GPU frame time capture status
  48511. */
  48512. /**
  48513. * Enable or disable the GPU frame time capture
  48514. */
  48515. captureGPUFrameTime: boolean;
  48516. /**
  48517. * Gets the perf counter used for shader compilation time
  48518. */
  48519. readonly shaderCompilationTimeCounter: PerfCounter;
  48520. /**
  48521. * Gets the shader compilation time capture status
  48522. */
  48523. /**
  48524. * Enable or disable the shader compilation time capture
  48525. */
  48526. captureShaderCompilationTime: boolean;
  48527. /**
  48528. * Instantiates a new engine instrumentation.
  48529. * This class can be used to get instrumentation data from a Babylon engine
  48530. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48531. * @param engine Defines the engine to instrument
  48532. */
  48533. constructor(
  48534. /**
  48535. * Define the instrumented engine.
  48536. */
  48537. engine: Engine);
  48538. /**
  48539. * Dispose and release associated resources.
  48540. */
  48541. dispose(): void;
  48542. }
  48543. }
  48544. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48545. import { PerfCounter } from "babylonjs/Misc/tools";
  48546. import { Scene, IDisposable } from "babylonjs/scene";
  48547. /**
  48548. * This class can be used to get instrumentation data from a Babylon engine
  48549. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48550. */
  48551. export class SceneInstrumentation implements IDisposable {
  48552. /**
  48553. * Defines the scene to instrument
  48554. */
  48555. scene: Scene;
  48556. private _captureActiveMeshesEvaluationTime;
  48557. private _activeMeshesEvaluationTime;
  48558. private _captureRenderTargetsRenderTime;
  48559. private _renderTargetsRenderTime;
  48560. private _captureFrameTime;
  48561. private _frameTime;
  48562. private _captureRenderTime;
  48563. private _renderTime;
  48564. private _captureInterFrameTime;
  48565. private _interFrameTime;
  48566. private _captureParticlesRenderTime;
  48567. private _particlesRenderTime;
  48568. private _captureSpritesRenderTime;
  48569. private _spritesRenderTime;
  48570. private _capturePhysicsTime;
  48571. private _physicsTime;
  48572. private _captureAnimationsTime;
  48573. private _animationsTime;
  48574. private _captureCameraRenderTime;
  48575. private _cameraRenderTime;
  48576. private _onBeforeActiveMeshesEvaluationObserver;
  48577. private _onAfterActiveMeshesEvaluationObserver;
  48578. private _onBeforeRenderTargetsRenderObserver;
  48579. private _onAfterRenderTargetsRenderObserver;
  48580. private _onAfterRenderObserver;
  48581. private _onBeforeDrawPhaseObserver;
  48582. private _onAfterDrawPhaseObserver;
  48583. private _onBeforeAnimationsObserver;
  48584. private _onBeforeParticlesRenderingObserver;
  48585. private _onAfterParticlesRenderingObserver;
  48586. private _onBeforeSpritesRenderingObserver;
  48587. private _onAfterSpritesRenderingObserver;
  48588. private _onBeforePhysicsObserver;
  48589. private _onAfterPhysicsObserver;
  48590. private _onAfterAnimationsObserver;
  48591. private _onBeforeCameraRenderObserver;
  48592. private _onAfterCameraRenderObserver;
  48593. /**
  48594. * Gets the perf counter used for active meshes evaluation time
  48595. */
  48596. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48597. /**
  48598. * Gets the active meshes evaluation time capture status
  48599. */
  48600. /**
  48601. * Enable or disable the active meshes evaluation time capture
  48602. */
  48603. captureActiveMeshesEvaluationTime: boolean;
  48604. /**
  48605. * Gets the perf counter used for render targets render time
  48606. */
  48607. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48608. /**
  48609. * Gets the render targets render time capture status
  48610. */
  48611. /**
  48612. * Enable or disable the render targets render time capture
  48613. */
  48614. captureRenderTargetsRenderTime: boolean;
  48615. /**
  48616. * Gets the perf counter used for particles render time
  48617. */
  48618. readonly particlesRenderTimeCounter: PerfCounter;
  48619. /**
  48620. * Gets the particles render time capture status
  48621. */
  48622. /**
  48623. * Enable or disable the particles render time capture
  48624. */
  48625. captureParticlesRenderTime: boolean;
  48626. /**
  48627. * Gets the perf counter used for sprites render time
  48628. */
  48629. readonly spritesRenderTimeCounter: PerfCounter;
  48630. /**
  48631. * Gets the sprites render time capture status
  48632. */
  48633. /**
  48634. * Enable or disable the sprites render time capture
  48635. */
  48636. captureSpritesRenderTime: boolean;
  48637. /**
  48638. * Gets the perf counter used for physics time
  48639. */
  48640. readonly physicsTimeCounter: PerfCounter;
  48641. /**
  48642. * Gets the physics time capture status
  48643. */
  48644. /**
  48645. * Enable or disable the physics time capture
  48646. */
  48647. capturePhysicsTime: boolean;
  48648. /**
  48649. * Gets the perf counter used for animations time
  48650. */
  48651. readonly animationsTimeCounter: PerfCounter;
  48652. /**
  48653. * Gets the animations time capture status
  48654. */
  48655. /**
  48656. * Enable or disable the animations time capture
  48657. */
  48658. captureAnimationsTime: boolean;
  48659. /**
  48660. * Gets the perf counter used for frame time capture
  48661. */
  48662. readonly frameTimeCounter: PerfCounter;
  48663. /**
  48664. * Gets the frame time capture status
  48665. */
  48666. /**
  48667. * Enable or disable the frame time capture
  48668. */
  48669. captureFrameTime: boolean;
  48670. /**
  48671. * Gets the perf counter used for inter-frames time capture
  48672. */
  48673. readonly interFrameTimeCounter: PerfCounter;
  48674. /**
  48675. * Gets the inter-frames time capture status
  48676. */
  48677. /**
  48678. * Enable or disable the inter-frames time capture
  48679. */
  48680. captureInterFrameTime: boolean;
  48681. /**
  48682. * Gets the perf counter used for render time capture
  48683. */
  48684. readonly renderTimeCounter: PerfCounter;
  48685. /**
  48686. * Gets the render time capture status
  48687. */
  48688. /**
  48689. * Enable or disable the render time capture
  48690. */
  48691. captureRenderTime: boolean;
  48692. /**
  48693. * Gets the perf counter used for camera render time capture
  48694. */
  48695. readonly cameraRenderTimeCounter: PerfCounter;
  48696. /**
  48697. * Gets the camera render time capture status
  48698. */
  48699. /**
  48700. * Enable or disable the camera render time capture
  48701. */
  48702. captureCameraRenderTime: boolean;
  48703. /**
  48704. * Gets the perf counter used for draw calls
  48705. */
  48706. readonly drawCallsCounter: PerfCounter;
  48707. /**
  48708. * Instantiates a new scene instrumentation.
  48709. * This class can be used to get instrumentation data from a Babylon engine
  48710. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48711. * @param scene Defines the scene to instrument
  48712. */
  48713. constructor(
  48714. /**
  48715. * Defines the scene to instrument
  48716. */
  48717. scene: Scene);
  48718. /**
  48719. * Dispose and release associated resources.
  48720. */
  48721. dispose(): void;
  48722. }
  48723. }
  48724. declare module "babylonjs/Instrumentation/index" {
  48725. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48726. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48727. export * from "babylonjs/Instrumentation/timeToken";
  48728. }
  48729. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48730. /** @hidden */
  48731. export var glowMapGenerationPixelShader: {
  48732. name: string;
  48733. shader: string;
  48734. };
  48735. }
  48736. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48737. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48738. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48739. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48740. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48741. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48742. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48743. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48744. /** @hidden */
  48745. export var glowMapGenerationVertexShader: {
  48746. name: string;
  48747. shader: string;
  48748. };
  48749. }
  48750. declare module "babylonjs/Layers/effectLayer" {
  48751. import { Observable } from "babylonjs/Misc/observable";
  48752. import { Nullable } from "babylonjs/types";
  48753. import { Camera } from "babylonjs/Cameras/camera";
  48754. import { Scene } from "babylonjs/scene";
  48755. import { Color4, ISize } from "babylonjs/Maths/math";
  48756. import { Engine } from "babylonjs/Engines/engine";
  48757. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48759. import { Mesh } from "babylonjs/Meshes/mesh";
  48760. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48761. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48762. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48763. import { Effect } from "babylonjs/Materials/effect";
  48764. import { Material } from "babylonjs/Materials/material";
  48765. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48766. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48767. /**
  48768. * Effect layer options. This helps customizing the behaviour
  48769. * of the effect layer.
  48770. */
  48771. export interface IEffectLayerOptions {
  48772. /**
  48773. * Multiplication factor apply to the canvas size to compute the render target size
  48774. * used to generated the objects (the smaller the faster).
  48775. */
  48776. mainTextureRatio: number;
  48777. /**
  48778. * Enforces a fixed size texture to ensure effect stability across devices.
  48779. */
  48780. mainTextureFixedSize?: number;
  48781. /**
  48782. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48783. */
  48784. alphaBlendingMode: number;
  48785. /**
  48786. * The camera attached to the layer.
  48787. */
  48788. camera: Nullable<Camera>;
  48789. /**
  48790. * The rendering group to draw the layer in.
  48791. */
  48792. renderingGroupId: number;
  48793. }
  48794. /**
  48795. * The effect layer Helps adding post process effect blended with the main pass.
  48796. *
  48797. * This can be for instance use to generate glow or higlight effects on the scene.
  48798. *
  48799. * The effect layer class can not be used directly and is intented to inherited from to be
  48800. * customized per effects.
  48801. */
  48802. export abstract class EffectLayer {
  48803. private _vertexBuffers;
  48804. private _indexBuffer;
  48805. private _cachedDefines;
  48806. private _effectLayerMapGenerationEffect;
  48807. private _effectLayerOptions;
  48808. private _mergeEffect;
  48809. protected _scene: Scene;
  48810. protected _engine: Engine;
  48811. protected _maxSize: number;
  48812. protected _mainTextureDesiredSize: ISize;
  48813. protected _mainTexture: RenderTargetTexture;
  48814. protected _shouldRender: boolean;
  48815. protected _postProcesses: PostProcess[];
  48816. protected _textures: BaseTexture[];
  48817. protected _emissiveTextureAndColor: {
  48818. texture: Nullable<BaseTexture>;
  48819. color: Color4;
  48820. };
  48821. /**
  48822. * The name of the layer
  48823. */
  48824. name: string;
  48825. /**
  48826. * The clear color of the texture used to generate the glow map.
  48827. */
  48828. neutralColor: Color4;
  48829. /**
  48830. * Specifies wether the highlight layer is enabled or not.
  48831. */
  48832. isEnabled: boolean;
  48833. /**
  48834. * Gets the camera attached to the layer.
  48835. */
  48836. readonly camera: Nullable<Camera>;
  48837. /**
  48838. * Gets the rendering group id the layer should render in.
  48839. */
  48840. readonly renderingGroupId: number;
  48841. /**
  48842. * An event triggered when the effect layer has been disposed.
  48843. */
  48844. onDisposeObservable: Observable<EffectLayer>;
  48845. /**
  48846. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48847. */
  48848. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48849. /**
  48850. * An event triggered when the generated texture is being merged in the scene.
  48851. */
  48852. onBeforeComposeObservable: Observable<EffectLayer>;
  48853. /**
  48854. * An event triggered when the generated texture has been merged in the scene.
  48855. */
  48856. onAfterComposeObservable: Observable<EffectLayer>;
  48857. /**
  48858. * An event triggered when the efffect layer changes its size.
  48859. */
  48860. onSizeChangedObservable: Observable<EffectLayer>;
  48861. /** @hidden */
  48862. static _SceneComponentInitialization: (scene: Scene) => void;
  48863. /**
  48864. * Instantiates a new effect Layer and references it in the scene.
  48865. * @param name The name of the layer
  48866. * @param scene The scene to use the layer in
  48867. */
  48868. constructor(
  48869. /** The Friendly of the effect in the scene */
  48870. name: string, scene: Scene);
  48871. /**
  48872. * Get the effect name of the layer.
  48873. * @return The effect name
  48874. */
  48875. abstract getEffectName(): string;
  48876. /**
  48877. * Checks for the readiness of the element composing the layer.
  48878. * @param subMesh the mesh to check for
  48879. * @param useInstances specify wether or not to use instances to render the mesh
  48880. * @return true if ready otherwise, false
  48881. */
  48882. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48883. /**
  48884. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48885. * @returns true if the effect requires stencil during the main canvas render pass.
  48886. */
  48887. abstract needStencil(): boolean;
  48888. /**
  48889. * Create the merge effect. This is the shader use to blit the information back
  48890. * to the main canvas at the end of the scene rendering.
  48891. * @returns The effect containing the shader used to merge the effect on the main canvas
  48892. */
  48893. protected abstract _createMergeEffect(): Effect;
  48894. /**
  48895. * Creates the render target textures and post processes used in the effect layer.
  48896. */
  48897. protected abstract _createTextureAndPostProcesses(): void;
  48898. /**
  48899. * Implementation specific of rendering the generating effect on the main canvas.
  48900. * @param effect The effect used to render through
  48901. */
  48902. protected abstract _internalRender(effect: Effect): void;
  48903. /**
  48904. * Sets the required values for both the emissive texture and and the main color.
  48905. */
  48906. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48907. /**
  48908. * Free any resources and references associated to a mesh.
  48909. * Internal use
  48910. * @param mesh The mesh to free.
  48911. */
  48912. abstract _disposeMesh(mesh: Mesh): void;
  48913. /**
  48914. * Serializes this layer (Glow or Highlight for example)
  48915. * @returns a serialized layer object
  48916. */
  48917. abstract serialize?(): any;
  48918. /**
  48919. * Initializes the effect layer with the required options.
  48920. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48921. */
  48922. protected _init(options: Partial<IEffectLayerOptions>): void;
  48923. /**
  48924. * Generates the index buffer of the full screen quad blending to the main canvas.
  48925. */
  48926. private _generateIndexBuffer;
  48927. /**
  48928. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48929. */
  48930. private _generateVertexBuffer;
  48931. /**
  48932. * Sets the main texture desired size which is the closest power of two
  48933. * of the engine canvas size.
  48934. */
  48935. private _setMainTextureSize;
  48936. /**
  48937. * Creates the main texture for the effect layer.
  48938. */
  48939. protected _createMainTexture(): void;
  48940. /**
  48941. * Adds specific effects defines.
  48942. * @param defines The defines to add specifics to.
  48943. */
  48944. protected _addCustomEffectDefines(defines: string[]): void;
  48945. /**
  48946. * Checks for the readiness of the element composing the layer.
  48947. * @param subMesh the mesh to check for
  48948. * @param useInstances specify wether or not to use instances to render the mesh
  48949. * @param emissiveTexture the associated emissive texture used to generate the glow
  48950. * @return true if ready otherwise, false
  48951. */
  48952. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48953. /**
  48954. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48955. */
  48956. render(): void;
  48957. /**
  48958. * Determine if a given mesh will be used in the current effect.
  48959. * @param mesh mesh to test
  48960. * @returns true if the mesh will be used
  48961. */
  48962. hasMesh(mesh: AbstractMesh): boolean;
  48963. /**
  48964. * Returns true if the layer contains information to display, otherwise false.
  48965. * @returns true if the glow layer should be rendered
  48966. */
  48967. shouldRender(): boolean;
  48968. /**
  48969. * Returns true if the mesh should render, otherwise false.
  48970. * @param mesh The mesh to render
  48971. * @returns true if it should render otherwise false
  48972. */
  48973. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48974. /**
  48975. * Returns true if the mesh can be rendered, otherwise false.
  48976. * @param mesh The mesh to render
  48977. * @param material The material used on the mesh
  48978. * @returns true if it can be rendered otherwise false
  48979. */
  48980. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48981. /**
  48982. * Returns true if the mesh should render, otherwise false.
  48983. * @param mesh The mesh to render
  48984. * @returns true if it should render otherwise false
  48985. */
  48986. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48987. /**
  48988. * Renders the submesh passed in parameter to the generation map.
  48989. */
  48990. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48991. /**
  48992. * Rebuild the required buffers.
  48993. * @hidden Internal use only.
  48994. */
  48995. _rebuild(): void;
  48996. /**
  48997. * Dispose only the render target textures and post process.
  48998. */
  48999. private _disposeTextureAndPostProcesses;
  49000. /**
  49001. * Dispose the highlight layer and free resources.
  49002. */
  49003. dispose(): void;
  49004. /**
  49005. * Gets the class name of the effect layer
  49006. * @returns the string with the class name of the effect layer
  49007. */
  49008. getClassName(): string;
  49009. /**
  49010. * Creates an effect layer from parsed effect layer data
  49011. * @param parsedEffectLayer defines effect layer data
  49012. * @param scene defines the current scene
  49013. * @param rootUrl defines the root URL containing the effect layer information
  49014. * @returns a parsed effect Layer
  49015. */
  49016. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49017. }
  49018. }
  49019. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49020. import { Scene } from "babylonjs/scene";
  49021. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49022. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49023. import { AbstractScene } from "babylonjs/abstractScene";
  49024. module "babylonjs/abstractScene" {
  49025. interface AbstractScene {
  49026. /**
  49027. * The list of effect layers (highlights/glow) added to the scene
  49028. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49029. * @see http://doc.babylonjs.com/how_to/glow_layer
  49030. */
  49031. effectLayers: Array<EffectLayer>;
  49032. /**
  49033. * Removes the given effect layer from this scene.
  49034. * @param toRemove defines the effect layer to remove
  49035. * @returns the index of the removed effect layer
  49036. */
  49037. removeEffectLayer(toRemove: EffectLayer): number;
  49038. /**
  49039. * Adds the given effect layer to this scene
  49040. * @param newEffectLayer defines the effect layer to add
  49041. */
  49042. addEffectLayer(newEffectLayer: EffectLayer): void;
  49043. }
  49044. }
  49045. /**
  49046. * Defines the layer scene component responsible to manage any effect layers
  49047. * in a given scene.
  49048. */
  49049. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49050. /**
  49051. * The component name helpfull to identify the component in the list of scene components.
  49052. */
  49053. readonly name: string;
  49054. /**
  49055. * The scene the component belongs to.
  49056. */
  49057. scene: Scene;
  49058. private _engine;
  49059. private _renderEffects;
  49060. private _needStencil;
  49061. private _previousStencilState;
  49062. /**
  49063. * Creates a new instance of the component for the given scene
  49064. * @param scene Defines the scene to register the component in
  49065. */
  49066. constructor(scene: Scene);
  49067. /**
  49068. * Registers the component in a given scene
  49069. */
  49070. register(): void;
  49071. /**
  49072. * Rebuilds the elements related to this component in case of
  49073. * context lost for instance.
  49074. */
  49075. rebuild(): void;
  49076. /**
  49077. * Serializes the component data to the specified json object
  49078. * @param serializationObject The object to serialize to
  49079. */
  49080. serialize(serializationObject: any): void;
  49081. /**
  49082. * Adds all the element from the container to the scene
  49083. * @param container the container holding the elements
  49084. */
  49085. addFromContainer(container: AbstractScene): void;
  49086. /**
  49087. * Removes all the elements in the container from the scene
  49088. * @param container contains the elements to remove
  49089. * @param dispose if the removed element should be disposed (default: false)
  49090. */
  49091. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49092. /**
  49093. * Disposes the component and the associated ressources.
  49094. */
  49095. dispose(): void;
  49096. private _isReadyForMesh;
  49097. private _renderMainTexture;
  49098. private _setStencil;
  49099. private _setStencilBack;
  49100. private _draw;
  49101. private _drawCamera;
  49102. private _drawRenderingGroup;
  49103. }
  49104. }
  49105. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49106. /** @hidden */
  49107. export var glowMapMergePixelShader: {
  49108. name: string;
  49109. shader: string;
  49110. };
  49111. }
  49112. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49113. /** @hidden */
  49114. export var glowMapMergeVertexShader: {
  49115. name: string;
  49116. shader: string;
  49117. };
  49118. }
  49119. declare module "babylonjs/Layers/glowLayer" {
  49120. import { Nullable } from "babylonjs/types";
  49121. import { Camera } from "babylonjs/Cameras/camera";
  49122. import { Scene } from "babylonjs/scene";
  49123. import { Color4 } from "babylonjs/Maths/math";
  49124. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49126. import { Mesh } from "babylonjs/Meshes/mesh";
  49127. import { Texture } from "babylonjs/Materials/Textures/texture";
  49128. import { Effect } from "babylonjs/Materials/effect";
  49129. import { Material } from "babylonjs/Materials/material";
  49130. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49131. import "babylonjs/Shaders/glowMapMerge.fragment";
  49132. import "babylonjs/Shaders/glowMapMerge.vertex";
  49133. import "babylonjs/Layers/effectLayerSceneComponent";
  49134. module "babylonjs/abstractScene" {
  49135. interface AbstractScene {
  49136. /**
  49137. * Return a the first highlight layer of the scene with a given name.
  49138. * @param name The name of the highlight layer to look for.
  49139. * @return The highlight layer if found otherwise null.
  49140. */
  49141. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49142. }
  49143. }
  49144. /**
  49145. * Glow layer options. This helps customizing the behaviour
  49146. * of the glow layer.
  49147. */
  49148. export interface IGlowLayerOptions {
  49149. /**
  49150. * Multiplication factor apply to the canvas size to compute the render target size
  49151. * used to generated the glowing objects (the smaller the faster).
  49152. */
  49153. mainTextureRatio: number;
  49154. /**
  49155. * Enforces a fixed size texture to ensure resize independant blur.
  49156. */
  49157. mainTextureFixedSize?: number;
  49158. /**
  49159. * How big is the kernel of the blur texture.
  49160. */
  49161. blurKernelSize: number;
  49162. /**
  49163. * The camera attached to the layer.
  49164. */
  49165. camera: Nullable<Camera>;
  49166. /**
  49167. * Enable MSAA by chosing the number of samples.
  49168. */
  49169. mainTextureSamples?: number;
  49170. /**
  49171. * The rendering group to draw the layer in.
  49172. */
  49173. renderingGroupId: number;
  49174. }
  49175. /**
  49176. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49177. *
  49178. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49179. * glowy meshes to your scene.
  49180. *
  49181. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49182. */
  49183. export class GlowLayer extends EffectLayer {
  49184. /**
  49185. * Effect Name of the layer.
  49186. */
  49187. static readonly EffectName: string;
  49188. /**
  49189. * The default blur kernel size used for the glow.
  49190. */
  49191. static DefaultBlurKernelSize: number;
  49192. /**
  49193. * The default texture size ratio used for the glow.
  49194. */
  49195. static DefaultTextureRatio: number;
  49196. /**
  49197. * Sets the kernel size of the blur.
  49198. */
  49199. /**
  49200. * Gets the kernel size of the blur.
  49201. */
  49202. blurKernelSize: number;
  49203. /**
  49204. * Sets the glow intensity.
  49205. */
  49206. /**
  49207. * Gets the glow intensity.
  49208. */
  49209. intensity: number;
  49210. private _options;
  49211. private _intensity;
  49212. private _horizontalBlurPostprocess1;
  49213. private _verticalBlurPostprocess1;
  49214. private _horizontalBlurPostprocess2;
  49215. private _verticalBlurPostprocess2;
  49216. private _blurTexture1;
  49217. private _blurTexture2;
  49218. private _postProcesses1;
  49219. private _postProcesses2;
  49220. private _includedOnlyMeshes;
  49221. private _excludedMeshes;
  49222. /**
  49223. * Callback used to let the user override the color selection on a per mesh basis
  49224. */
  49225. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49226. /**
  49227. * Callback used to let the user override the texture selection on a per mesh basis
  49228. */
  49229. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49230. /**
  49231. * Instantiates a new glow Layer and references it to the scene.
  49232. * @param name The name of the layer
  49233. * @param scene The scene to use the layer in
  49234. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49235. */
  49236. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49237. /**
  49238. * Get the effect name of the layer.
  49239. * @return The effect name
  49240. */
  49241. getEffectName(): string;
  49242. /**
  49243. * Create the merge effect. This is the shader use to blit the information back
  49244. * to the main canvas at the end of the scene rendering.
  49245. */
  49246. protected _createMergeEffect(): Effect;
  49247. /**
  49248. * Creates the render target textures and post processes used in the glow layer.
  49249. */
  49250. protected _createTextureAndPostProcesses(): void;
  49251. /**
  49252. * Checks for the readiness of the element composing the layer.
  49253. * @param subMesh the mesh to check for
  49254. * @param useInstances specify wether or not to use instances to render the mesh
  49255. * @param emissiveTexture the associated emissive texture used to generate the glow
  49256. * @return true if ready otherwise, false
  49257. */
  49258. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49259. /**
  49260. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49261. */
  49262. needStencil(): boolean;
  49263. /**
  49264. * Returns true if the mesh can be rendered, otherwise false.
  49265. * @param mesh The mesh to render
  49266. * @param material The material used on the mesh
  49267. * @returns true if it can be rendered otherwise false
  49268. */
  49269. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49270. /**
  49271. * Implementation specific of rendering the generating effect on the main canvas.
  49272. * @param effect The effect used to render through
  49273. */
  49274. protected _internalRender(effect: Effect): void;
  49275. /**
  49276. * Sets the required values for both the emissive texture and and the main color.
  49277. */
  49278. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49279. /**
  49280. * Returns true if the mesh should render, otherwise false.
  49281. * @param mesh The mesh to render
  49282. * @returns true if it should render otherwise false
  49283. */
  49284. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49285. /**
  49286. * Adds specific effects defines.
  49287. * @param defines The defines to add specifics to.
  49288. */
  49289. protected _addCustomEffectDefines(defines: string[]): void;
  49290. /**
  49291. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49292. * @param mesh The mesh to exclude from the glow layer
  49293. */
  49294. addExcludedMesh(mesh: Mesh): void;
  49295. /**
  49296. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49297. * @param mesh The mesh to remove
  49298. */
  49299. removeExcludedMesh(mesh: Mesh): void;
  49300. /**
  49301. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49302. * @param mesh The mesh to include in the glow layer
  49303. */
  49304. addIncludedOnlyMesh(mesh: Mesh): void;
  49305. /**
  49306. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49307. * @param mesh The mesh to remove
  49308. */
  49309. removeIncludedOnlyMesh(mesh: Mesh): void;
  49310. /**
  49311. * Determine if a given mesh will be used in the glow layer
  49312. * @param mesh The mesh to test
  49313. * @returns true if the mesh will be highlighted by the current glow layer
  49314. */
  49315. hasMesh(mesh: AbstractMesh): boolean;
  49316. /**
  49317. * Free any resources and references associated to a mesh.
  49318. * Internal use
  49319. * @param mesh The mesh to free.
  49320. * @hidden
  49321. */
  49322. _disposeMesh(mesh: Mesh): void;
  49323. /**
  49324. * Gets the class name of the effect layer
  49325. * @returns the string with the class name of the effect layer
  49326. */
  49327. getClassName(): string;
  49328. /**
  49329. * Serializes this glow layer
  49330. * @returns a serialized glow layer object
  49331. */
  49332. serialize(): any;
  49333. /**
  49334. * Creates a Glow Layer from parsed glow layer data
  49335. * @param parsedGlowLayer defines glow layer data
  49336. * @param scene defines the current scene
  49337. * @param rootUrl defines the root URL containing the glow layer information
  49338. * @returns a parsed Glow Layer
  49339. */
  49340. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49341. }
  49342. }
  49343. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49344. /** @hidden */
  49345. export var glowBlurPostProcessPixelShader: {
  49346. name: string;
  49347. shader: string;
  49348. };
  49349. }
  49350. declare module "babylonjs/Layers/highlightLayer" {
  49351. import { Observable } from "babylonjs/Misc/observable";
  49352. import { Nullable } from "babylonjs/types";
  49353. import { Camera } from "babylonjs/Cameras/camera";
  49354. import { Scene } from "babylonjs/scene";
  49355. import { Color3, Color4 } from "babylonjs/Maths/math";
  49356. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49358. import { Mesh } from "babylonjs/Meshes/mesh";
  49359. import { Effect } from "babylonjs/Materials/effect";
  49360. import { Material } from "babylonjs/Materials/material";
  49361. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49362. import "babylonjs/Shaders/glowMapMerge.fragment";
  49363. import "babylonjs/Shaders/glowMapMerge.vertex";
  49364. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49365. module "babylonjs/abstractScene" {
  49366. interface AbstractScene {
  49367. /**
  49368. * Return a the first highlight layer of the scene with a given name.
  49369. * @param name The name of the highlight layer to look for.
  49370. * @return The highlight layer if found otherwise null.
  49371. */
  49372. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49373. }
  49374. }
  49375. /**
  49376. * Highlight layer options. This helps customizing the behaviour
  49377. * of the highlight layer.
  49378. */
  49379. export interface IHighlightLayerOptions {
  49380. /**
  49381. * Multiplication factor apply to the canvas size to compute the render target size
  49382. * used to generated the glowing objects (the smaller the faster).
  49383. */
  49384. mainTextureRatio: number;
  49385. /**
  49386. * Enforces a fixed size texture to ensure resize independant blur.
  49387. */
  49388. mainTextureFixedSize?: number;
  49389. /**
  49390. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49391. * of the picture to blur (the smaller the faster).
  49392. */
  49393. blurTextureSizeRatio: number;
  49394. /**
  49395. * How big in texel of the blur texture is the vertical blur.
  49396. */
  49397. blurVerticalSize: number;
  49398. /**
  49399. * How big in texel of the blur texture is the horizontal blur.
  49400. */
  49401. blurHorizontalSize: number;
  49402. /**
  49403. * Alpha blending mode used to apply the blur. Default is combine.
  49404. */
  49405. alphaBlendingMode: number;
  49406. /**
  49407. * The camera attached to the layer.
  49408. */
  49409. camera: Nullable<Camera>;
  49410. /**
  49411. * Should we display highlight as a solid stroke?
  49412. */
  49413. isStroke?: boolean;
  49414. /**
  49415. * The rendering group to draw the layer in.
  49416. */
  49417. renderingGroupId: number;
  49418. }
  49419. /**
  49420. * The highlight layer Helps adding a glow effect around a mesh.
  49421. *
  49422. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49423. * glowy meshes to your scene.
  49424. *
  49425. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49426. */
  49427. export class HighlightLayer extends EffectLayer {
  49428. name: string;
  49429. /**
  49430. * Effect Name of the highlight layer.
  49431. */
  49432. static readonly EffectName: string;
  49433. /**
  49434. * The neutral color used during the preparation of the glow effect.
  49435. * This is black by default as the blend operation is a blend operation.
  49436. */
  49437. static NeutralColor: Color4;
  49438. /**
  49439. * Stencil value used for glowing meshes.
  49440. */
  49441. static GlowingMeshStencilReference: number;
  49442. /**
  49443. * Stencil value used for the other meshes in the scene.
  49444. */
  49445. static NormalMeshStencilReference: number;
  49446. /**
  49447. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49448. */
  49449. innerGlow: boolean;
  49450. /**
  49451. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49452. */
  49453. outerGlow: boolean;
  49454. /**
  49455. * Specifies the horizontal size of the blur.
  49456. */
  49457. /**
  49458. * Gets the horizontal size of the blur.
  49459. */
  49460. blurHorizontalSize: number;
  49461. /**
  49462. * Specifies the vertical size of the blur.
  49463. */
  49464. /**
  49465. * Gets the vertical size of the blur.
  49466. */
  49467. blurVerticalSize: number;
  49468. /**
  49469. * An event triggered when the highlight layer is being blurred.
  49470. */
  49471. onBeforeBlurObservable: Observable<HighlightLayer>;
  49472. /**
  49473. * An event triggered when the highlight layer has been blurred.
  49474. */
  49475. onAfterBlurObservable: Observable<HighlightLayer>;
  49476. private _instanceGlowingMeshStencilReference;
  49477. private _options;
  49478. private _downSamplePostprocess;
  49479. private _horizontalBlurPostprocess;
  49480. private _verticalBlurPostprocess;
  49481. private _blurTexture;
  49482. private _meshes;
  49483. private _excludedMeshes;
  49484. /**
  49485. * Instantiates a new highlight Layer and references it to the scene..
  49486. * @param name The name of the layer
  49487. * @param scene The scene to use the layer in
  49488. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49489. */
  49490. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49491. /**
  49492. * Get the effect name of the layer.
  49493. * @return The effect name
  49494. */
  49495. getEffectName(): string;
  49496. /**
  49497. * Create the merge effect. This is the shader use to blit the information back
  49498. * to the main canvas at the end of the scene rendering.
  49499. */
  49500. protected _createMergeEffect(): Effect;
  49501. /**
  49502. * Creates the render target textures and post processes used in the highlight layer.
  49503. */
  49504. protected _createTextureAndPostProcesses(): void;
  49505. /**
  49506. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49507. */
  49508. needStencil(): boolean;
  49509. /**
  49510. * Checks for the readiness of the element composing the layer.
  49511. * @param subMesh the mesh to check for
  49512. * @param useInstances specify wether or not to use instances to render the mesh
  49513. * @param emissiveTexture the associated emissive texture used to generate the glow
  49514. * @return true if ready otherwise, false
  49515. */
  49516. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49517. /**
  49518. * Implementation specific of rendering the generating effect on the main canvas.
  49519. * @param effect The effect used to render through
  49520. */
  49521. protected _internalRender(effect: Effect): void;
  49522. /**
  49523. * Returns true if the layer contains information to display, otherwise false.
  49524. */
  49525. shouldRender(): boolean;
  49526. /**
  49527. * Returns true if the mesh should render, otherwise false.
  49528. * @param mesh The mesh to render
  49529. * @returns true if it should render otherwise false
  49530. */
  49531. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49532. /**
  49533. * Sets the required values for both the emissive texture and and the main color.
  49534. */
  49535. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49536. /**
  49537. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49538. * @param mesh The mesh to exclude from the highlight layer
  49539. */
  49540. addExcludedMesh(mesh: Mesh): void;
  49541. /**
  49542. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49543. * @param mesh The mesh to highlight
  49544. */
  49545. removeExcludedMesh(mesh: Mesh): void;
  49546. /**
  49547. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49548. * @param mesh mesh to test
  49549. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49550. */
  49551. hasMesh(mesh: AbstractMesh): boolean;
  49552. /**
  49553. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49554. * @param mesh The mesh to highlight
  49555. * @param color The color of the highlight
  49556. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49557. */
  49558. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49559. /**
  49560. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49561. * @param mesh The mesh to highlight
  49562. */
  49563. removeMesh(mesh: Mesh): void;
  49564. /**
  49565. * Force the stencil to the normal expected value for none glowing parts
  49566. */
  49567. private _defaultStencilReference;
  49568. /**
  49569. * Free any resources and references associated to a mesh.
  49570. * Internal use
  49571. * @param mesh The mesh to free.
  49572. * @hidden
  49573. */
  49574. _disposeMesh(mesh: Mesh): void;
  49575. /**
  49576. * Dispose the highlight layer and free resources.
  49577. */
  49578. dispose(): void;
  49579. /**
  49580. * Gets the class name of the effect layer
  49581. * @returns the string with the class name of the effect layer
  49582. */
  49583. getClassName(): string;
  49584. /**
  49585. * Serializes this Highlight layer
  49586. * @returns a serialized Highlight layer object
  49587. */
  49588. serialize(): any;
  49589. /**
  49590. * Creates a Highlight layer from parsed Highlight layer data
  49591. * @param parsedHightlightLayer defines the Highlight layer data
  49592. * @param scene defines the current scene
  49593. * @param rootUrl defines the root URL containing the Highlight layer information
  49594. * @returns a parsed Highlight layer
  49595. */
  49596. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49597. }
  49598. }
  49599. declare module "babylonjs/Layers/index" {
  49600. export * from "babylonjs/Layers/effectLayer";
  49601. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49602. export * from "babylonjs/Layers/glowLayer";
  49603. export * from "babylonjs/Layers/highlightLayer";
  49604. export * from "babylonjs/Layers/layer";
  49605. export * from "babylonjs/Layers/layerSceneComponent";
  49606. }
  49607. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49608. /** @hidden */
  49609. export var lensFlarePixelShader: {
  49610. name: string;
  49611. shader: string;
  49612. };
  49613. }
  49614. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49615. /** @hidden */
  49616. export var lensFlareVertexShader: {
  49617. name: string;
  49618. shader: string;
  49619. };
  49620. }
  49621. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49622. import { Scene } from "babylonjs/scene";
  49623. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49625. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49626. import "babylonjs/Shaders/lensFlare.fragment";
  49627. import "babylonjs/Shaders/lensFlare.vertex";
  49628. /**
  49629. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49630. * It is usually composed of several `lensFlare`.
  49631. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49632. */
  49633. export class LensFlareSystem {
  49634. /**
  49635. * Define the name of the lens flare system
  49636. */
  49637. name: string;
  49638. /**
  49639. * List of lens flares used in this system.
  49640. */
  49641. lensFlares: LensFlare[];
  49642. /**
  49643. * Define a limit from the border the lens flare can be visible.
  49644. */
  49645. borderLimit: number;
  49646. /**
  49647. * Define a viewport border we do not want to see the lens flare in.
  49648. */
  49649. viewportBorder: number;
  49650. /**
  49651. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49652. */
  49653. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49654. /**
  49655. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49656. */
  49657. layerMask: number;
  49658. /**
  49659. * Define the id of the lens flare system in the scene.
  49660. * (equal to name by default)
  49661. */
  49662. id: string;
  49663. private _scene;
  49664. private _emitter;
  49665. private _vertexBuffers;
  49666. private _indexBuffer;
  49667. private _effect;
  49668. private _positionX;
  49669. private _positionY;
  49670. private _isEnabled;
  49671. /** @hidden */
  49672. static _SceneComponentInitialization: (scene: Scene) => void;
  49673. /**
  49674. * Instantiates a lens flare system.
  49675. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49676. * It is usually composed of several `lensFlare`.
  49677. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49678. * @param name Define the name of the lens flare system in the scene
  49679. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49680. * @param scene Define the scene the lens flare system belongs to
  49681. */
  49682. constructor(
  49683. /**
  49684. * Define the name of the lens flare system
  49685. */
  49686. name: string, emitter: any, scene: Scene);
  49687. /**
  49688. * Define if the lens flare system is enabled.
  49689. */
  49690. isEnabled: boolean;
  49691. /**
  49692. * Get the scene the effects belongs to.
  49693. * @returns the scene holding the lens flare system
  49694. */
  49695. getScene(): Scene;
  49696. /**
  49697. * Get the emitter of the lens flare system.
  49698. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49699. * @returns the emitter of the lens flare system
  49700. */
  49701. getEmitter(): any;
  49702. /**
  49703. * Set the emitter of the lens flare system.
  49704. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49705. * @param newEmitter Define the new emitter of the system
  49706. */
  49707. setEmitter(newEmitter: any): void;
  49708. /**
  49709. * Get the lens flare system emitter position.
  49710. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49711. * @returns the position
  49712. */
  49713. getEmitterPosition(): Vector3;
  49714. /**
  49715. * @hidden
  49716. */
  49717. computeEffectivePosition(globalViewport: Viewport): boolean;
  49718. /** @hidden */
  49719. _isVisible(): boolean;
  49720. /**
  49721. * @hidden
  49722. */
  49723. render(): boolean;
  49724. /**
  49725. * Dispose and release the lens flare with its associated resources.
  49726. */
  49727. dispose(): void;
  49728. /**
  49729. * Parse a lens flare system from a JSON repressentation
  49730. * @param parsedLensFlareSystem Define the JSON to parse
  49731. * @param scene Define the scene the parsed system should be instantiated in
  49732. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49733. * @returns the parsed system
  49734. */
  49735. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49736. /**
  49737. * Serialize the current Lens Flare System into a JSON representation.
  49738. * @returns the serialized JSON
  49739. */
  49740. serialize(): any;
  49741. }
  49742. }
  49743. declare module "babylonjs/LensFlares/lensFlare" {
  49744. import { Nullable } from "babylonjs/types";
  49745. import { Color3 } from "babylonjs/Maths/math";
  49746. import { Texture } from "babylonjs/Materials/Textures/texture";
  49747. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49748. /**
  49749. * This represents one of the lens effect in a `lensFlareSystem`.
  49750. * It controls one of the indiviual texture used in the effect.
  49751. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49752. */
  49753. export class LensFlare {
  49754. /**
  49755. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49756. */
  49757. size: number;
  49758. /**
  49759. * 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.
  49760. */
  49761. position: number;
  49762. /**
  49763. * Define the lens color.
  49764. */
  49765. color: Color3;
  49766. /**
  49767. * Define the lens texture.
  49768. */
  49769. texture: Nullable<Texture>;
  49770. /**
  49771. * Define the alpha mode to render this particular lens.
  49772. */
  49773. alphaMode: number;
  49774. private _system;
  49775. /**
  49776. * Creates a new Lens Flare.
  49777. * This represents one of the lens effect in a `lensFlareSystem`.
  49778. * It controls one of the indiviual texture used in the effect.
  49779. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49780. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49781. * @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.
  49782. * @param color Define the lens color
  49783. * @param imgUrl Define the lens texture url
  49784. * @param system Define the `lensFlareSystem` this flare is part of
  49785. * @returns The newly created Lens Flare
  49786. */
  49787. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49788. /**
  49789. * Instantiates a new Lens Flare.
  49790. * This represents one of the lens effect in a `lensFlareSystem`.
  49791. * It controls one of the indiviual texture used in the effect.
  49792. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49793. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49794. * @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.
  49795. * @param color Define the lens color
  49796. * @param imgUrl Define the lens texture url
  49797. * @param system Define the `lensFlareSystem` this flare is part of
  49798. */
  49799. constructor(
  49800. /**
  49801. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49802. */
  49803. size: number,
  49804. /**
  49805. * 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.
  49806. */
  49807. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49808. /**
  49809. * Dispose and release the lens flare with its associated resources.
  49810. */
  49811. dispose(): void;
  49812. }
  49813. }
  49814. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49815. import { Nullable } from "babylonjs/types";
  49816. import { Scene } from "babylonjs/scene";
  49817. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49818. import { AbstractScene } from "babylonjs/abstractScene";
  49819. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49820. module "babylonjs/abstractScene" {
  49821. interface AbstractScene {
  49822. /**
  49823. * The list of lens flare system added to the scene
  49824. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49825. */
  49826. lensFlareSystems: Array<LensFlareSystem>;
  49827. /**
  49828. * Removes the given lens flare system from this scene.
  49829. * @param toRemove The lens flare system to remove
  49830. * @returns The index of the removed lens flare system
  49831. */
  49832. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49833. /**
  49834. * Adds the given lens flare system to this scene
  49835. * @param newLensFlareSystem The lens flare system to add
  49836. */
  49837. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49838. /**
  49839. * Gets a lens flare system using its name
  49840. * @param name defines the name to look for
  49841. * @returns the lens flare system or null if not found
  49842. */
  49843. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49844. /**
  49845. * Gets a lens flare system using its id
  49846. * @param id defines the id to look for
  49847. * @returns the lens flare system or null if not found
  49848. */
  49849. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49850. }
  49851. }
  49852. /**
  49853. * Defines the lens flare scene component responsible to manage any lens flares
  49854. * in a given scene.
  49855. */
  49856. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49857. /**
  49858. * The component name helpfull to identify the component in the list of scene components.
  49859. */
  49860. readonly name: string;
  49861. /**
  49862. * The scene the component belongs to.
  49863. */
  49864. scene: Scene;
  49865. /**
  49866. * Creates a new instance of the component for the given scene
  49867. * @param scene Defines the scene to register the component in
  49868. */
  49869. constructor(scene: Scene);
  49870. /**
  49871. * Registers the component in a given scene
  49872. */
  49873. register(): void;
  49874. /**
  49875. * Rebuilds the elements related to this component in case of
  49876. * context lost for instance.
  49877. */
  49878. rebuild(): void;
  49879. /**
  49880. * Adds all the element from the container to the scene
  49881. * @param container the container holding the elements
  49882. */
  49883. addFromContainer(container: AbstractScene): void;
  49884. /**
  49885. * Removes all the elements in the container from the scene
  49886. * @param container contains the elements to remove
  49887. * @param dispose if the removed element should be disposed (default: false)
  49888. */
  49889. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49890. /**
  49891. * Serializes the component data to the specified json object
  49892. * @param serializationObject The object to serialize to
  49893. */
  49894. serialize(serializationObject: any): void;
  49895. /**
  49896. * Disposes the component and the associated ressources.
  49897. */
  49898. dispose(): void;
  49899. private _draw;
  49900. }
  49901. }
  49902. declare module "babylonjs/LensFlares/index" {
  49903. export * from "babylonjs/LensFlares/lensFlare";
  49904. export * from "babylonjs/LensFlares/lensFlareSystem";
  49905. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49906. }
  49907. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49908. import { Scene } from "babylonjs/scene";
  49909. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49910. import { AbstractScene } from "babylonjs/abstractScene";
  49911. /**
  49912. * Defines the shadow generator component responsible to manage any shadow generators
  49913. * in a given scene.
  49914. */
  49915. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49916. /**
  49917. * The component name helpfull to identify the component in the list of scene components.
  49918. */
  49919. readonly name: string;
  49920. /**
  49921. * The scene the component belongs to.
  49922. */
  49923. scene: Scene;
  49924. /**
  49925. * Creates a new instance of the component for the given scene
  49926. * @param scene Defines the scene to register the component in
  49927. */
  49928. constructor(scene: Scene);
  49929. /**
  49930. * Registers the component in a given scene
  49931. */
  49932. register(): void;
  49933. /**
  49934. * Rebuilds the elements related to this component in case of
  49935. * context lost for instance.
  49936. */
  49937. rebuild(): void;
  49938. /**
  49939. * Serializes the component data to the specified json object
  49940. * @param serializationObject The object to serialize to
  49941. */
  49942. serialize(serializationObject: any): void;
  49943. /**
  49944. * Adds all the element from the container to the scene
  49945. * @param container the container holding the elements
  49946. */
  49947. addFromContainer(container: AbstractScene): void;
  49948. /**
  49949. * Removes all the elements in the container from the scene
  49950. * @param container contains the elements to remove
  49951. * @param dispose if the removed element should be disposed (default: false)
  49952. */
  49953. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49954. /**
  49955. * Rebuilds the elements related to this component in case of
  49956. * context lost for instance.
  49957. */
  49958. dispose(): void;
  49959. private _gatherRenderTargets;
  49960. }
  49961. }
  49962. declare module "babylonjs/Lights/Shadows/index" {
  49963. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49964. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49965. }
  49966. declare module "babylonjs/Lights/pointLight" {
  49967. import { Scene } from "babylonjs/scene";
  49968. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49970. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49971. import { Effect } from "babylonjs/Materials/effect";
  49972. /**
  49973. * A point light is a light defined by an unique point in world space.
  49974. * The light is emitted in every direction from this point.
  49975. * A good example of a point light is a standard light bulb.
  49976. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49977. */
  49978. export class PointLight extends ShadowLight {
  49979. private _shadowAngle;
  49980. /**
  49981. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49982. * This specifies what angle the shadow will use to be created.
  49983. *
  49984. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49985. */
  49986. /**
  49987. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49988. * This specifies what angle the shadow will use to be created.
  49989. *
  49990. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49991. */
  49992. shadowAngle: number;
  49993. /**
  49994. * Gets the direction if it has been set.
  49995. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49996. */
  49997. /**
  49998. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49999. */
  50000. direction: Vector3;
  50001. /**
  50002. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50003. * A PointLight emits the light in every direction.
  50004. * It can cast shadows.
  50005. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50006. * ```javascript
  50007. * var pointLight = new PointLight("pl", camera.position, scene);
  50008. * ```
  50009. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50010. * @param name The light friendly name
  50011. * @param position The position of the point light in the scene
  50012. * @param scene The scene the lights belongs to
  50013. */
  50014. constructor(name: string, position: Vector3, scene: Scene);
  50015. /**
  50016. * Returns the string "PointLight"
  50017. * @returns the class name
  50018. */
  50019. getClassName(): string;
  50020. /**
  50021. * Returns the integer 0.
  50022. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50023. */
  50024. getTypeID(): number;
  50025. /**
  50026. * Specifies wether or not the shadowmap should be a cube texture.
  50027. * @returns true if the shadowmap needs to be a cube texture.
  50028. */
  50029. needCube(): boolean;
  50030. /**
  50031. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50032. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50033. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50034. */
  50035. getShadowDirection(faceIndex?: number): Vector3;
  50036. /**
  50037. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50038. * - fov = PI / 2
  50039. * - aspect ratio : 1.0
  50040. * - z-near and far equal to the active camera minZ and maxZ.
  50041. * Returns the PointLight.
  50042. */
  50043. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50044. protected _buildUniformLayout(): void;
  50045. /**
  50046. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50047. * @param effect The effect to update
  50048. * @param lightIndex The index of the light in the effect to update
  50049. * @returns The point light
  50050. */
  50051. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50052. /**
  50053. * Prepares the list of defines specific to the light type.
  50054. * @param defines the list of defines
  50055. * @param lightIndex defines the index of the light for the effect
  50056. */
  50057. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50058. }
  50059. }
  50060. declare module "babylonjs/Lights/index" {
  50061. export * from "babylonjs/Lights/light";
  50062. export * from "babylonjs/Lights/shadowLight";
  50063. export * from "babylonjs/Lights/Shadows/index";
  50064. export * from "babylonjs/Lights/directionalLight";
  50065. export * from "babylonjs/Lights/hemisphericLight";
  50066. export * from "babylonjs/Lights/pointLight";
  50067. export * from "babylonjs/Lights/spotLight";
  50068. }
  50069. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50070. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50071. /**
  50072. * Header information of HDR texture files.
  50073. */
  50074. export interface HDRInfo {
  50075. /**
  50076. * The height of the texture in pixels.
  50077. */
  50078. height: number;
  50079. /**
  50080. * The width of the texture in pixels.
  50081. */
  50082. width: number;
  50083. /**
  50084. * The index of the beginning of the data in the binary file.
  50085. */
  50086. dataPosition: number;
  50087. }
  50088. /**
  50089. * This groups tools to convert HDR texture to native colors array.
  50090. */
  50091. export class HDRTools {
  50092. private static Ldexp;
  50093. private static Rgbe2float;
  50094. private static readStringLine;
  50095. /**
  50096. * Reads header information from an RGBE texture stored in a native array.
  50097. * More information on this format are available here:
  50098. * https://en.wikipedia.org/wiki/RGBE_image_format
  50099. *
  50100. * @param uint8array The binary file stored in native array.
  50101. * @return The header information.
  50102. */
  50103. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50104. /**
  50105. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50106. * This RGBE texture needs to store the information as a panorama.
  50107. *
  50108. * More information on this format are available here:
  50109. * https://en.wikipedia.org/wiki/RGBE_image_format
  50110. *
  50111. * @param buffer The binary file stored in an array buffer.
  50112. * @param size The expected size of the extracted cubemap.
  50113. * @return The Cube Map information.
  50114. */
  50115. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50116. /**
  50117. * Returns the pixels data extracted from an RGBE texture.
  50118. * This pixels will be stored left to right up to down in the R G B order in one array.
  50119. *
  50120. * More information on this format are available here:
  50121. * https://en.wikipedia.org/wiki/RGBE_image_format
  50122. *
  50123. * @param uint8array The binary file stored in an array buffer.
  50124. * @param hdrInfo The header information of the file.
  50125. * @return The pixels data in RGB right to left up to down order.
  50126. */
  50127. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50128. private static RGBE_ReadPixels_RLE;
  50129. }
  50130. }
  50131. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50132. import { Nullable } from "babylonjs/types";
  50133. import { Scene } from "babylonjs/scene";
  50134. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50135. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50136. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50137. /**
  50138. * This represents a texture coming from an HDR input.
  50139. *
  50140. * The only supported format is currently panorama picture stored in RGBE format.
  50141. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50142. */
  50143. export class HDRCubeTexture extends BaseTexture {
  50144. private static _facesMapping;
  50145. private _generateHarmonics;
  50146. private _noMipmap;
  50147. private _textureMatrix;
  50148. private _size;
  50149. private _onLoad;
  50150. private _onError;
  50151. /**
  50152. * The texture URL.
  50153. */
  50154. url: string;
  50155. /**
  50156. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50157. */
  50158. coordinatesMode: number;
  50159. protected _isBlocking: boolean;
  50160. /**
  50161. * Sets wether or not the texture is blocking during loading.
  50162. */
  50163. /**
  50164. * Gets wether or not the texture is blocking during loading.
  50165. */
  50166. isBlocking: boolean;
  50167. protected _rotationY: number;
  50168. /**
  50169. * Sets texture matrix rotation angle around Y axis in radians.
  50170. */
  50171. /**
  50172. * Gets texture matrix rotation angle around Y axis radians.
  50173. */
  50174. rotationY: number;
  50175. /**
  50176. * Gets or sets the center of the bounding box associated with the cube texture
  50177. * It must define where the camera used to render the texture was set
  50178. */
  50179. boundingBoxPosition: Vector3;
  50180. private _boundingBoxSize;
  50181. /**
  50182. * Gets or sets the size of the bounding box associated with the cube texture
  50183. * When defined, the cubemap will switch to local mode
  50184. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50185. * @example https://www.babylonjs-playground.com/#RNASML
  50186. */
  50187. boundingBoxSize: Vector3;
  50188. /**
  50189. * Instantiates an HDRTexture from the following parameters.
  50190. *
  50191. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50192. * @param scene The scene the texture will be used in
  50193. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50194. * @param noMipmap Forces to not generate the mipmap if true
  50195. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50196. * @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)
  50197. * @param reserved Reserved flag for internal use.
  50198. */
  50199. 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>);
  50200. /**
  50201. * Get the current class name of the texture useful for serialization or dynamic coding.
  50202. * @returns "HDRCubeTexture"
  50203. */
  50204. getClassName(): string;
  50205. /**
  50206. * Occurs when the file is raw .hdr file.
  50207. */
  50208. private loadTexture;
  50209. clone(): HDRCubeTexture;
  50210. delayLoad(): void;
  50211. /**
  50212. * Get the texture reflection matrix used to rotate/transform the reflection.
  50213. * @returns the reflection matrix
  50214. */
  50215. getReflectionTextureMatrix(): Matrix;
  50216. /**
  50217. * Set the texture reflection matrix used to rotate/transform the reflection.
  50218. * @param value Define the reflection matrix to set
  50219. */
  50220. setReflectionTextureMatrix(value: Matrix): void;
  50221. /**
  50222. * Parses a JSON representation of an HDR Texture in order to create the texture
  50223. * @param parsedTexture Define the JSON representation
  50224. * @param scene Define the scene the texture should be created in
  50225. * @param rootUrl Define the root url in case we need to load relative dependencies
  50226. * @returns the newly created texture after parsing
  50227. */
  50228. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50229. serialize(): any;
  50230. }
  50231. }
  50232. declare module "babylonjs/Physics/physicsEngine" {
  50233. import { Nullable } from "babylonjs/types";
  50234. import { Vector3 } from "babylonjs/Maths/math";
  50235. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50236. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50237. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50238. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50239. /**
  50240. * Class used to control physics engine
  50241. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50242. */
  50243. export class PhysicsEngine implements IPhysicsEngine {
  50244. private _physicsPlugin;
  50245. /**
  50246. * Global value used to control the smallest number supported by the simulation
  50247. */
  50248. static Epsilon: number;
  50249. private _impostors;
  50250. private _joints;
  50251. /**
  50252. * Gets the gravity vector used by the simulation
  50253. */
  50254. gravity: Vector3;
  50255. /**
  50256. * Factory used to create the default physics plugin.
  50257. * @returns The default physics plugin
  50258. */
  50259. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50260. /**
  50261. * Creates a new Physics Engine
  50262. * @param gravity defines the gravity vector used by the simulation
  50263. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50264. */
  50265. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50266. /**
  50267. * Sets the gravity vector used by the simulation
  50268. * @param gravity defines the gravity vector to use
  50269. */
  50270. setGravity(gravity: Vector3): void;
  50271. /**
  50272. * Set the time step of the physics engine.
  50273. * Default is 1/60.
  50274. * To slow it down, enter 1/600 for example.
  50275. * To speed it up, 1/30
  50276. * @param newTimeStep defines the new timestep to apply to this world.
  50277. */
  50278. setTimeStep(newTimeStep?: number): void;
  50279. /**
  50280. * Get the time step of the physics engine.
  50281. * @returns the current time step
  50282. */
  50283. getTimeStep(): number;
  50284. /**
  50285. * Release all resources
  50286. */
  50287. dispose(): void;
  50288. /**
  50289. * Gets the name of the current physics plugin
  50290. * @returns the name of the plugin
  50291. */
  50292. getPhysicsPluginName(): string;
  50293. /**
  50294. * Adding a new impostor for the impostor tracking.
  50295. * This will be done by the impostor itself.
  50296. * @param impostor the impostor to add
  50297. */
  50298. addImpostor(impostor: PhysicsImpostor): void;
  50299. /**
  50300. * Remove an impostor from the engine.
  50301. * This impostor and its mesh will not longer be updated by the physics engine.
  50302. * @param impostor the impostor to remove
  50303. */
  50304. removeImpostor(impostor: PhysicsImpostor): void;
  50305. /**
  50306. * Add a joint to the physics engine
  50307. * @param mainImpostor defines the main impostor to which the joint is added.
  50308. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50309. * @param joint defines the joint that will connect both impostors.
  50310. */
  50311. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50312. /**
  50313. * Removes a joint from the simulation
  50314. * @param mainImpostor defines the impostor used with the joint
  50315. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50316. * @param joint defines the joint to remove
  50317. */
  50318. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50319. /**
  50320. * Called by the scene. No need to call it.
  50321. * @param delta defines the timespam between frames
  50322. */
  50323. _step(delta: number): void;
  50324. /**
  50325. * Gets the current plugin used to run the simulation
  50326. * @returns current plugin
  50327. */
  50328. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50329. /**
  50330. * Gets the list of physic impostors
  50331. * @returns an array of PhysicsImpostor
  50332. */
  50333. getImpostors(): Array<PhysicsImpostor>;
  50334. /**
  50335. * Gets the impostor for a physics enabled object
  50336. * @param object defines the object impersonated by the impostor
  50337. * @returns the PhysicsImpostor or null if not found
  50338. */
  50339. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50340. /**
  50341. * Gets the impostor for a physics body object
  50342. * @param body defines physics body used by the impostor
  50343. * @returns the PhysicsImpostor or null if not found
  50344. */
  50345. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50346. /**
  50347. * Does a raycast in the physics world
  50348. * @param from when should the ray start?
  50349. * @param to when should the ray end?
  50350. * @returns PhysicsRaycastResult
  50351. */
  50352. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50353. }
  50354. }
  50355. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50356. import { Nullable } from "babylonjs/types";
  50357. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50359. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50360. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50361. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50362. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50363. /** @hidden */
  50364. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50365. private _useDeltaForWorldStep;
  50366. world: any;
  50367. name: string;
  50368. private _physicsMaterials;
  50369. private _fixedTimeStep;
  50370. private _cannonRaycastResult;
  50371. private _raycastResult;
  50372. private _removeAfterStep;
  50373. BJSCANNON: any;
  50374. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50375. setGravity(gravity: Vector3): void;
  50376. setTimeStep(timeStep: number): void;
  50377. getTimeStep(): number;
  50378. executeStep(delta: number): void;
  50379. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50380. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50381. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50382. private _processChildMeshes;
  50383. removePhysicsBody(impostor: PhysicsImpostor): void;
  50384. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50385. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50386. private _addMaterial;
  50387. private _checkWithEpsilon;
  50388. private _createShape;
  50389. private _createHeightmap;
  50390. private _minus90X;
  50391. private _plus90X;
  50392. private _tmpPosition;
  50393. private _tmpDeltaPosition;
  50394. private _tmpUnityRotation;
  50395. private _updatePhysicsBodyTransformation;
  50396. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50397. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50398. isSupported(): boolean;
  50399. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50400. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50401. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50402. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50403. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50404. getBodyMass(impostor: PhysicsImpostor): number;
  50405. getBodyFriction(impostor: PhysicsImpostor): number;
  50406. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50407. getBodyRestitution(impostor: PhysicsImpostor): number;
  50408. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50409. sleepBody(impostor: PhysicsImpostor): void;
  50410. wakeUpBody(impostor: PhysicsImpostor): void;
  50411. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50412. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50413. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50414. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50415. getRadius(impostor: PhysicsImpostor): number;
  50416. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50417. dispose(): void;
  50418. private _extendNamespace;
  50419. /**
  50420. * Does a raycast in the physics world
  50421. * @param from when should the ray start?
  50422. * @param to when should the ray end?
  50423. * @returns PhysicsRaycastResult
  50424. */
  50425. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50426. }
  50427. }
  50428. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50429. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50430. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50431. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50433. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50434. import { Nullable } from "babylonjs/types";
  50435. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50436. /** @hidden */
  50437. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50438. world: any;
  50439. name: string;
  50440. BJSOIMO: any;
  50441. private _raycastResult;
  50442. constructor(iterations?: number, oimoInjection?: any);
  50443. setGravity(gravity: Vector3): void;
  50444. setTimeStep(timeStep: number): void;
  50445. getTimeStep(): number;
  50446. private _tmpImpostorsArray;
  50447. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50448. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50449. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50450. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50451. private _tmpPositionVector;
  50452. removePhysicsBody(impostor: PhysicsImpostor): void;
  50453. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50454. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50455. isSupported(): boolean;
  50456. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50457. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50458. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50459. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50460. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50461. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50462. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50463. getBodyMass(impostor: PhysicsImpostor): number;
  50464. getBodyFriction(impostor: PhysicsImpostor): number;
  50465. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50466. getBodyRestitution(impostor: PhysicsImpostor): number;
  50467. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50468. sleepBody(impostor: PhysicsImpostor): void;
  50469. wakeUpBody(impostor: PhysicsImpostor): void;
  50470. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50471. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50472. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50473. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50474. getRadius(impostor: PhysicsImpostor): number;
  50475. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50476. dispose(): void;
  50477. /**
  50478. * Does a raycast in the physics world
  50479. * @param from when should the ray start?
  50480. * @param to when should the ray end?
  50481. * @returns PhysicsRaycastResult
  50482. */
  50483. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50484. }
  50485. }
  50486. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50487. import { Nullable } from "babylonjs/types";
  50488. import { Scene } from "babylonjs/scene";
  50489. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50490. import { Mesh } from "babylonjs/Meshes/mesh";
  50491. /**
  50492. * Class containing static functions to help procedurally build meshes
  50493. */
  50494. export class RibbonBuilder {
  50495. /**
  50496. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50497. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50498. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50499. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50500. * * 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
  50501. * * 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
  50502. * * 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
  50503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50505. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50506. * * 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
  50507. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50508. * * 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
  50509. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50511. * @param name defines the name of the mesh
  50512. * @param options defines the options used to create the mesh
  50513. * @param scene defines the hosting scene
  50514. * @returns the ribbon mesh
  50515. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50516. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50517. */
  50518. static CreateRibbon(name: string, options: {
  50519. pathArray: Vector3[][];
  50520. closeArray?: boolean;
  50521. closePath?: boolean;
  50522. offset?: number;
  50523. updatable?: boolean;
  50524. sideOrientation?: number;
  50525. frontUVs?: Vector4;
  50526. backUVs?: Vector4;
  50527. instance?: Mesh;
  50528. invertUV?: boolean;
  50529. uvs?: Vector2[];
  50530. colors?: Color4[];
  50531. }, scene?: Nullable<Scene>): Mesh;
  50532. }
  50533. }
  50534. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50535. import { Nullable } from "babylonjs/types";
  50536. import { Scene } from "babylonjs/scene";
  50537. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50538. import { Mesh } from "babylonjs/Meshes/mesh";
  50539. /**
  50540. * Class containing static functions to help procedurally build meshes
  50541. */
  50542. export class ShapeBuilder {
  50543. /**
  50544. * 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.
  50545. * * 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.
  50546. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50547. * * 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.
  50548. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50549. * * 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
  50550. * * 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
  50551. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50554. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50556. * @param name defines the name of the mesh
  50557. * @param options defines the options used to create the mesh
  50558. * @param scene defines the hosting scene
  50559. * @returns the extruded shape mesh
  50560. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50562. */
  50563. static ExtrudeShape(name: string, options: {
  50564. shape: Vector3[];
  50565. path: Vector3[];
  50566. scale?: number;
  50567. rotation?: number;
  50568. cap?: number;
  50569. updatable?: boolean;
  50570. sideOrientation?: number;
  50571. frontUVs?: Vector4;
  50572. backUVs?: Vector4;
  50573. instance?: Mesh;
  50574. invertUV?: boolean;
  50575. }, scene?: Nullable<Scene>): Mesh;
  50576. /**
  50577. * Creates an custom extruded shape mesh.
  50578. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50579. * * 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.
  50580. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50581. * * 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
  50582. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50583. * * 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
  50584. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50585. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50586. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50587. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  50588. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  50589. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50592. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50594. * @param name defines the name of the mesh
  50595. * @param options defines the options used to create the mesh
  50596. * @param scene defines the hosting scene
  50597. * @returns the custom extruded shape mesh
  50598. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50599. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50600. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50601. */
  50602. static ExtrudeShapeCustom(name: string, options: {
  50603. shape: Vector3[];
  50604. path: Vector3[];
  50605. scaleFunction?: any;
  50606. rotationFunction?: any;
  50607. ribbonCloseArray?: boolean;
  50608. ribbonClosePath?: boolean;
  50609. cap?: number;
  50610. updatable?: boolean;
  50611. sideOrientation?: number;
  50612. frontUVs?: Vector4;
  50613. backUVs?: Vector4;
  50614. instance?: Mesh;
  50615. invertUV?: boolean;
  50616. }, scene?: Nullable<Scene>): Mesh;
  50617. private static _ExtrudeShapeGeneric;
  50618. }
  50619. }
  50620. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50621. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50622. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50623. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50624. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50625. import { Nullable } from "babylonjs/types";
  50626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50627. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50628. /**
  50629. * AmmoJS Physics plugin
  50630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50631. * @see https://github.com/kripken/ammo.js/
  50632. */
  50633. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50634. private _useDeltaForWorldStep;
  50635. /**
  50636. * Reference to the Ammo library
  50637. */
  50638. bjsAMMO: any;
  50639. /**
  50640. * Created ammoJS world which physics bodies are added to
  50641. */
  50642. world: any;
  50643. /**
  50644. * Name of the plugin
  50645. */
  50646. name: string;
  50647. private _timeStep;
  50648. private _fixedTimeStep;
  50649. private _maxSteps;
  50650. private _tmpQuaternion;
  50651. private _tmpAmmoTransform;
  50652. private _tmpAmmoQuaternion;
  50653. private _tmpAmmoConcreteContactResultCallback;
  50654. private _collisionConfiguration;
  50655. private _dispatcher;
  50656. private _overlappingPairCache;
  50657. private _solver;
  50658. private _softBodySolver;
  50659. private _tmpAmmoVectorA;
  50660. private _tmpAmmoVectorB;
  50661. private _tmpAmmoVectorC;
  50662. private _tmpAmmoVectorD;
  50663. private _tmpContactCallbackResult;
  50664. private _tmpAmmoVectorRCA;
  50665. private _tmpAmmoVectorRCB;
  50666. private _raycastResult;
  50667. private static readonly DISABLE_COLLISION_FLAG;
  50668. private static readonly KINEMATIC_FLAG;
  50669. private static readonly DISABLE_DEACTIVATION_FLAG;
  50670. /**
  50671. * Initializes the ammoJS plugin
  50672. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50673. * @param ammoInjection can be used to inject your own ammo reference
  50674. */
  50675. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50676. /**
  50677. * Sets the gravity of the physics world (m/(s^2))
  50678. * @param gravity Gravity to set
  50679. */
  50680. setGravity(gravity: Vector3): void;
  50681. /**
  50682. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50683. * @param timeStep timestep to use in seconds
  50684. */
  50685. setTimeStep(timeStep: number): void;
  50686. /**
  50687. * 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)
  50688. * @param fixedTimeStep fixedTimeStep to use in seconds
  50689. */
  50690. setFixedTimeStep(fixedTimeStep: number): void;
  50691. /**
  50692. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50693. * @param maxSteps the maximum number of steps by the physics engine per frame
  50694. */
  50695. setMaxSteps(maxSteps: number): void;
  50696. /**
  50697. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50698. * @returns the current timestep in seconds
  50699. */
  50700. getTimeStep(): number;
  50701. private _isImpostorInContact;
  50702. private _isImpostorPairInContact;
  50703. private _stepSimulation;
  50704. /**
  50705. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50706. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50707. * After the step the babylon meshes are set to the position of the physics imposters
  50708. * @param delta amount of time to step forward
  50709. * @param impostors array of imposters to update before/after the step
  50710. */
  50711. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50712. /**
  50713. * Update babylon mesh to match physics world object
  50714. * @param impostor imposter to match
  50715. */
  50716. private _afterSoftStep;
  50717. /**
  50718. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50719. * @param impostor imposter to match
  50720. */
  50721. private _ropeStep;
  50722. /**
  50723. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50724. * @param impostor imposter to match
  50725. */
  50726. private _softbodyOrClothStep;
  50727. private _tmpVector;
  50728. private _tmpMatrix;
  50729. /**
  50730. * Applies an impulse on the imposter
  50731. * @param impostor imposter to apply impulse to
  50732. * @param force amount of force to be applied to the imposter
  50733. * @param contactPoint the location to apply the impulse on the imposter
  50734. */
  50735. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50736. /**
  50737. * Applies a force on the imposter
  50738. * @param impostor imposter to apply force
  50739. * @param force amount of force to be applied to the imposter
  50740. * @param contactPoint the location to apply the force on the imposter
  50741. */
  50742. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50743. /**
  50744. * Creates a physics body using the plugin
  50745. * @param impostor the imposter to create the physics body on
  50746. */
  50747. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50748. /**
  50749. * Removes the physics body from the imposter and disposes of the body's memory
  50750. * @param impostor imposter to remove the physics body from
  50751. */
  50752. removePhysicsBody(impostor: PhysicsImpostor): void;
  50753. /**
  50754. * Generates a joint
  50755. * @param impostorJoint the imposter joint to create the joint with
  50756. */
  50757. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50758. /**
  50759. * Removes a joint
  50760. * @param impostorJoint the imposter joint to remove the joint from
  50761. */
  50762. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50763. private _addMeshVerts;
  50764. /**
  50765. * Initialise the soft body vertices to match its object's (mesh) vertices
  50766. * Softbody vertices (nodes) are in world space and to match this
  50767. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50768. * @param impostor to create the softbody for
  50769. */
  50770. private _softVertexData;
  50771. /**
  50772. * Create an impostor's soft body
  50773. * @param impostor to create the softbody for
  50774. */
  50775. private _createSoftbody;
  50776. /**
  50777. * Create cloth for an impostor
  50778. * @param impostor to create the softbody for
  50779. */
  50780. private _createCloth;
  50781. /**
  50782. * Create rope for an impostor
  50783. * @param impostor to create the softbody for
  50784. */
  50785. private _createRope;
  50786. private _addHullVerts;
  50787. private _createShape;
  50788. /**
  50789. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50790. * @param impostor imposter containing the physics body and babylon object
  50791. */
  50792. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50793. /**
  50794. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50795. * @param impostor imposter containing the physics body and babylon object
  50796. * @param newPosition new position
  50797. * @param newRotation new rotation
  50798. */
  50799. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50800. /**
  50801. * If this plugin is supported
  50802. * @returns true if its supported
  50803. */
  50804. isSupported(): boolean;
  50805. /**
  50806. * Sets the linear velocity of the physics body
  50807. * @param impostor imposter to set the velocity on
  50808. * @param velocity velocity to set
  50809. */
  50810. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50811. /**
  50812. * Sets the angular velocity of the physics body
  50813. * @param impostor imposter to set the velocity on
  50814. * @param velocity velocity to set
  50815. */
  50816. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50817. /**
  50818. * gets the linear velocity
  50819. * @param impostor imposter to get linear velocity from
  50820. * @returns linear velocity
  50821. */
  50822. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50823. /**
  50824. * gets the angular velocity
  50825. * @param impostor imposter to get angular velocity from
  50826. * @returns angular velocity
  50827. */
  50828. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50829. /**
  50830. * Sets the mass of physics body
  50831. * @param impostor imposter to set the mass on
  50832. * @param mass mass to set
  50833. */
  50834. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50835. /**
  50836. * Gets the mass of the physics body
  50837. * @param impostor imposter to get the mass from
  50838. * @returns mass
  50839. */
  50840. getBodyMass(impostor: PhysicsImpostor): number;
  50841. /**
  50842. * Gets friction of the impostor
  50843. * @param impostor impostor to get friction from
  50844. * @returns friction value
  50845. */
  50846. getBodyFriction(impostor: PhysicsImpostor): number;
  50847. /**
  50848. * Sets friction of the impostor
  50849. * @param impostor impostor to set friction on
  50850. * @param friction friction value
  50851. */
  50852. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50853. /**
  50854. * Gets restitution of the impostor
  50855. * @param impostor impostor to get restitution from
  50856. * @returns restitution value
  50857. */
  50858. getBodyRestitution(impostor: PhysicsImpostor): number;
  50859. /**
  50860. * Sets resitution of the impostor
  50861. * @param impostor impostor to set resitution on
  50862. * @param restitution resitution value
  50863. */
  50864. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50865. /**
  50866. * Gets pressure inside the impostor
  50867. * @param impostor impostor to get pressure from
  50868. * @returns pressure value
  50869. */
  50870. getBodyPressure(impostor: PhysicsImpostor): number;
  50871. /**
  50872. * Sets pressure inside a soft body impostor
  50873. * Cloth and rope must remain 0 pressure
  50874. * @param impostor impostor to set pressure on
  50875. * @param pressure pressure value
  50876. */
  50877. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50878. /**
  50879. * Gets stiffness of the impostor
  50880. * @param impostor impostor to get stiffness from
  50881. * @returns pressure value
  50882. */
  50883. getBodyStiffness(impostor: PhysicsImpostor): number;
  50884. /**
  50885. * Sets stiffness of the impostor
  50886. * @param impostor impostor to set stiffness on
  50887. * @param stiffness stiffness value from 0 to 1
  50888. */
  50889. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50890. /**
  50891. * Gets velocityIterations of the impostor
  50892. * @param impostor impostor to get velocity iterations from
  50893. * @returns velocityIterations value
  50894. */
  50895. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50896. /**
  50897. * Sets velocityIterations of the impostor
  50898. * @param impostor impostor to set velocity iterations on
  50899. * @param velocityIterations velocityIterations value
  50900. */
  50901. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50902. /**
  50903. * Gets positionIterations of the impostor
  50904. * @param impostor impostor to get position iterations from
  50905. * @returns positionIterations value
  50906. */
  50907. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50908. /**
  50909. * Sets positionIterations of the impostor
  50910. * @param impostor impostor to set position on
  50911. * @param positionIterations positionIterations value
  50912. */
  50913. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50914. /**
  50915. * Append an anchor to a cloth object
  50916. * @param impostor is the cloth impostor to add anchor to
  50917. * @param otherImpostor is the rigid impostor to anchor to
  50918. * @param width ratio across width from 0 to 1
  50919. * @param height ratio up height from 0 to 1
  50920. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50921. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50922. */
  50923. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50924. /**
  50925. * Append an hook to a rope object
  50926. * @param impostor is the rope impostor to add hook to
  50927. * @param otherImpostor is the rigid impostor to hook to
  50928. * @param length ratio along the rope from 0 to 1
  50929. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50930. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50931. */
  50932. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50933. /**
  50934. * Sleeps the physics body and stops it from being active
  50935. * @param impostor impostor to sleep
  50936. */
  50937. sleepBody(impostor: PhysicsImpostor): void;
  50938. /**
  50939. * Activates the physics body
  50940. * @param impostor impostor to activate
  50941. */
  50942. wakeUpBody(impostor: PhysicsImpostor): void;
  50943. /**
  50944. * Updates the distance parameters of the joint
  50945. * @param joint joint to update
  50946. * @param maxDistance maximum distance of the joint
  50947. * @param minDistance minimum distance of the joint
  50948. */
  50949. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50950. /**
  50951. * Sets a motor on the joint
  50952. * @param joint joint to set motor on
  50953. * @param speed speed of the motor
  50954. * @param maxForce maximum force of the motor
  50955. * @param motorIndex index of the motor
  50956. */
  50957. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50958. /**
  50959. * Sets the motors limit
  50960. * @param joint joint to set limit on
  50961. * @param upperLimit upper limit
  50962. * @param lowerLimit lower limit
  50963. */
  50964. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50965. /**
  50966. * Syncs the position and rotation of a mesh with the impostor
  50967. * @param mesh mesh to sync
  50968. * @param impostor impostor to update the mesh with
  50969. */
  50970. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50971. /**
  50972. * Gets the radius of the impostor
  50973. * @param impostor impostor to get radius from
  50974. * @returns the radius
  50975. */
  50976. getRadius(impostor: PhysicsImpostor): number;
  50977. /**
  50978. * Gets the box size of the impostor
  50979. * @param impostor impostor to get box size from
  50980. * @param result the resulting box size
  50981. */
  50982. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50983. /**
  50984. * Disposes of the impostor
  50985. */
  50986. dispose(): void;
  50987. /**
  50988. * Does a raycast in the physics world
  50989. * @param from when should the ray start?
  50990. * @param to when should the ray end?
  50991. * @returns PhysicsRaycastResult
  50992. */
  50993. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50994. }
  50995. }
  50996. declare module "babylonjs/Probes/reflectionProbe" {
  50997. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50998. import { Vector3 } from "babylonjs/Maths/math";
  50999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51000. import { Nullable } from "babylonjs/types";
  51001. import { Scene } from "babylonjs/scene";
  51002. module "babylonjs/abstractScene" {
  51003. interface AbstractScene {
  51004. /**
  51005. * The list of reflection probes added to the scene
  51006. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51007. */
  51008. reflectionProbes: Array<ReflectionProbe>;
  51009. /**
  51010. * Removes the given reflection probe from this scene.
  51011. * @param toRemove The reflection probe to remove
  51012. * @returns The index of the removed reflection probe
  51013. */
  51014. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51015. /**
  51016. * Adds the given reflection probe to this scene.
  51017. * @param newReflectionProbe The reflection probe to add
  51018. */
  51019. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51020. }
  51021. }
  51022. /**
  51023. * Class used to generate realtime reflection / refraction cube textures
  51024. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51025. */
  51026. export class ReflectionProbe {
  51027. /** defines the name of the probe */
  51028. name: string;
  51029. private _scene;
  51030. private _renderTargetTexture;
  51031. private _projectionMatrix;
  51032. private _viewMatrix;
  51033. private _target;
  51034. private _add;
  51035. private _attachedMesh;
  51036. private _invertYAxis;
  51037. /** Gets or sets probe position (center of the cube map) */
  51038. position: Vector3;
  51039. /**
  51040. * Creates a new reflection probe
  51041. * @param name defines the name of the probe
  51042. * @param size defines the texture resolution (for each face)
  51043. * @param scene defines the hosting scene
  51044. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51045. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51046. */
  51047. constructor(
  51048. /** defines the name of the probe */
  51049. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51050. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51051. samples: number;
  51052. /** Gets or sets the refresh rate to use (on every frame by default) */
  51053. refreshRate: number;
  51054. /**
  51055. * Gets the hosting scene
  51056. * @returns a Scene
  51057. */
  51058. getScene(): Scene;
  51059. /** Gets the internal CubeTexture used to render to */
  51060. readonly cubeTexture: RenderTargetTexture;
  51061. /** Gets the list of meshes to render */
  51062. readonly renderList: Nullable<AbstractMesh[]>;
  51063. /**
  51064. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51065. * @param mesh defines the mesh to attach to
  51066. */
  51067. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51068. /**
  51069. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51070. * @param renderingGroupId The rendering group id corresponding to its index
  51071. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51072. */
  51073. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51074. /**
  51075. * Clean all associated resources
  51076. */
  51077. dispose(): void;
  51078. /**
  51079. * Converts the reflection probe information to a readable string for debug purpose.
  51080. * @param fullDetails Supports for multiple levels of logging within scene loading
  51081. * @returns the human readable reflection probe info
  51082. */
  51083. toString(fullDetails?: boolean): string;
  51084. /**
  51085. * Get the class name of the relfection probe.
  51086. * @returns "ReflectionProbe"
  51087. */
  51088. getClassName(): string;
  51089. /**
  51090. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51091. * @returns The JSON representation of the texture
  51092. */
  51093. serialize(): any;
  51094. /**
  51095. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51096. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51097. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51098. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51099. * @returns The parsed reflection probe if successful
  51100. */
  51101. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51102. }
  51103. }
  51104. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51105. /** @hidden */
  51106. export var _BabylonLoaderRegistered: boolean;
  51107. }
  51108. declare module "babylonjs/Loading/Plugins/index" {
  51109. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51110. }
  51111. declare module "babylonjs/Loading/index" {
  51112. export * from "babylonjs/Loading/loadingScreen";
  51113. export * from "babylonjs/Loading/Plugins/index";
  51114. export * from "babylonjs/Loading/sceneLoader";
  51115. export * from "babylonjs/Loading/sceneLoaderFlags";
  51116. }
  51117. declare module "babylonjs/Materials/Background/index" {
  51118. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51119. }
  51120. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51121. import { Scene } from "babylonjs/scene";
  51122. import { Color3 } from "babylonjs/Maths/math";
  51123. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51124. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51125. /**
  51126. * The Physically based simple base material of BJS.
  51127. *
  51128. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51129. * It is used as the base class for both the specGloss and metalRough conventions.
  51130. */
  51131. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51132. /**
  51133. * Number of Simultaneous lights allowed on the material.
  51134. */
  51135. maxSimultaneousLights: number;
  51136. /**
  51137. * If sets to true, disables all the lights affecting the material.
  51138. */
  51139. disableLighting: boolean;
  51140. /**
  51141. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51142. */
  51143. environmentTexture: BaseTexture;
  51144. /**
  51145. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51146. */
  51147. invertNormalMapX: boolean;
  51148. /**
  51149. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51150. */
  51151. invertNormalMapY: boolean;
  51152. /**
  51153. * Normal map used in the model.
  51154. */
  51155. normalTexture: BaseTexture;
  51156. /**
  51157. * Emissivie color used to self-illuminate the model.
  51158. */
  51159. emissiveColor: Color3;
  51160. /**
  51161. * Emissivie texture used to self-illuminate the model.
  51162. */
  51163. emissiveTexture: BaseTexture;
  51164. /**
  51165. * Occlusion Channel Strenght.
  51166. */
  51167. occlusionStrength: number;
  51168. /**
  51169. * Occlusion Texture of the material (adding extra occlusion effects).
  51170. */
  51171. occlusionTexture: BaseTexture;
  51172. /**
  51173. * Defines the alpha limits in alpha test mode.
  51174. */
  51175. alphaCutOff: number;
  51176. /**
  51177. * Gets the current double sided mode.
  51178. */
  51179. /**
  51180. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51181. */
  51182. doubleSided: boolean;
  51183. /**
  51184. * Stores the pre-calculated light information of a mesh in a texture.
  51185. */
  51186. lightmapTexture: BaseTexture;
  51187. /**
  51188. * If true, the light map contains occlusion information instead of lighting info.
  51189. */
  51190. useLightmapAsShadowmap: boolean;
  51191. /**
  51192. * Instantiates a new PBRMaterial instance.
  51193. *
  51194. * @param name The material name
  51195. * @param scene The scene the material will be use in.
  51196. */
  51197. constructor(name: string, scene: Scene);
  51198. getClassName(): string;
  51199. }
  51200. }
  51201. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51202. import { Scene } from "babylonjs/scene";
  51203. import { Color3 } from "babylonjs/Maths/math";
  51204. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51205. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51206. /**
  51207. * The PBR material of BJS following the metal roughness convention.
  51208. *
  51209. * This fits to the PBR convention in the GLTF definition:
  51210. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51211. */
  51212. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51213. /**
  51214. * The base color has two different interpretations depending on the value of metalness.
  51215. * When the material is a metal, the base color is the specific measured reflectance value
  51216. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51217. * of the material.
  51218. */
  51219. baseColor: Color3;
  51220. /**
  51221. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51222. * well as opacity information in the alpha channel.
  51223. */
  51224. baseTexture: BaseTexture;
  51225. /**
  51226. * Specifies the metallic scalar value of the material.
  51227. * Can also be used to scale the metalness values of the metallic texture.
  51228. */
  51229. metallic: number;
  51230. /**
  51231. * Specifies the roughness scalar value of the material.
  51232. * Can also be used to scale the roughness values of the metallic texture.
  51233. */
  51234. roughness: number;
  51235. /**
  51236. * Texture containing both the metallic value in the B channel and the
  51237. * roughness value in the G channel to keep better precision.
  51238. */
  51239. metallicRoughnessTexture: BaseTexture;
  51240. /**
  51241. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51242. *
  51243. * @param name The material name
  51244. * @param scene The scene the material will be use in.
  51245. */
  51246. constructor(name: string, scene: Scene);
  51247. /**
  51248. * Return the currrent class name of the material.
  51249. */
  51250. getClassName(): string;
  51251. /**
  51252. * Makes a duplicate of the current material.
  51253. * @param name - name to use for the new material.
  51254. */
  51255. clone(name: string): PBRMetallicRoughnessMaterial;
  51256. /**
  51257. * Serialize the material to a parsable JSON object.
  51258. */
  51259. serialize(): any;
  51260. /**
  51261. * Parses a JSON object correponding to the serialize function.
  51262. */
  51263. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51264. }
  51265. }
  51266. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51267. import { Scene } from "babylonjs/scene";
  51268. import { Color3 } from "babylonjs/Maths/math";
  51269. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51270. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51271. /**
  51272. * The PBR material of BJS following the specular glossiness convention.
  51273. *
  51274. * This fits to the PBR convention in the GLTF definition:
  51275. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51276. */
  51277. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51278. /**
  51279. * Specifies the diffuse color of the material.
  51280. */
  51281. diffuseColor: Color3;
  51282. /**
  51283. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51284. * channel.
  51285. */
  51286. diffuseTexture: BaseTexture;
  51287. /**
  51288. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51289. */
  51290. specularColor: Color3;
  51291. /**
  51292. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51293. */
  51294. glossiness: number;
  51295. /**
  51296. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51297. */
  51298. specularGlossinessTexture: BaseTexture;
  51299. /**
  51300. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51301. *
  51302. * @param name The material name
  51303. * @param scene The scene the material will be use in.
  51304. */
  51305. constructor(name: string, scene: Scene);
  51306. /**
  51307. * Return the currrent class name of the material.
  51308. */
  51309. getClassName(): string;
  51310. /**
  51311. * Makes a duplicate of the current material.
  51312. * @param name - name to use for the new material.
  51313. */
  51314. clone(name: string): PBRSpecularGlossinessMaterial;
  51315. /**
  51316. * Serialize the material to a parsable JSON object.
  51317. */
  51318. serialize(): any;
  51319. /**
  51320. * Parses a JSON object correponding to the serialize function.
  51321. */
  51322. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51323. }
  51324. }
  51325. declare module "babylonjs/Materials/PBR/index" {
  51326. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51327. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51328. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51329. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51330. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51331. }
  51332. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51333. import { Nullable } from "babylonjs/types";
  51334. import { Scene } from "babylonjs/scene";
  51335. import { Matrix } from "babylonjs/Maths/math";
  51336. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51337. /**
  51338. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51339. * It can help converting any input color in a desired output one. This can then be used to create effects
  51340. * from sepia, black and white to sixties or futuristic rendering...
  51341. *
  51342. * The only supported format is currently 3dl.
  51343. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51344. */
  51345. export class ColorGradingTexture extends BaseTexture {
  51346. /**
  51347. * The current texture matrix. (will always be identity in color grading texture)
  51348. */
  51349. private _textureMatrix;
  51350. /**
  51351. * The texture URL.
  51352. */
  51353. url: string;
  51354. /**
  51355. * Empty line regex stored for GC.
  51356. */
  51357. private static _noneEmptyLineRegex;
  51358. private _engine;
  51359. /**
  51360. * Instantiates a ColorGradingTexture from the following parameters.
  51361. *
  51362. * @param url The location of the color gradind data (currently only supporting 3dl)
  51363. * @param scene The scene the texture will be used in
  51364. */
  51365. constructor(url: string, scene: Scene);
  51366. /**
  51367. * Returns the texture matrix used in most of the material.
  51368. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51369. */
  51370. getTextureMatrix(): Matrix;
  51371. /**
  51372. * Occurs when the file being loaded is a .3dl LUT file.
  51373. */
  51374. private load3dlTexture;
  51375. /**
  51376. * Starts the loading process of the texture.
  51377. */
  51378. private loadTexture;
  51379. /**
  51380. * Clones the color gradind texture.
  51381. */
  51382. clone(): ColorGradingTexture;
  51383. /**
  51384. * Called during delayed load for textures.
  51385. */
  51386. delayLoad(): void;
  51387. /**
  51388. * Parses a color grading texture serialized by Babylon.
  51389. * @param parsedTexture The texture information being parsedTexture
  51390. * @param scene The scene to load the texture in
  51391. * @param rootUrl The root url of the data assets to load
  51392. * @return A color gradind texture
  51393. */
  51394. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51395. /**
  51396. * Serializes the LUT texture to json format.
  51397. */
  51398. serialize(): any;
  51399. }
  51400. }
  51401. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51403. import { Scene } from "babylonjs/scene";
  51404. import { Nullable } from "babylonjs/types";
  51405. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51406. /**
  51407. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51408. */
  51409. export class EquiRectangularCubeTexture extends BaseTexture {
  51410. /** The six faces of the cube. */
  51411. private static _FacesMapping;
  51412. private _noMipmap;
  51413. private _onLoad;
  51414. private _onError;
  51415. /** The size of the cubemap. */
  51416. private _size;
  51417. /** The buffer of the image. */
  51418. private _buffer;
  51419. /** The width of the input image. */
  51420. private _width;
  51421. /** The height of the input image. */
  51422. private _height;
  51423. /** The URL to the image. */
  51424. url: string;
  51425. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51426. coordinatesMode: number;
  51427. /**
  51428. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51429. * @param url The location of the image
  51430. * @param scene The scene the texture will be used in
  51431. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51432. * @param noMipmap Forces to not generate the mipmap if true
  51433. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51434. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51435. * @param onLoad — defines a callback called when texture is loaded
  51436. * @param onError — defines a callback called if there is an error
  51437. */
  51438. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51439. /**
  51440. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51441. */
  51442. private loadImage;
  51443. /**
  51444. * Convert the image buffer into a cubemap and create a CubeTexture.
  51445. */
  51446. private loadTexture;
  51447. /**
  51448. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51449. * @param buffer The ArrayBuffer that should be converted.
  51450. * @returns The buffer as Float32Array.
  51451. */
  51452. private getFloat32ArrayFromArrayBuffer;
  51453. /**
  51454. * Get the current class name of the texture useful for serialization or dynamic coding.
  51455. * @returns "EquiRectangularCubeTexture"
  51456. */
  51457. getClassName(): string;
  51458. /**
  51459. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51460. * @returns A clone of the current EquiRectangularCubeTexture.
  51461. */
  51462. clone(): EquiRectangularCubeTexture;
  51463. }
  51464. }
  51465. declare module "babylonjs/Misc/tga" {
  51466. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51467. /**
  51468. * Based on jsTGALoader - Javascript loader for TGA file
  51469. * By Vincent Thibault
  51470. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51471. */
  51472. export class TGATools {
  51473. private static _TYPE_INDEXED;
  51474. private static _TYPE_RGB;
  51475. private static _TYPE_GREY;
  51476. private static _TYPE_RLE_INDEXED;
  51477. private static _TYPE_RLE_RGB;
  51478. private static _TYPE_RLE_GREY;
  51479. private static _ORIGIN_MASK;
  51480. private static _ORIGIN_SHIFT;
  51481. private static _ORIGIN_BL;
  51482. private static _ORIGIN_BR;
  51483. private static _ORIGIN_UL;
  51484. private static _ORIGIN_UR;
  51485. /**
  51486. * Gets the header of a TGA file
  51487. * @param data defines the TGA data
  51488. * @returns the header
  51489. */
  51490. static GetTGAHeader(data: Uint8Array): any;
  51491. /**
  51492. * Uploads TGA content to a Babylon Texture
  51493. * @hidden
  51494. */
  51495. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51496. /** @hidden */
  51497. 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;
  51498. /** @hidden */
  51499. 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;
  51500. /** @hidden */
  51501. 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;
  51502. /** @hidden */
  51503. 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;
  51504. /** @hidden */
  51505. 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;
  51506. /** @hidden */
  51507. 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;
  51508. }
  51509. }
  51510. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51511. import { Nullable } from "babylonjs/types";
  51512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51513. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51514. /**
  51515. * Implementation of the TGA Texture Loader.
  51516. * @hidden
  51517. */
  51518. export class _TGATextureLoader implements IInternalTextureLoader {
  51519. /**
  51520. * Defines wether the loader supports cascade loading the different faces.
  51521. */
  51522. readonly supportCascades: boolean;
  51523. /**
  51524. * This returns if the loader support the current file information.
  51525. * @param extension defines the file extension of the file being loaded
  51526. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51527. * @param fallback defines the fallback internal texture if any
  51528. * @param isBase64 defines whether the texture is encoded as a base64
  51529. * @param isBuffer defines whether the texture data are stored as a buffer
  51530. * @returns true if the loader can load the specified file
  51531. */
  51532. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51533. /**
  51534. * Transform the url before loading if required.
  51535. * @param rootUrl the url of the texture
  51536. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51537. * @returns the transformed texture
  51538. */
  51539. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51540. /**
  51541. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51542. * @param rootUrl the url of the texture
  51543. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51544. * @returns the fallback texture
  51545. */
  51546. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51547. /**
  51548. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51549. * @param data contains the texture data
  51550. * @param texture defines the BabylonJS internal texture
  51551. * @param createPolynomials will be true if polynomials have been requested
  51552. * @param onLoad defines the callback to trigger once the texture is ready
  51553. * @param onError defines the callback to trigger in case of error
  51554. */
  51555. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51556. /**
  51557. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51558. * @param data contains the texture data
  51559. * @param texture defines the BabylonJS internal texture
  51560. * @param callback defines the method to call once ready to upload
  51561. */
  51562. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51563. }
  51564. }
  51565. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51566. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51567. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51568. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51569. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51570. }
  51571. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51572. import { Scene } from "babylonjs/scene";
  51573. import { Texture } from "babylonjs/Materials/Textures/texture";
  51574. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51575. /**
  51576. * 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.
  51577. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51578. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51579. */
  51580. export class CustomProceduralTexture extends ProceduralTexture {
  51581. private _animate;
  51582. private _time;
  51583. private _config;
  51584. private _texturePath;
  51585. /**
  51586. * Instantiates a new Custom Procedural Texture.
  51587. * 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.
  51588. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51589. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51590. * @param name Define the name of the texture
  51591. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51592. * @param size Define the size of the texture to create
  51593. * @param scene Define the scene the texture belongs to
  51594. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51595. * @param generateMipMaps Define if the texture should creates mip maps or not
  51596. */
  51597. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51598. private _loadJson;
  51599. /**
  51600. * Is the texture ready to be used ? (rendered at least once)
  51601. * @returns true if ready, otherwise, false.
  51602. */
  51603. isReady(): boolean;
  51604. /**
  51605. * Render the texture to its associated render target.
  51606. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51607. */
  51608. render(useCameraPostProcess?: boolean): void;
  51609. /**
  51610. * Update the list of dependant textures samplers in the shader.
  51611. */
  51612. updateTextures(): void;
  51613. /**
  51614. * Update the uniform values of the procedural texture in the shader.
  51615. */
  51616. updateShaderUniforms(): void;
  51617. /**
  51618. * Define if the texture animates or not.
  51619. */
  51620. animate: boolean;
  51621. }
  51622. }
  51623. declare module "babylonjs/Shaders/noise.fragment" {
  51624. /** @hidden */
  51625. export var noisePixelShader: {
  51626. name: string;
  51627. shader: string;
  51628. };
  51629. }
  51630. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51631. import { Nullable } from "babylonjs/types";
  51632. import { Scene } from "babylonjs/scene";
  51633. import { Texture } from "babylonjs/Materials/Textures/texture";
  51634. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51635. import "babylonjs/Shaders/noise.fragment";
  51636. /**
  51637. * Class used to generate noise procedural textures
  51638. */
  51639. export class NoiseProceduralTexture extends ProceduralTexture {
  51640. private _time;
  51641. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51642. brightness: number;
  51643. /** Defines the number of octaves to process */
  51644. octaves: number;
  51645. /** Defines the level of persistence (0.8 by default) */
  51646. persistence: number;
  51647. /** Gets or sets animation speed factor (default is 1) */
  51648. animationSpeedFactor: number;
  51649. /**
  51650. * Creates a new NoiseProceduralTexture
  51651. * @param name defines the name fo the texture
  51652. * @param size defines the size of the texture (default is 256)
  51653. * @param scene defines the hosting scene
  51654. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51655. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51656. */
  51657. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51658. private _updateShaderUniforms;
  51659. protected _getDefines(): string;
  51660. /** Generate the current state of the procedural texture */
  51661. render(useCameraPostProcess?: boolean): void;
  51662. /**
  51663. * Serializes this noise procedural texture
  51664. * @returns a serialized noise procedural texture object
  51665. */
  51666. serialize(): any;
  51667. /**
  51668. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51669. * @param parsedTexture defines parsed texture data
  51670. * @param scene defines the current scene
  51671. * @param rootUrl defines the root URL containing noise procedural texture information
  51672. * @returns a parsed NoiseProceduralTexture
  51673. */
  51674. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51675. }
  51676. }
  51677. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51678. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51679. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51680. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51681. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51682. }
  51683. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51684. import { Nullable } from "babylonjs/types";
  51685. import { Scene } from "babylonjs/scene";
  51686. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51687. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51688. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51689. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51690. /**
  51691. * Raw cube texture where the raw buffers are passed in
  51692. */
  51693. export class RawCubeTexture extends CubeTexture {
  51694. /**
  51695. * Creates a cube texture where the raw buffers are passed in.
  51696. * @param scene defines the scene the texture is attached to
  51697. * @param data defines the array of data to use to create each face
  51698. * @param size defines the size of the textures
  51699. * @param format defines the format of the data
  51700. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51701. * @param generateMipMaps defines if the engine should generate the mip levels
  51702. * @param invertY defines if data must be stored with Y axis inverted
  51703. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51704. * @param compression defines the compression used (null by default)
  51705. */
  51706. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51707. /**
  51708. * Updates the raw cube texture.
  51709. * @param data defines the data to store
  51710. * @param format defines the data format
  51711. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51712. * @param invertY defines if data must be stored with Y axis inverted
  51713. * @param compression defines the compression used (null by default)
  51714. * @param level defines which level of the texture to update
  51715. */
  51716. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51717. /**
  51718. * Updates a raw cube texture with RGBD encoded data.
  51719. * @param data defines the array of data [mipmap][face] to use to create each face
  51720. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51721. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51722. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51723. * @returns a promsie that resolves when the operation is complete
  51724. */
  51725. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51726. /**
  51727. * Clones the raw cube texture.
  51728. * @return a new cube texture
  51729. */
  51730. clone(): CubeTexture;
  51731. /** @hidden */
  51732. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51733. }
  51734. }
  51735. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51736. import { Scene } from "babylonjs/scene";
  51737. import { Texture } from "babylonjs/Materials/Textures/texture";
  51738. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51739. /**
  51740. * Class used to store 3D textures containing user data
  51741. */
  51742. export class RawTexture3D extends Texture {
  51743. /** Gets or sets the texture format to use */
  51744. format: number;
  51745. private _engine;
  51746. /**
  51747. * Create a new RawTexture3D
  51748. * @param data defines the data of the texture
  51749. * @param width defines the width of the texture
  51750. * @param height defines the height of the texture
  51751. * @param depth defines the depth of the texture
  51752. * @param format defines the texture format to use
  51753. * @param scene defines the hosting scene
  51754. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51755. * @param invertY defines if texture must be stored with Y axis inverted
  51756. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51757. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51758. */
  51759. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51760. /** Gets or sets the texture format to use */
  51761. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51762. /**
  51763. * Update the texture with new data
  51764. * @param data defines the data to store in the texture
  51765. */
  51766. update(data: ArrayBufferView): void;
  51767. }
  51768. }
  51769. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51770. import { Scene } from "babylonjs/scene";
  51771. import { Plane } from "babylonjs/Maths/math";
  51772. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51773. /**
  51774. * Creates a refraction texture used by refraction channel of the standard material.
  51775. * It is like a mirror but to see through a material.
  51776. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51777. */
  51778. export class RefractionTexture extends RenderTargetTexture {
  51779. /**
  51780. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51781. * 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.
  51782. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51783. */
  51784. refractionPlane: Plane;
  51785. /**
  51786. * Define how deep under the surface we should see.
  51787. */
  51788. depth: number;
  51789. /**
  51790. * Creates a refraction texture used by refraction channel of the standard material.
  51791. * It is like a mirror but to see through a material.
  51792. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51793. * @param name Define the texture name
  51794. * @param size Define the size of the underlying texture
  51795. * @param scene Define the scene the refraction belongs to
  51796. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51797. */
  51798. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51799. /**
  51800. * Clone the refraction texture.
  51801. * @returns the cloned texture
  51802. */
  51803. clone(): RefractionTexture;
  51804. /**
  51805. * Serialize the texture to a JSON representation you could use in Parse later on
  51806. * @returns the serialized JSON representation
  51807. */
  51808. serialize(): any;
  51809. }
  51810. }
  51811. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  51812. import { Nullable } from "babylonjs/types";
  51813. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51814. import { Matrix } from "babylonjs/Maths/math";
  51815. import { Engine } from "babylonjs/Engines/engine";
  51816. import { Scene } from "babylonjs/scene";
  51817. /**
  51818. * Defines the options related to the creation of an HtmlElementTexture
  51819. */
  51820. export interface IHtmlElementTextureOptions {
  51821. /**
  51822. * Defines wether mip maps should be created or not.
  51823. */
  51824. generateMipMaps?: boolean;
  51825. /**
  51826. * Defines the sampling mode of the texture.
  51827. */
  51828. samplingMode?: number;
  51829. /**
  51830. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51831. */
  51832. engine: Nullable<Engine>;
  51833. /**
  51834. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51835. */
  51836. scene: Nullable<Scene>;
  51837. }
  51838. /**
  51839. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51840. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51841. * is automatically managed.
  51842. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51843. * in your application.
  51844. *
  51845. * As the update is not automatic, you need to call them manually.
  51846. */
  51847. export class HtmlElementTexture extends BaseTexture {
  51848. /**
  51849. * The texture URL.
  51850. */
  51851. element: HTMLVideoElement | HTMLCanvasElement;
  51852. private static readonly DefaultOptions;
  51853. private _textureMatrix;
  51854. private _engine;
  51855. private _isVideo;
  51856. private _generateMipMaps;
  51857. private _samplingMode;
  51858. /**
  51859. * Instantiates a HtmlElementTexture from the following parameters.
  51860. *
  51861. * @param name Defines the name of the texture
  51862. * @param element Defines the video or canvas the texture is filled with
  51863. * @param options Defines the other none mandatory texture creation options
  51864. */
  51865. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51866. private _createInternalTexture;
  51867. /**
  51868. * Returns the texture matrix used in most of the material.
  51869. */
  51870. getTextureMatrix(): Matrix;
  51871. /**
  51872. * Updates the content of the texture.
  51873. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51874. */
  51875. update(invertY?: Nullable<boolean>): void;
  51876. }
  51877. }
  51878. declare module "babylonjs/Materials/Textures/index" {
  51879. export * from "babylonjs/Materials/Textures/baseTexture";
  51880. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51881. export * from "babylonjs/Materials/Textures/cubeTexture";
  51882. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51883. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51884. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51885. export * from "babylonjs/Materials/Textures/internalTexture";
  51886. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51887. export * from "babylonjs/Materials/Textures/Loaders/index";
  51888. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51889. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51890. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51891. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51892. export * from "babylonjs/Materials/Textures/rawTexture";
  51893. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51894. export * from "babylonjs/Materials/Textures/refractionTexture";
  51895. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51896. export * from "babylonjs/Materials/Textures/texture";
  51897. export * from "babylonjs/Materials/Textures/videoTexture";
  51898. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  51899. }
  51900. declare module "babylonjs/Materials/index" {
  51901. export * from "babylonjs/Materials/Background/index";
  51902. export * from "babylonjs/Materials/colorCurves";
  51903. export * from "babylonjs/Materials/effect";
  51904. export * from "babylonjs/Materials/fresnelParameters";
  51905. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51906. export * from "babylonjs/Materials/material";
  51907. export * from "babylonjs/Materials/materialDefines";
  51908. export * from "babylonjs/Materials/materialHelper";
  51909. export * from "babylonjs/Materials/multiMaterial";
  51910. export * from "babylonjs/Materials/PBR/index";
  51911. export * from "babylonjs/Materials/pushMaterial";
  51912. export * from "babylonjs/Materials/shaderMaterial";
  51913. export * from "babylonjs/Materials/standardMaterial";
  51914. export * from "babylonjs/Materials/Textures/index";
  51915. export * from "babylonjs/Materials/uniformBuffer";
  51916. export * from "babylonjs/Materials/materialFlags";
  51917. }
  51918. declare module "babylonjs/Maths/index" {
  51919. export * from "babylonjs/Maths/math.scalar";
  51920. export * from "babylonjs/Maths/math";
  51921. export * from "babylonjs/Maths/sphericalPolynomial";
  51922. }
  51923. declare module "babylonjs/Misc/workerPool" {
  51924. import { IDisposable } from "babylonjs/scene";
  51925. /**
  51926. * Helper class to push actions to a pool of workers.
  51927. */
  51928. export class WorkerPool implements IDisposable {
  51929. private _workerInfos;
  51930. private _pendingActions;
  51931. /**
  51932. * Constructor
  51933. * @param workers Array of workers to use for actions
  51934. */
  51935. constructor(workers: Array<Worker>);
  51936. /**
  51937. * Terminates all workers and clears any pending actions.
  51938. */
  51939. dispose(): void;
  51940. /**
  51941. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51942. * pended until a worker has completed its action.
  51943. * @param action The action to perform. Call onComplete when the action is complete.
  51944. */
  51945. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51946. private _execute;
  51947. }
  51948. }
  51949. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51950. import { IDisposable } from "babylonjs/scene";
  51951. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51952. /**
  51953. * Configuration for Draco compression
  51954. */
  51955. export interface IDracoCompressionConfiguration {
  51956. /**
  51957. * Configuration for the decoder.
  51958. */
  51959. decoder: {
  51960. /**
  51961. * The url to the WebAssembly module.
  51962. */
  51963. wasmUrl?: string;
  51964. /**
  51965. * The url to the WebAssembly binary.
  51966. */
  51967. wasmBinaryUrl?: string;
  51968. /**
  51969. * The url to the fallback JavaScript module.
  51970. */
  51971. fallbackUrl?: string;
  51972. };
  51973. }
  51974. /**
  51975. * Draco compression (https://google.github.io/draco/)
  51976. *
  51977. * This class wraps the Draco module.
  51978. *
  51979. * **Encoder**
  51980. *
  51981. * The encoder is not currently implemented.
  51982. *
  51983. * **Decoder**
  51984. *
  51985. * 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.
  51986. *
  51987. * To update the configuration, use the following code:
  51988. * ```javascript
  51989. * DracoCompression.Configuration = {
  51990. * decoder: {
  51991. * wasmUrl: "<url to the WebAssembly library>",
  51992. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51993. * fallbackUrl: "<url to the fallback JavaScript library>",
  51994. * }
  51995. * };
  51996. * ```
  51997. *
  51998. * 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.
  51999. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  52000. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52001. *
  52002. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52003. * ```javascript
  52004. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52005. * ```
  52006. *
  52007. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52008. */
  52009. export class DracoCompression implements IDisposable {
  52010. private _workerPoolPromise?;
  52011. private _decoderModulePromise?;
  52012. /**
  52013. * The configuration. Defaults to the following urls:
  52014. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52015. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52016. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52017. */
  52018. static Configuration: IDracoCompressionConfiguration;
  52019. /**
  52020. * Returns true if the decoder configuration is available.
  52021. */
  52022. static readonly DecoderAvailable: boolean;
  52023. /**
  52024. * Default number of workers to create when creating the draco compression object.
  52025. */
  52026. static DefaultNumWorkers: number;
  52027. private static GetDefaultNumWorkers;
  52028. private static _Default;
  52029. /**
  52030. * Default instance for the draco compression object.
  52031. */
  52032. static readonly Default: DracoCompression;
  52033. /**
  52034. * Constructor
  52035. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52036. */
  52037. constructor(numWorkers?: number);
  52038. /**
  52039. * Stop all async operations and release resources.
  52040. */
  52041. dispose(): void;
  52042. /**
  52043. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52044. * @returns a promise that resolves when ready
  52045. */
  52046. whenReadyAsync(): Promise<void>;
  52047. /**
  52048. * Decode Draco compressed mesh data to vertex data.
  52049. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52050. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52051. * @returns A promise that resolves with the decoded vertex data
  52052. */
  52053. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52054. [kind: string]: number;
  52055. }): Promise<VertexData>;
  52056. }
  52057. }
  52058. declare module "babylonjs/Meshes/Compression/index" {
  52059. export * from "babylonjs/Meshes/Compression/dracoCompression";
  52060. }
  52061. declare module "babylonjs/Meshes/csg" {
  52062. import { Nullable } from "babylonjs/types";
  52063. import { Scene } from "babylonjs/scene";
  52064. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  52065. import { Mesh } from "babylonjs/Meshes/mesh";
  52066. import { Material } from "babylonjs/Materials/material";
  52067. /**
  52068. * Class for building Constructive Solid Geometry
  52069. */
  52070. export class CSG {
  52071. private polygons;
  52072. /**
  52073. * The world matrix
  52074. */
  52075. matrix: Matrix;
  52076. /**
  52077. * Stores the position
  52078. */
  52079. position: Vector3;
  52080. /**
  52081. * Stores the rotation
  52082. */
  52083. rotation: Vector3;
  52084. /**
  52085. * Stores the rotation quaternion
  52086. */
  52087. rotationQuaternion: Nullable<Quaternion>;
  52088. /**
  52089. * Stores the scaling vector
  52090. */
  52091. scaling: Vector3;
  52092. /**
  52093. * Convert the Mesh to CSG
  52094. * @param mesh The Mesh to convert to CSG
  52095. * @returns A new CSG from the Mesh
  52096. */
  52097. static FromMesh(mesh: Mesh): CSG;
  52098. /**
  52099. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52100. * @param polygons Polygons used to construct a CSG solid
  52101. */
  52102. private static FromPolygons;
  52103. /**
  52104. * Clones, or makes a deep copy, of the CSG
  52105. * @returns A new CSG
  52106. */
  52107. clone(): CSG;
  52108. /**
  52109. * Unions this CSG with another CSG
  52110. * @param csg The CSG to union against this CSG
  52111. * @returns The unioned CSG
  52112. */
  52113. union(csg: CSG): CSG;
  52114. /**
  52115. * Unions this CSG with another CSG in place
  52116. * @param csg The CSG to union against this CSG
  52117. */
  52118. unionInPlace(csg: CSG): void;
  52119. /**
  52120. * Subtracts this CSG with another CSG
  52121. * @param csg The CSG to subtract against this CSG
  52122. * @returns A new CSG
  52123. */
  52124. subtract(csg: CSG): CSG;
  52125. /**
  52126. * Subtracts this CSG with another CSG in place
  52127. * @param csg The CSG to subtact against this CSG
  52128. */
  52129. subtractInPlace(csg: CSG): void;
  52130. /**
  52131. * Intersect this CSG with another CSG
  52132. * @param csg The CSG to intersect against this CSG
  52133. * @returns A new CSG
  52134. */
  52135. intersect(csg: CSG): CSG;
  52136. /**
  52137. * Intersects this CSG with another CSG in place
  52138. * @param csg The CSG to intersect against this CSG
  52139. */
  52140. intersectInPlace(csg: CSG): void;
  52141. /**
  52142. * Return a new CSG solid with solid and empty space switched. This solid is
  52143. * not modified.
  52144. * @returns A new CSG solid with solid and empty space switched
  52145. */
  52146. inverse(): CSG;
  52147. /**
  52148. * Inverses the CSG in place
  52149. */
  52150. inverseInPlace(): void;
  52151. /**
  52152. * This is used to keep meshes transformations so they can be restored
  52153. * when we build back a Babylon Mesh
  52154. * NB : All CSG operations are performed in world coordinates
  52155. * @param csg The CSG to copy the transform attributes from
  52156. * @returns This CSG
  52157. */
  52158. copyTransformAttributes(csg: CSG): CSG;
  52159. /**
  52160. * Build Raw mesh from CSG
  52161. * Coordinates here are in world space
  52162. * @param name The name of the mesh geometry
  52163. * @param scene The Scene
  52164. * @param keepSubMeshes Specifies if the submeshes should be kept
  52165. * @returns A new Mesh
  52166. */
  52167. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52168. /**
  52169. * Build Mesh from CSG taking material and transforms into account
  52170. * @param name The name of the Mesh
  52171. * @param material The material of the Mesh
  52172. * @param scene The Scene
  52173. * @param keepSubMeshes Specifies if submeshes should be kept
  52174. * @returns The new Mesh
  52175. */
  52176. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52177. }
  52178. }
  52179. declare module "babylonjs/Meshes/trailMesh" {
  52180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52181. import { Mesh } from "babylonjs/Meshes/mesh";
  52182. import { Scene } from "babylonjs/scene";
  52183. /**
  52184. * Class used to create a trail following a mesh
  52185. */
  52186. export class TrailMesh extends Mesh {
  52187. private _generator;
  52188. private _autoStart;
  52189. private _running;
  52190. private _diameter;
  52191. private _length;
  52192. private _sectionPolygonPointsCount;
  52193. private _sectionVectors;
  52194. private _sectionNormalVectors;
  52195. private _beforeRenderObserver;
  52196. /**
  52197. * @constructor
  52198. * @param name The value used by scene.getMeshByName() to do a lookup.
  52199. * @param generator The mesh to generate a trail.
  52200. * @param scene The scene to add this mesh to.
  52201. * @param diameter Diameter of trailing mesh. Default is 1.
  52202. * @param length Length of trailing mesh. Default is 60.
  52203. * @param autoStart Automatically start trailing mesh. Default true.
  52204. */
  52205. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52206. /**
  52207. * "TrailMesh"
  52208. * @returns "TrailMesh"
  52209. */
  52210. getClassName(): string;
  52211. private _createMesh;
  52212. /**
  52213. * Start trailing mesh.
  52214. */
  52215. start(): void;
  52216. /**
  52217. * Stop trailing mesh.
  52218. */
  52219. stop(): void;
  52220. /**
  52221. * Update trailing mesh geometry.
  52222. */
  52223. update(): void;
  52224. /**
  52225. * Returns a new TrailMesh object.
  52226. * @param name is a string, the name given to the new mesh
  52227. * @param newGenerator use new generator object for cloned trail mesh
  52228. * @returns a new mesh
  52229. */
  52230. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52231. /**
  52232. * Serializes this trail mesh
  52233. * @param serializationObject object to write serialization to
  52234. */
  52235. serialize(serializationObject: any): void;
  52236. /**
  52237. * Parses a serialized trail mesh
  52238. * @param parsedMesh the serialized mesh
  52239. * @param scene the scene to create the trail mesh in
  52240. * @returns the created trail mesh
  52241. */
  52242. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52243. }
  52244. }
  52245. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  52246. import { Vector4 } from "babylonjs/Maths/math";
  52247. import { Mesh } from "babylonjs/Meshes/mesh";
  52248. /**
  52249. * Class containing static functions to help procedurally build meshes
  52250. */
  52251. export class TorusKnotBuilder {
  52252. /**
  52253. * Creates a torus knot mesh
  52254. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52255. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52256. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52257. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52261. * @param name defines the name of the mesh
  52262. * @param options defines the options used to create the mesh
  52263. * @param scene defines the hosting scene
  52264. * @returns the torus knot mesh
  52265. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52266. */
  52267. static CreateTorusKnot(name: string, options: {
  52268. radius?: number;
  52269. tube?: number;
  52270. radialSegments?: number;
  52271. tubularSegments?: number;
  52272. p?: number;
  52273. q?: number;
  52274. updatable?: boolean;
  52275. sideOrientation?: number;
  52276. frontUVs?: Vector4;
  52277. backUVs?: Vector4;
  52278. }, scene: any): Mesh;
  52279. }
  52280. }
  52281. declare module "babylonjs/Meshes/polygonMesh" {
  52282. import { Scene } from "babylonjs/scene";
  52283. import { Vector2, Path2 } from "babylonjs/Maths/math";
  52284. import { Mesh } from "babylonjs/Meshes/mesh";
  52285. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  52286. /**
  52287. * Polygon
  52288. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52289. */
  52290. export class Polygon {
  52291. /**
  52292. * Creates a rectangle
  52293. * @param xmin bottom X coord
  52294. * @param ymin bottom Y coord
  52295. * @param xmax top X coord
  52296. * @param ymax top Y coord
  52297. * @returns points that make the resulting rectation
  52298. */
  52299. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52300. /**
  52301. * Creates a circle
  52302. * @param radius radius of circle
  52303. * @param cx scale in x
  52304. * @param cy scale in y
  52305. * @param numberOfSides number of sides that make up the circle
  52306. * @returns points that make the resulting circle
  52307. */
  52308. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52309. /**
  52310. * Creates a polygon from input string
  52311. * @param input Input polygon data
  52312. * @returns the parsed points
  52313. */
  52314. static Parse(input: string): Vector2[];
  52315. /**
  52316. * Starts building a polygon from x and y coordinates
  52317. * @param x x coordinate
  52318. * @param y y coordinate
  52319. * @returns the started path2
  52320. */
  52321. static StartingAt(x: number, y: number): Path2;
  52322. }
  52323. /**
  52324. * Builds a polygon
  52325. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52326. */
  52327. export class PolygonMeshBuilder {
  52328. private _points;
  52329. private _outlinepoints;
  52330. private _holes;
  52331. private _name;
  52332. private _scene;
  52333. private _epoints;
  52334. private _eholes;
  52335. private _addToepoint;
  52336. /**
  52337. * Babylon reference to the earcut plugin.
  52338. */
  52339. bjsEarcut: any;
  52340. /**
  52341. * Creates a PolygonMeshBuilder
  52342. * @param name name of the builder
  52343. * @param contours Path of the polygon
  52344. * @param scene scene to add to when creating the mesh
  52345. * @param earcutInjection can be used to inject your own earcut reference
  52346. */
  52347. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52348. /**
  52349. * Adds a whole within the polygon
  52350. * @param hole Array of points defining the hole
  52351. * @returns this
  52352. */
  52353. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52354. /**
  52355. * Creates the polygon
  52356. * @param updatable If the mesh should be updatable
  52357. * @param depth The depth of the mesh created
  52358. * @returns the created mesh
  52359. */
  52360. build(updatable?: boolean, depth?: number): Mesh;
  52361. /**
  52362. * Creates the polygon
  52363. * @param depth The depth of the mesh created
  52364. * @returns the created VertexData
  52365. */
  52366. buildVertexData(depth?: number): VertexData;
  52367. /**
  52368. * Adds a side to the polygon
  52369. * @param positions points that make the polygon
  52370. * @param normals normals of the polygon
  52371. * @param uvs uvs of the polygon
  52372. * @param indices indices of the polygon
  52373. * @param bounds bounds of the polygon
  52374. * @param points points of the polygon
  52375. * @param depth depth of the polygon
  52376. * @param flip flip of the polygon
  52377. */
  52378. private addSide;
  52379. }
  52380. }
  52381. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  52382. import { Scene } from "babylonjs/scene";
  52383. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  52384. import { Mesh } from "babylonjs/Meshes/mesh";
  52385. import { Nullable } from "babylonjs/types";
  52386. /**
  52387. * Class containing static functions to help procedurally build meshes
  52388. */
  52389. export class PolygonBuilder {
  52390. /**
  52391. * Creates a polygon mesh
  52392. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52393. * * 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
  52394. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52397. * * Remember you can only change the shape positions, not their number when updating a polygon
  52398. * @param name defines the name of the mesh
  52399. * @param options defines the options used to create the mesh
  52400. * @param scene defines the hosting scene
  52401. * @param earcutInjection can be used to inject your own earcut reference
  52402. * @returns the polygon mesh
  52403. */
  52404. static CreatePolygon(name: string, options: {
  52405. shape: Vector3[];
  52406. holes?: Vector3[][];
  52407. depth?: number;
  52408. faceUV?: Vector4[];
  52409. faceColors?: Color4[];
  52410. updatable?: boolean;
  52411. sideOrientation?: number;
  52412. frontUVs?: Vector4;
  52413. backUVs?: Vector4;
  52414. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52415. /**
  52416. * Creates an extruded polygon mesh, with depth in the Y direction.
  52417. * * 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)
  52418. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52419. * @param name defines the name of the mesh
  52420. * @param options defines the options used to create the mesh
  52421. * @param scene defines the hosting scene
  52422. * @param earcutInjection can be used to inject your own earcut reference
  52423. * @returns the polygon mesh
  52424. */
  52425. static ExtrudePolygon(name: string, options: {
  52426. shape: Vector3[];
  52427. holes?: Vector3[][];
  52428. depth?: number;
  52429. faceUV?: Vector4[];
  52430. faceColors?: Color4[];
  52431. updatable?: boolean;
  52432. sideOrientation?: number;
  52433. frontUVs?: Vector4;
  52434. backUVs?: Vector4;
  52435. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52436. }
  52437. }
  52438. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  52439. import { Scene } from "babylonjs/scene";
  52440. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52441. import { Mesh } from "babylonjs/Meshes/mesh";
  52442. import { Nullable } from "babylonjs/types";
  52443. /**
  52444. * Class containing static functions to help procedurally build meshes
  52445. */
  52446. export class LatheBuilder {
  52447. /**
  52448. * Creates lathe mesh.
  52449. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52450. * * 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
  52451. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52452. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52453. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52454. * * 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
  52455. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52456. * * 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
  52457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52459. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52461. * @param name defines the name of the mesh
  52462. * @param options defines the options used to create the mesh
  52463. * @param scene defines the hosting scene
  52464. * @returns the lathe mesh
  52465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52466. */
  52467. static CreateLathe(name: string, options: {
  52468. shape: Vector3[];
  52469. radius?: number;
  52470. tessellation?: number;
  52471. clip?: number;
  52472. arc?: number;
  52473. closed?: boolean;
  52474. updatable?: boolean;
  52475. sideOrientation?: number;
  52476. frontUVs?: Vector4;
  52477. backUVs?: Vector4;
  52478. cap?: number;
  52479. invertUV?: boolean;
  52480. }, scene?: Nullable<Scene>): Mesh;
  52481. }
  52482. }
  52483. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  52484. import { Nullable } from "babylonjs/types";
  52485. import { Scene } from "babylonjs/scene";
  52486. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52487. import { Mesh } from "babylonjs/Meshes/mesh";
  52488. /**
  52489. * Class containing static functions to help procedurally build meshes
  52490. */
  52491. export class TubeBuilder {
  52492. /**
  52493. * Creates a tube mesh.
  52494. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52495. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52496. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52497. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52498. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52499. * * 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)
  52500. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52501. * * 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
  52502. * * 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
  52503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52505. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52507. * @param name defines the name of the mesh
  52508. * @param options defines the options used to create the mesh
  52509. * @param scene defines the hosting scene
  52510. * @returns the tube mesh
  52511. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52512. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52513. */
  52514. static CreateTube(name: string, options: {
  52515. path: Vector3[];
  52516. radius?: number;
  52517. tessellation?: number;
  52518. radiusFunction?: {
  52519. (i: number, distance: number): number;
  52520. };
  52521. cap?: number;
  52522. arc?: number;
  52523. updatable?: boolean;
  52524. sideOrientation?: number;
  52525. frontUVs?: Vector4;
  52526. backUVs?: Vector4;
  52527. instance?: Mesh;
  52528. invertUV?: boolean;
  52529. }, scene?: Nullable<Scene>): Mesh;
  52530. }
  52531. }
  52532. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52533. import { Scene } from "babylonjs/scene";
  52534. import { Vector4 } from "babylonjs/Maths/math";
  52535. import { Mesh } from "babylonjs/Meshes/mesh";
  52536. import { Nullable } from "babylonjs/types";
  52537. /**
  52538. * Class containing static functions to help procedurally build meshes
  52539. */
  52540. export class IcoSphereBuilder {
  52541. /**
  52542. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52543. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52544. * * 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`)
  52545. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52546. * * 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
  52547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52550. * @param name defines the name of the mesh
  52551. * @param options defines the options used to create the mesh
  52552. * @param scene defines the hosting scene
  52553. * @returns the icosahedron mesh
  52554. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52555. */
  52556. static CreateIcoSphere(name: string, options: {
  52557. radius?: number;
  52558. radiusX?: number;
  52559. radiusY?: number;
  52560. radiusZ?: number;
  52561. flat?: boolean;
  52562. subdivisions?: number;
  52563. sideOrientation?: number;
  52564. frontUVs?: Vector4;
  52565. backUVs?: Vector4;
  52566. updatable?: boolean;
  52567. }, scene?: Nullable<Scene>): Mesh;
  52568. }
  52569. }
  52570. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52571. import { Vector3 } from "babylonjs/Maths/math";
  52572. import { Mesh } from "babylonjs/Meshes/mesh";
  52573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52574. /**
  52575. * Class containing static functions to help procedurally build meshes
  52576. */
  52577. export class DecalBuilder {
  52578. /**
  52579. * Creates a decal mesh.
  52580. * 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
  52581. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52582. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52583. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52584. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52585. * @param name defines the name of the mesh
  52586. * @param sourceMesh defines the mesh where the decal must be applied
  52587. * @param options defines the options used to create the mesh
  52588. * @param scene defines the hosting scene
  52589. * @returns the decal mesh
  52590. * @see https://doc.babylonjs.com/how_to/decals
  52591. */
  52592. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52593. position?: Vector3;
  52594. normal?: Vector3;
  52595. size?: Vector3;
  52596. angle?: number;
  52597. }): Mesh;
  52598. }
  52599. }
  52600. declare module "babylonjs/Meshes/meshBuilder" {
  52601. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52602. import { Nullable } from "babylonjs/types";
  52603. import { Scene } from "babylonjs/scene";
  52604. import { Mesh } from "babylonjs/Meshes/mesh";
  52605. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52606. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52608. /**
  52609. * Class containing static functions to help procedurally build meshes
  52610. */
  52611. export class MeshBuilder {
  52612. /**
  52613. * Creates a box mesh
  52614. * * The parameter `size` sets the size (float) of each box side (default 1)
  52615. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52616. * * 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)
  52617. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52621. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52622. * @param name defines the name of the mesh
  52623. * @param options defines the options used to create the mesh
  52624. * @param scene defines the hosting scene
  52625. * @returns the box mesh
  52626. */
  52627. static CreateBox(name: string, options: {
  52628. size?: number;
  52629. width?: number;
  52630. height?: number;
  52631. depth?: number;
  52632. faceUV?: Vector4[];
  52633. faceColors?: Color4[];
  52634. sideOrientation?: number;
  52635. frontUVs?: Vector4;
  52636. backUVs?: Vector4;
  52637. updatable?: boolean;
  52638. }, scene?: Nullable<Scene>): Mesh;
  52639. /**
  52640. * Creates a sphere mesh
  52641. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52642. * * 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`)
  52643. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52644. * * 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
  52645. * * 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)
  52646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52647. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52649. * @param name defines the name of the mesh
  52650. * @param options defines the options used to create the mesh
  52651. * @param scene defines the hosting scene
  52652. * @returns the sphere mesh
  52653. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52654. */
  52655. static CreateSphere(name: string, options: {
  52656. segments?: number;
  52657. diameter?: number;
  52658. diameterX?: number;
  52659. diameterY?: number;
  52660. diameterZ?: number;
  52661. arc?: number;
  52662. slice?: number;
  52663. sideOrientation?: number;
  52664. frontUVs?: Vector4;
  52665. backUVs?: Vector4;
  52666. updatable?: boolean;
  52667. }, scene?: Nullable<Scene>): Mesh;
  52668. /**
  52669. * Creates a plane polygonal mesh. By default, this is a disc
  52670. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52671. * * 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
  52672. * * 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
  52673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52676. * @param name defines the name of the mesh
  52677. * @param options defines the options used to create the mesh
  52678. * @param scene defines the hosting scene
  52679. * @returns the plane polygonal mesh
  52680. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52681. */
  52682. static CreateDisc(name: string, options: {
  52683. radius?: number;
  52684. tessellation?: number;
  52685. arc?: number;
  52686. updatable?: boolean;
  52687. sideOrientation?: number;
  52688. frontUVs?: Vector4;
  52689. backUVs?: Vector4;
  52690. }, scene?: Nullable<Scene>): Mesh;
  52691. /**
  52692. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52693. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52694. * * 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`)
  52695. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52696. * * 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
  52697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52700. * @param name defines the name of the mesh
  52701. * @param options defines the options used to create the mesh
  52702. * @param scene defines the hosting scene
  52703. * @returns the icosahedron mesh
  52704. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52705. */
  52706. static CreateIcoSphere(name: string, options: {
  52707. radius?: number;
  52708. radiusX?: number;
  52709. radiusY?: number;
  52710. radiusZ?: number;
  52711. flat?: boolean;
  52712. subdivisions?: number;
  52713. sideOrientation?: number;
  52714. frontUVs?: Vector4;
  52715. backUVs?: Vector4;
  52716. updatable?: boolean;
  52717. }, scene?: Nullable<Scene>): Mesh;
  52718. /**
  52719. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52720. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52721. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52722. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52723. * * 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
  52724. * * 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
  52725. * * 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
  52726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52728. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52729. * * 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
  52730. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52731. * * 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
  52732. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52734. * @param name defines the name of the mesh
  52735. * @param options defines the options used to create the mesh
  52736. * @param scene defines the hosting scene
  52737. * @returns the ribbon mesh
  52738. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52739. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52740. */
  52741. static CreateRibbon(name: string, options: {
  52742. pathArray: Vector3[][];
  52743. closeArray?: boolean;
  52744. closePath?: boolean;
  52745. offset?: number;
  52746. updatable?: boolean;
  52747. sideOrientation?: number;
  52748. frontUVs?: Vector4;
  52749. backUVs?: Vector4;
  52750. instance?: Mesh;
  52751. invertUV?: boolean;
  52752. uvs?: Vector2[];
  52753. colors?: Color4[];
  52754. }, scene?: Nullable<Scene>): Mesh;
  52755. /**
  52756. * Creates a cylinder or a cone mesh
  52757. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52758. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52759. * * 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.
  52760. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52761. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52762. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52763. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52764. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52765. * * 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).
  52766. * * 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
  52767. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52768. * * 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
  52769. * * 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.
  52770. * * If `enclose` is false, a ring surface is one element.
  52771. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52772. * * 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
  52773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52776. * @param name defines the name of the mesh
  52777. * @param options defines the options used to create the mesh
  52778. * @param scene defines the hosting scene
  52779. * @returns the cylinder mesh
  52780. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52781. */
  52782. static CreateCylinder(name: string, options: {
  52783. height?: number;
  52784. diameterTop?: number;
  52785. diameterBottom?: number;
  52786. diameter?: number;
  52787. tessellation?: number;
  52788. subdivisions?: number;
  52789. arc?: number;
  52790. faceColors?: Color4[];
  52791. faceUV?: Vector4[];
  52792. updatable?: boolean;
  52793. hasRings?: boolean;
  52794. enclose?: boolean;
  52795. sideOrientation?: number;
  52796. frontUVs?: Vector4;
  52797. backUVs?: Vector4;
  52798. }, scene?: Nullable<Scene>): Mesh;
  52799. /**
  52800. * Creates a torus mesh
  52801. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52802. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52803. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52805. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52807. * @param name defines the name of the mesh
  52808. * @param options defines the options used to create the mesh
  52809. * @param scene defines the hosting scene
  52810. * @returns the torus mesh
  52811. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52812. */
  52813. static CreateTorus(name: string, options: {
  52814. diameter?: number;
  52815. thickness?: number;
  52816. tessellation?: number;
  52817. updatable?: boolean;
  52818. sideOrientation?: number;
  52819. frontUVs?: Vector4;
  52820. backUVs?: Vector4;
  52821. }, scene?: Nullable<Scene>): Mesh;
  52822. /**
  52823. * Creates a torus knot mesh
  52824. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52825. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52826. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52827. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52829. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52831. * @param name defines the name of the mesh
  52832. * @param options defines the options used to create the mesh
  52833. * @param scene defines the hosting scene
  52834. * @returns the torus knot mesh
  52835. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52836. */
  52837. static CreateTorusKnot(name: string, options: {
  52838. radius?: number;
  52839. tube?: number;
  52840. radialSegments?: number;
  52841. tubularSegments?: number;
  52842. p?: number;
  52843. q?: number;
  52844. updatable?: boolean;
  52845. sideOrientation?: number;
  52846. frontUVs?: Vector4;
  52847. backUVs?: Vector4;
  52848. }, scene?: Nullable<Scene>): Mesh;
  52849. /**
  52850. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52851. * * 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
  52852. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52853. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52854. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52855. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52856. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52857. * * 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
  52858. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52860. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52861. * @param name defines the name of the new line system
  52862. * @param options defines the options used to create the line system
  52863. * @param scene defines the hosting scene
  52864. * @returns a new line system mesh
  52865. */
  52866. static CreateLineSystem(name: string, options: {
  52867. lines: Vector3[][];
  52868. updatable?: boolean;
  52869. instance?: Nullable<LinesMesh>;
  52870. colors?: Nullable<Color4[][]>;
  52871. useVertexAlpha?: boolean;
  52872. }, scene: Nullable<Scene>): LinesMesh;
  52873. /**
  52874. * Creates a line mesh
  52875. * 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
  52876. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52877. * * The parameter `points` is an array successive Vector3
  52878. * * 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
  52879. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52880. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52881. * * When updating an instance, remember that only point positions can change, not the number of points
  52882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52883. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52884. * @param name defines the name of the new line system
  52885. * @param options defines the options used to create the line system
  52886. * @param scene defines the hosting scene
  52887. * @returns a new line mesh
  52888. */
  52889. static CreateLines(name: string, options: {
  52890. points: Vector3[];
  52891. updatable?: boolean;
  52892. instance?: Nullable<LinesMesh>;
  52893. colors?: Color4[];
  52894. useVertexAlpha?: boolean;
  52895. }, scene?: Nullable<Scene>): LinesMesh;
  52896. /**
  52897. * Creates a dashed line mesh
  52898. * * 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
  52899. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52900. * * The parameter `points` is an array successive Vector3
  52901. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52902. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52903. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52904. * * 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
  52905. * * When updating an instance, remember that only point positions can change, not the number of points
  52906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52907. * @param name defines the name of the mesh
  52908. * @param options defines the options used to create the mesh
  52909. * @param scene defines the hosting scene
  52910. * @returns the dashed line mesh
  52911. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52912. */
  52913. static CreateDashedLines(name: string, options: {
  52914. points: Vector3[];
  52915. dashSize?: number;
  52916. gapSize?: number;
  52917. dashNb?: number;
  52918. updatable?: boolean;
  52919. instance?: LinesMesh;
  52920. }, scene?: Nullable<Scene>): LinesMesh;
  52921. /**
  52922. * 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.
  52923. * * 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.
  52924. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52925. * * 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.
  52926. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52927. * * 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
  52928. * * 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
  52929. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52931. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52932. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52934. * @param name defines the name of the mesh
  52935. * @param options defines the options used to create the mesh
  52936. * @param scene defines the hosting scene
  52937. * @returns the extruded shape mesh
  52938. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52939. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52940. */
  52941. static ExtrudeShape(name: string, options: {
  52942. shape: Vector3[];
  52943. path: Vector3[];
  52944. scale?: number;
  52945. rotation?: number;
  52946. cap?: number;
  52947. updatable?: boolean;
  52948. sideOrientation?: number;
  52949. frontUVs?: Vector4;
  52950. backUVs?: Vector4;
  52951. instance?: Mesh;
  52952. invertUV?: boolean;
  52953. }, scene?: Nullable<Scene>): Mesh;
  52954. /**
  52955. * Creates an custom extruded shape mesh.
  52956. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52957. * * 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.
  52958. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52959. * * 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
  52960. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52961. * * 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
  52962. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52963. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52964. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52965. * * 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
  52966. * * 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
  52967. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52970. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52972. * @param name defines the name of the mesh
  52973. * @param options defines the options used to create the mesh
  52974. * @param scene defines the hosting scene
  52975. * @returns the custom extruded shape mesh
  52976. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52977. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52978. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52979. */
  52980. static ExtrudeShapeCustom(name: string, options: {
  52981. shape: Vector3[];
  52982. path: Vector3[];
  52983. scaleFunction?: any;
  52984. rotationFunction?: any;
  52985. ribbonCloseArray?: boolean;
  52986. ribbonClosePath?: boolean;
  52987. cap?: number;
  52988. updatable?: boolean;
  52989. sideOrientation?: number;
  52990. frontUVs?: Vector4;
  52991. backUVs?: Vector4;
  52992. instance?: Mesh;
  52993. invertUV?: boolean;
  52994. }, scene?: Nullable<Scene>): Mesh;
  52995. /**
  52996. * Creates lathe mesh.
  52997. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52998. * * 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
  52999. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53000. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53001. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53002. * * 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
  53003. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53004. * * 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
  53005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53006. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53007. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53009. * @param name defines the name of the mesh
  53010. * @param options defines the options used to create the mesh
  53011. * @param scene defines the hosting scene
  53012. * @returns the lathe mesh
  53013. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53014. */
  53015. static CreateLathe(name: string, options: {
  53016. shape: Vector3[];
  53017. radius?: number;
  53018. tessellation?: number;
  53019. clip?: number;
  53020. arc?: number;
  53021. closed?: boolean;
  53022. updatable?: boolean;
  53023. sideOrientation?: number;
  53024. frontUVs?: Vector4;
  53025. backUVs?: Vector4;
  53026. cap?: number;
  53027. invertUV?: boolean;
  53028. }, scene?: Nullable<Scene>): Mesh;
  53029. /**
  53030. * Creates a plane mesh
  53031. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53032. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53033. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53037. * @param name defines the name of the mesh
  53038. * @param options defines the options used to create the mesh
  53039. * @param scene defines the hosting scene
  53040. * @returns the plane mesh
  53041. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53042. */
  53043. static CreatePlane(name: string, options: {
  53044. size?: number;
  53045. width?: number;
  53046. height?: number;
  53047. sideOrientation?: number;
  53048. frontUVs?: Vector4;
  53049. backUVs?: Vector4;
  53050. updatable?: boolean;
  53051. sourcePlane?: Plane;
  53052. }, scene?: Nullable<Scene>): Mesh;
  53053. /**
  53054. * Creates a ground mesh
  53055. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53056. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53058. * @param name defines the name of the mesh
  53059. * @param options defines the options used to create the mesh
  53060. * @param scene defines the hosting scene
  53061. * @returns the ground mesh
  53062. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53063. */
  53064. static CreateGround(name: string, options: {
  53065. width?: number;
  53066. height?: number;
  53067. subdivisions?: number;
  53068. subdivisionsX?: number;
  53069. subdivisionsY?: number;
  53070. updatable?: boolean;
  53071. }, scene?: Nullable<Scene>): Mesh;
  53072. /**
  53073. * Creates a tiled ground mesh
  53074. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53075. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53076. * * 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
  53077. * * 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
  53078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53079. * @param name defines the name of the mesh
  53080. * @param options defines the options used to create the mesh
  53081. * @param scene defines the hosting scene
  53082. * @returns the tiled ground mesh
  53083. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53084. */
  53085. static CreateTiledGround(name: string, options: {
  53086. xmin: number;
  53087. zmin: number;
  53088. xmax: number;
  53089. zmax: number;
  53090. subdivisions?: {
  53091. w: number;
  53092. h: number;
  53093. };
  53094. precision?: {
  53095. w: number;
  53096. h: number;
  53097. };
  53098. updatable?: boolean;
  53099. }, scene?: Nullable<Scene>): Mesh;
  53100. /**
  53101. * Creates a ground mesh from a height map
  53102. * * The parameter `url` sets the URL of the height map image resource.
  53103. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53104. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53105. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53106. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53107. * * 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.
  53108. * * 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).
  53109. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53111. * @param name defines the name of the mesh
  53112. * @param url defines the url to the height map
  53113. * @param options defines the options used to create the mesh
  53114. * @param scene defines the hosting scene
  53115. * @returns the ground mesh
  53116. * @see https://doc.babylonjs.com/babylon101/height_map
  53117. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53118. */
  53119. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53120. width?: number;
  53121. height?: number;
  53122. subdivisions?: number;
  53123. minHeight?: number;
  53124. maxHeight?: number;
  53125. colorFilter?: Color3;
  53126. alphaFilter?: number;
  53127. updatable?: boolean;
  53128. onReady?: (mesh: GroundMesh) => void;
  53129. }, scene?: Nullable<Scene>): GroundMesh;
  53130. /**
  53131. * Creates a polygon mesh
  53132. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53133. * * 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
  53134. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53136. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  53137. * * Remember you can only change the shape positions, not their number when updating a polygon
  53138. * @param name defines the name of the mesh
  53139. * @param options defines the options used to create the mesh
  53140. * @param scene defines the hosting scene
  53141. * @param earcutInjection can be used to inject your own earcut reference
  53142. * @returns the polygon mesh
  53143. */
  53144. static CreatePolygon(name: string, options: {
  53145. shape: Vector3[];
  53146. holes?: Vector3[][];
  53147. depth?: number;
  53148. faceUV?: Vector4[];
  53149. faceColors?: Color4[];
  53150. updatable?: boolean;
  53151. sideOrientation?: number;
  53152. frontUVs?: Vector4;
  53153. backUVs?: Vector4;
  53154. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53155. /**
  53156. * Creates an extruded polygon mesh, with depth in the Y direction.
  53157. * * 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)
  53158. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53159. * @param name defines the name of the mesh
  53160. * @param options defines the options used to create the mesh
  53161. * @param scene defines the hosting scene
  53162. * @param earcutInjection can be used to inject your own earcut reference
  53163. * @returns the polygon mesh
  53164. */
  53165. static ExtrudePolygon(name: string, options: {
  53166. shape: Vector3[];
  53167. holes?: Vector3[][];
  53168. depth?: number;
  53169. faceUV?: Vector4[];
  53170. faceColors?: Color4[];
  53171. updatable?: boolean;
  53172. sideOrientation?: number;
  53173. frontUVs?: Vector4;
  53174. backUVs?: Vector4;
  53175. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53176. /**
  53177. * Creates a tube mesh.
  53178. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53179. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53180. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53181. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53182. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53183. * * 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)
  53184. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53185. * * 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
  53186. * * 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
  53187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53189. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53191. * @param name defines the name of the mesh
  53192. * @param options defines the options used to create the mesh
  53193. * @param scene defines the hosting scene
  53194. * @returns the tube mesh
  53195. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53196. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53197. */
  53198. static CreateTube(name: string, options: {
  53199. path: Vector3[];
  53200. radius?: number;
  53201. tessellation?: number;
  53202. radiusFunction?: {
  53203. (i: number, distance: number): number;
  53204. };
  53205. cap?: number;
  53206. arc?: number;
  53207. updatable?: boolean;
  53208. sideOrientation?: number;
  53209. frontUVs?: Vector4;
  53210. backUVs?: Vector4;
  53211. instance?: Mesh;
  53212. invertUV?: boolean;
  53213. }, scene?: Nullable<Scene>): Mesh;
  53214. /**
  53215. * Creates a polyhedron mesh
  53216. * * 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
  53217. * * The parameter `size` (positive float, default 1) sets the polygon size
  53218. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53219. * * 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`
  53220. * * 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
  53221. * * 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)`)
  53222. * * 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
  53223. * * 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
  53224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53227. * @param name defines the name of the mesh
  53228. * @param options defines the options used to create the mesh
  53229. * @param scene defines the hosting scene
  53230. * @returns the polyhedron mesh
  53231. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53232. */
  53233. static CreatePolyhedron(name: string, options: {
  53234. type?: number;
  53235. size?: number;
  53236. sizeX?: number;
  53237. sizeY?: number;
  53238. sizeZ?: number;
  53239. custom?: any;
  53240. faceUV?: Vector4[];
  53241. faceColors?: Color4[];
  53242. flat?: boolean;
  53243. updatable?: boolean;
  53244. sideOrientation?: number;
  53245. frontUVs?: Vector4;
  53246. backUVs?: Vector4;
  53247. }, scene?: Nullable<Scene>): Mesh;
  53248. /**
  53249. * Creates a decal mesh.
  53250. * 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
  53251. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53252. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53253. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53254. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53255. * @param name defines the name of the mesh
  53256. * @param sourceMesh defines the mesh where the decal must be applied
  53257. * @param options defines the options used to create the mesh
  53258. * @param scene defines the hosting scene
  53259. * @returns the decal mesh
  53260. * @see https://doc.babylonjs.com/how_to/decals
  53261. */
  53262. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53263. position?: Vector3;
  53264. normal?: Vector3;
  53265. size?: Vector3;
  53266. angle?: number;
  53267. }): Mesh;
  53268. }
  53269. }
  53270. declare module "babylonjs/Meshes/meshSimplification" {
  53271. import { Mesh } from "babylonjs/Meshes/mesh";
  53272. /**
  53273. * A simplifier interface for future simplification implementations
  53274. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53275. */
  53276. export interface ISimplifier {
  53277. /**
  53278. * Simplification of a given mesh according to the given settings.
  53279. * Since this requires computation, it is assumed that the function runs async.
  53280. * @param settings The settings of the simplification, including quality and distance
  53281. * @param successCallback A callback that will be called after the mesh was simplified.
  53282. * @param errorCallback in case of an error, this callback will be called. optional.
  53283. */
  53284. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53285. }
  53286. /**
  53287. * Expected simplification settings.
  53288. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53289. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53290. */
  53291. export interface ISimplificationSettings {
  53292. /**
  53293. * Gets or sets the expected quality
  53294. */
  53295. quality: number;
  53296. /**
  53297. * Gets or sets the distance when this optimized version should be used
  53298. */
  53299. distance: number;
  53300. /**
  53301. * Gets an already optimized mesh
  53302. */
  53303. optimizeMesh?: boolean;
  53304. }
  53305. /**
  53306. * Class used to specify simplification options
  53307. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53308. */
  53309. export class SimplificationSettings implements ISimplificationSettings {
  53310. /** expected quality */
  53311. quality: number;
  53312. /** distance when this optimized version should be used */
  53313. distance: number;
  53314. /** already optimized mesh */
  53315. optimizeMesh?: boolean | undefined;
  53316. /**
  53317. * Creates a SimplificationSettings
  53318. * @param quality expected quality
  53319. * @param distance distance when this optimized version should be used
  53320. * @param optimizeMesh already optimized mesh
  53321. */
  53322. constructor(
  53323. /** expected quality */
  53324. quality: number,
  53325. /** distance when this optimized version should be used */
  53326. distance: number,
  53327. /** already optimized mesh */
  53328. optimizeMesh?: boolean | undefined);
  53329. }
  53330. /**
  53331. * Interface used to define a simplification task
  53332. */
  53333. export interface ISimplificationTask {
  53334. /**
  53335. * Array of settings
  53336. */
  53337. settings: Array<ISimplificationSettings>;
  53338. /**
  53339. * Simplification type
  53340. */
  53341. simplificationType: SimplificationType;
  53342. /**
  53343. * Mesh to simplify
  53344. */
  53345. mesh: Mesh;
  53346. /**
  53347. * Callback called on success
  53348. */
  53349. successCallback?: () => void;
  53350. /**
  53351. * Defines if parallel processing can be used
  53352. */
  53353. parallelProcessing: boolean;
  53354. }
  53355. /**
  53356. * Queue used to order the simplification tasks
  53357. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53358. */
  53359. export class SimplificationQueue {
  53360. private _simplificationArray;
  53361. /**
  53362. * Gets a boolean indicating that the process is still running
  53363. */
  53364. running: boolean;
  53365. /**
  53366. * Creates a new queue
  53367. */
  53368. constructor();
  53369. /**
  53370. * Adds a new simplification task
  53371. * @param task defines a task to add
  53372. */
  53373. addTask(task: ISimplificationTask): void;
  53374. /**
  53375. * Execute next task
  53376. */
  53377. executeNext(): void;
  53378. /**
  53379. * Execute a simplification task
  53380. * @param task defines the task to run
  53381. */
  53382. runSimplification(task: ISimplificationTask): void;
  53383. private getSimplifier;
  53384. }
  53385. /**
  53386. * The implemented types of simplification
  53387. * At the moment only Quadratic Error Decimation is implemented
  53388. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53389. */
  53390. export enum SimplificationType {
  53391. /** Quadratic error decimation */
  53392. QUADRATIC = 0
  53393. }
  53394. }
  53395. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  53396. import { Scene } from "babylonjs/scene";
  53397. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  53398. import { ISceneComponent } from "babylonjs/sceneComponent";
  53399. module "babylonjs/scene" {
  53400. interface Scene {
  53401. /** @hidden (Backing field) */
  53402. _simplificationQueue: SimplificationQueue;
  53403. /**
  53404. * Gets or sets the simplification queue attached to the scene
  53405. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53406. */
  53407. simplificationQueue: SimplificationQueue;
  53408. }
  53409. }
  53410. module "babylonjs/Meshes/mesh" {
  53411. interface Mesh {
  53412. /**
  53413. * Simplify the mesh according to the given array of settings.
  53414. * Function will return immediately and will simplify async
  53415. * @param settings a collection of simplification settings
  53416. * @param parallelProcessing should all levels calculate parallel or one after the other
  53417. * @param simplificationType the type of simplification to run
  53418. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53419. * @returns the current mesh
  53420. */
  53421. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53422. }
  53423. }
  53424. /**
  53425. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53426. * created in a scene
  53427. */
  53428. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53429. /**
  53430. * The component name helpfull to identify the component in the list of scene components.
  53431. */
  53432. readonly name: string;
  53433. /**
  53434. * The scene the component belongs to.
  53435. */
  53436. scene: Scene;
  53437. /**
  53438. * Creates a new instance of the component for the given scene
  53439. * @param scene Defines the scene to register the component in
  53440. */
  53441. constructor(scene: Scene);
  53442. /**
  53443. * Registers the component in a given scene
  53444. */
  53445. register(): void;
  53446. /**
  53447. * Rebuilds the elements related to this component in case of
  53448. * context lost for instance.
  53449. */
  53450. rebuild(): void;
  53451. /**
  53452. * Disposes the component and the associated ressources
  53453. */
  53454. dispose(): void;
  53455. private _beforeCameraUpdate;
  53456. }
  53457. }
  53458. declare module "babylonjs/Meshes/Builders/index" {
  53459. export * from "babylonjs/Meshes/Builders/boxBuilder";
  53460. export * from "babylonjs/Meshes/Builders/discBuilder";
  53461. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  53462. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  53463. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  53464. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  53465. export * from "babylonjs/Meshes/Builders/torusBuilder";
  53466. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  53467. export * from "babylonjs/Meshes/Builders/linesBuilder";
  53468. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  53469. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  53470. export * from "babylonjs/Meshes/Builders/latheBuilder";
  53471. export * from "babylonjs/Meshes/Builders/planeBuilder";
  53472. export * from "babylonjs/Meshes/Builders/groundBuilder";
  53473. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  53474. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  53475. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  53476. export * from "babylonjs/Meshes/Builders/decalBuilder";
  53477. }
  53478. declare module "babylonjs/Meshes/index" {
  53479. export * from "babylonjs/Meshes/abstractMesh";
  53480. export * from "babylonjs/Meshes/buffer";
  53481. export * from "babylonjs/Meshes/Compression/index";
  53482. export * from "babylonjs/Meshes/csg";
  53483. export * from "babylonjs/Meshes/geometry";
  53484. export * from "babylonjs/Meshes/groundMesh";
  53485. export * from "babylonjs/Meshes/trailMesh";
  53486. export * from "babylonjs/Meshes/instancedMesh";
  53487. export * from "babylonjs/Meshes/linesMesh";
  53488. export * from "babylonjs/Meshes/mesh";
  53489. export * from "babylonjs/Meshes/mesh.vertexData";
  53490. export * from "babylonjs/Meshes/meshBuilder";
  53491. export * from "babylonjs/Meshes/meshSimplification";
  53492. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  53493. export * from "babylonjs/Meshes/polygonMesh";
  53494. export * from "babylonjs/Meshes/subMesh";
  53495. export * from "babylonjs/Meshes/meshLODLevel";
  53496. export * from "babylonjs/Meshes/transformNode";
  53497. export * from "babylonjs/Meshes/Builders/index";
  53498. export * from "babylonjs/Meshes/dataBuffer";
  53499. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  53500. }
  53501. declare module "babylonjs/Morph/index" {
  53502. export * from "babylonjs/Morph/morphTarget";
  53503. export * from "babylonjs/Morph/morphTargetManager";
  53504. }
  53505. declare module "babylonjs/Offline/database" {
  53506. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  53507. /**
  53508. * Class used to enable access to IndexedDB
  53509. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53510. */
  53511. export class Database implements IOfflineProvider {
  53512. private _callbackManifestChecked;
  53513. private _currentSceneUrl;
  53514. private _db;
  53515. private _enableSceneOffline;
  53516. private _enableTexturesOffline;
  53517. private _manifestVersionFound;
  53518. private _mustUpdateRessources;
  53519. private _hasReachedQuota;
  53520. private _isSupported;
  53521. private _idbFactory;
  53522. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53523. private static IsUASupportingBlobStorage;
  53524. /**
  53525. * Gets a boolean indicating if Database storate is enabled (off by default)
  53526. */
  53527. static IDBStorageEnabled: boolean;
  53528. /**
  53529. * Gets a boolean indicating if scene must be saved in the database
  53530. */
  53531. readonly enableSceneOffline: boolean;
  53532. /**
  53533. * Gets a boolean indicating if textures must be saved in the database
  53534. */
  53535. readonly enableTexturesOffline: boolean;
  53536. /**
  53537. * Creates a new Database
  53538. * @param urlToScene defines the url to load the scene
  53539. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53540. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53541. */
  53542. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53543. private static _ParseURL;
  53544. private static _ReturnFullUrlLocation;
  53545. private _checkManifestFile;
  53546. /**
  53547. * Open the database and make it available
  53548. * @param successCallback defines the callback to call on success
  53549. * @param errorCallback defines the callback to call on error
  53550. */
  53551. open(successCallback: () => void, errorCallback: () => void): void;
  53552. /**
  53553. * Loads an image from the database
  53554. * @param url defines the url to load from
  53555. * @param image defines the target DOM image
  53556. */
  53557. loadImage(url: string, image: HTMLImageElement): void;
  53558. private _loadImageFromDBAsync;
  53559. private _saveImageIntoDBAsync;
  53560. private _checkVersionFromDB;
  53561. private _loadVersionFromDBAsync;
  53562. private _saveVersionIntoDBAsync;
  53563. /**
  53564. * Loads a file from database
  53565. * @param url defines the URL to load from
  53566. * @param sceneLoaded defines a callback to call on success
  53567. * @param progressCallBack defines a callback to call when progress changed
  53568. * @param errorCallback defines a callback to call on error
  53569. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53570. */
  53571. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53572. private _loadFileAsync;
  53573. private _saveFileAsync;
  53574. /**
  53575. * Validates if xhr data is correct
  53576. * @param xhr defines the request to validate
  53577. * @param dataType defines the expected data type
  53578. * @returns true if data is correct
  53579. */
  53580. private static _ValidateXHRData;
  53581. }
  53582. }
  53583. declare module "babylonjs/Offline/index" {
  53584. export * from "babylonjs/Offline/database";
  53585. export * from "babylonjs/Offline/IOfflineProvider";
  53586. }
  53587. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53588. /** @hidden */
  53589. export var gpuUpdateParticlesPixelShader: {
  53590. name: string;
  53591. shader: string;
  53592. };
  53593. }
  53594. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53595. /** @hidden */
  53596. export var gpuUpdateParticlesVertexShader: {
  53597. name: string;
  53598. shader: string;
  53599. };
  53600. }
  53601. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53602. /** @hidden */
  53603. export var clipPlaneFragmentDeclaration2: {
  53604. name: string;
  53605. shader: string;
  53606. };
  53607. }
  53608. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53609. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53610. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53611. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53612. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53613. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53614. /** @hidden */
  53615. export var gpuRenderParticlesPixelShader: {
  53616. name: string;
  53617. shader: string;
  53618. };
  53619. }
  53620. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53621. /** @hidden */
  53622. export var clipPlaneVertexDeclaration2: {
  53623. name: string;
  53624. shader: string;
  53625. };
  53626. }
  53627. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53628. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53629. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53630. /** @hidden */
  53631. export var gpuRenderParticlesVertexShader: {
  53632. name: string;
  53633. shader: string;
  53634. };
  53635. }
  53636. declare module "babylonjs/Particles/gpuParticleSystem" {
  53637. import { Nullable } from "babylonjs/types";
  53638. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53639. import { Observable } from "babylonjs/Misc/observable";
  53640. import { Color4, Color3 } from "babylonjs/Maths/math";
  53641. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53642. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53643. import { Scene, IDisposable } from "babylonjs/scene";
  53644. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53645. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53646. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53647. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53648. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53649. /**
  53650. * This represents a GPU particle system in Babylon
  53651. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53652. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53653. */
  53654. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53655. /**
  53656. * The layer mask we are rendering the particles through.
  53657. */
  53658. layerMask: number;
  53659. private _capacity;
  53660. private _activeCount;
  53661. private _currentActiveCount;
  53662. private _accumulatedCount;
  53663. private _renderEffect;
  53664. private _updateEffect;
  53665. private _buffer0;
  53666. private _buffer1;
  53667. private _spriteBuffer;
  53668. private _updateVAO;
  53669. private _renderVAO;
  53670. private _targetIndex;
  53671. private _sourceBuffer;
  53672. private _targetBuffer;
  53673. private _engine;
  53674. private _currentRenderId;
  53675. private _started;
  53676. private _stopped;
  53677. private _timeDelta;
  53678. private _randomTexture;
  53679. private _randomTexture2;
  53680. private _attributesStrideSize;
  53681. private _updateEffectOptions;
  53682. private _randomTextureSize;
  53683. private _actualFrame;
  53684. private readonly _rawTextureWidth;
  53685. /**
  53686. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53687. */
  53688. static readonly IsSupported: boolean;
  53689. /**
  53690. * An event triggered when the system is disposed.
  53691. */
  53692. onDisposeObservable: Observable<GPUParticleSystem>;
  53693. /**
  53694. * Gets the maximum number of particles active at the same time.
  53695. * @returns The max number of active particles.
  53696. */
  53697. getCapacity(): number;
  53698. /**
  53699. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53700. * to override the particles.
  53701. */
  53702. forceDepthWrite: boolean;
  53703. /**
  53704. * Gets or set the number of active particles
  53705. */
  53706. activeParticleCount: number;
  53707. private _preWarmDone;
  53708. /**
  53709. * Is this system ready to be used/rendered
  53710. * @return true if the system is ready
  53711. */
  53712. isReady(): boolean;
  53713. /**
  53714. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53715. * @returns True if it has been started, otherwise false.
  53716. */
  53717. isStarted(): boolean;
  53718. /**
  53719. * Starts the particle system and begins to emit
  53720. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53721. */
  53722. start(delay?: number): void;
  53723. /**
  53724. * Stops the particle system.
  53725. */
  53726. stop(): void;
  53727. /**
  53728. * Remove all active particles
  53729. */
  53730. reset(): void;
  53731. /**
  53732. * Returns the string "GPUParticleSystem"
  53733. * @returns a string containing the class name
  53734. */
  53735. getClassName(): string;
  53736. private _colorGradientsTexture;
  53737. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53738. /**
  53739. * Adds a new color gradient
  53740. * @param gradient defines the gradient to use (between 0 and 1)
  53741. * @param color1 defines the color to affect to the specified gradient
  53742. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53743. * @returns the current particle system
  53744. */
  53745. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53746. /**
  53747. * Remove a specific color gradient
  53748. * @param gradient defines the gradient to remove
  53749. * @returns the current particle system
  53750. */
  53751. removeColorGradient(gradient: number): GPUParticleSystem;
  53752. private _angularSpeedGradientsTexture;
  53753. private _sizeGradientsTexture;
  53754. private _velocityGradientsTexture;
  53755. private _limitVelocityGradientsTexture;
  53756. private _dragGradientsTexture;
  53757. private _addFactorGradient;
  53758. /**
  53759. * Adds a new size gradient
  53760. * @param gradient defines the gradient to use (between 0 and 1)
  53761. * @param factor defines the size factor to affect to the specified gradient
  53762. * @returns the current particle system
  53763. */
  53764. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53765. /**
  53766. * Remove a specific size gradient
  53767. * @param gradient defines the gradient to remove
  53768. * @returns the current particle system
  53769. */
  53770. removeSizeGradient(gradient: number): GPUParticleSystem;
  53771. /**
  53772. * Adds a new angular speed gradient
  53773. * @param gradient defines the gradient to use (between 0 and 1)
  53774. * @param factor defines the angular speed to affect to the specified gradient
  53775. * @returns the current particle system
  53776. */
  53777. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53778. /**
  53779. * Remove a specific angular speed gradient
  53780. * @param gradient defines the gradient to remove
  53781. * @returns the current particle system
  53782. */
  53783. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53784. /**
  53785. * Adds a new velocity gradient
  53786. * @param gradient defines the gradient to use (between 0 and 1)
  53787. * @param factor defines the velocity to affect to the specified gradient
  53788. * @returns the current particle system
  53789. */
  53790. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53791. /**
  53792. * Remove a specific velocity gradient
  53793. * @param gradient defines the gradient to remove
  53794. * @returns the current particle system
  53795. */
  53796. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53797. /**
  53798. * Adds a new limit velocity gradient
  53799. * @param gradient defines the gradient to use (between 0 and 1)
  53800. * @param factor defines the limit velocity value to affect to the specified gradient
  53801. * @returns the current particle system
  53802. */
  53803. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53804. /**
  53805. * Remove a specific limit velocity gradient
  53806. * @param gradient defines the gradient to remove
  53807. * @returns the current particle system
  53808. */
  53809. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53810. /**
  53811. * Adds a new drag gradient
  53812. * @param gradient defines the gradient to use (between 0 and 1)
  53813. * @param factor defines the drag value to affect to the specified gradient
  53814. * @returns the current particle system
  53815. */
  53816. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53817. /**
  53818. * Remove a specific drag gradient
  53819. * @param gradient defines the gradient to remove
  53820. * @returns the current particle system
  53821. */
  53822. removeDragGradient(gradient: number): GPUParticleSystem;
  53823. /**
  53824. * Not supported by GPUParticleSystem
  53825. * @param gradient defines the gradient to use (between 0 and 1)
  53826. * @param factor defines the emit rate value to affect to the specified gradient
  53827. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53828. * @returns the current particle system
  53829. */
  53830. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53831. /**
  53832. * Not supported by GPUParticleSystem
  53833. * @param gradient defines the gradient to remove
  53834. * @returns the current particle system
  53835. */
  53836. removeEmitRateGradient(gradient: number): IParticleSystem;
  53837. /**
  53838. * Not supported by GPUParticleSystem
  53839. * @param gradient defines the gradient to use (between 0 and 1)
  53840. * @param factor defines the start size value to affect to the specified gradient
  53841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53842. * @returns the current particle system
  53843. */
  53844. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53845. /**
  53846. * Not supported by GPUParticleSystem
  53847. * @param gradient defines the gradient to remove
  53848. * @returns the current particle system
  53849. */
  53850. removeStartSizeGradient(gradient: number): IParticleSystem;
  53851. /**
  53852. * Not supported by GPUParticleSystem
  53853. * @param gradient defines the gradient to use (between 0 and 1)
  53854. * @param min defines the color remap minimal range
  53855. * @param max defines the color remap maximal range
  53856. * @returns the current particle system
  53857. */
  53858. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53859. /**
  53860. * Not supported by GPUParticleSystem
  53861. * @param gradient defines the gradient to remove
  53862. * @returns the current particle system
  53863. */
  53864. removeColorRemapGradient(): IParticleSystem;
  53865. /**
  53866. * Not supported by GPUParticleSystem
  53867. * @param gradient defines the gradient to use (between 0 and 1)
  53868. * @param min defines the alpha remap minimal range
  53869. * @param max defines the alpha remap maximal range
  53870. * @returns the current particle system
  53871. */
  53872. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53873. /**
  53874. * Not supported by GPUParticleSystem
  53875. * @param gradient defines the gradient to remove
  53876. * @returns the current particle system
  53877. */
  53878. removeAlphaRemapGradient(): IParticleSystem;
  53879. /**
  53880. * Not supported by GPUParticleSystem
  53881. * @param gradient defines the gradient to use (between 0 and 1)
  53882. * @param color defines the color to affect to the specified gradient
  53883. * @returns the current particle system
  53884. */
  53885. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53886. /**
  53887. * Not supported by GPUParticleSystem
  53888. * @param gradient defines the gradient to remove
  53889. * @returns the current particle system
  53890. */
  53891. removeRampGradient(): IParticleSystem;
  53892. /**
  53893. * Not supported by GPUParticleSystem
  53894. * @returns the list of ramp gradients
  53895. */
  53896. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53897. /**
  53898. * Not supported by GPUParticleSystem
  53899. * Gets or sets a boolean indicating that ramp gradients must be used
  53900. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53901. */
  53902. useRampGradients: boolean;
  53903. /**
  53904. * Not supported by GPUParticleSystem
  53905. * @param gradient defines the gradient to use (between 0 and 1)
  53906. * @param factor defines the life time factor to affect to the specified gradient
  53907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53908. * @returns the current particle system
  53909. */
  53910. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53911. /**
  53912. * Not supported by GPUParticleSystem
  53913. * @param gradient defines the gradient to remove
  53914. * @returns the current particle system
  53915. */
  53916. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53917. /**
  53918. * Instantiates a GPU particle system.
  53919. * 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.
  53920. * @param name The name of the particle system
  53921. * @param options The options used to create the system
  53922. * @param scene The scene the particle system belongs to
  53923. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53924. */
  53925. constructor(name: string, options: Partial<{
  53926. capacity: number;
  53927. randomTextureSize: number;
  53928. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53929. protected _reset(): void;
  53930. private _createUpdateVAO;
  53931. private _createRenderVAO;
  53932. private _initialize;
  53933. /** @hidden */
  53934. _recreateUpdateEffect(): void;
  53935. /** @hidden */
  53936. _recreateRenderEffect(): void;
  53937. /**
  53938. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53939. * @param preWarm defines if we are in the pre-warmimg phase
  53940. */
  53941. animate(preWarm?: boolean): void;
  53942. private _createFactorGradientTexture;
  53943. private _createSizeGradientTexture;
  53944. private _createAngularSpeedGradientTexture;
  53945. private _createVelocityGradientTexture;
  53946. private _createLimitVelocityGradientTexture;
  53947. private _createDragGradientTexture;
  53948. private _createColorGradientTexture;
  53949. /**
  53950. * Renders the particle system in its current state
  53951. * @param preWarm defines if the system should only update the particles but not render them
  53952. * @returns the current number of particles
  53953. */
  53954. render(preWarm?: boolean): number;
  53955. /**
  53956. * Rebuilds the particle system
  53957. */
  53958. rebuild(): void;
  53959. private _releaseBuffers;
  53960. private _releaseVAOs;
  53961. /**
  53962. * Disposes the particle system and free the associated resources
  53963. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53964. */
  53965. dispose(disposeTexture?: boolean): void;
  53966. /**
  53967. * Clones the particle system.
  53968. * @param name The name of the cloned object
  53969. * @param newEmitter The new emitter to use
  53970. * @returns the cloned particle system
  53971. */
  53972. clone(name: string, newEmitter: any): GPUParticleSystem;
  53973. /**
  53974. * Serializes the particle system to a JSON object.
  53975. * @returns the JSON object
  53976. */
  53977. serialize(): any;
  53978. /**
  53979. * Parses a JSON object to create a GPU particle system.
  53980. * @param parsedParticleSystem The JSON object to parse
  53981. * @param scene The scene to create the particle system in
  53982. * @param rootUrl The root url to use to load external dependencies like texture
  53983. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53984. * @returns the parsed GPU particle system
  53985. */
  53986. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53987. }
  53988. }
  53989. declare module "babylonjs/Particles/particleSystemSet" {
  53990. import { Nullable } from "babylonjs/types";
  53991. import { Color3 } from "babylonjs/Maths/math";
  53992. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53994. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53995. import { Scene, IDisposable } from "babylonjs/scene";
  53996. /**
  53997. * Represents a set of particle systems working together to create a specific effect
  53998. */
  53999. export class ParticleSystemSet implements IDisposable {
  54000. private _emitterCreationOptions;
  54001. private _emitterNode;
  54002. /**
  54003. * Gets the particle system list
  54004. */
  54005. systems: IParticleSystem[];
  54006. /**
  54007. * Gets the emitter node used with this set
  54008. */
  54009. readonly emitterNode: Nullable<TransformNode>;
  54010. /**
  54011. * Creates a new emitter mesh as a sphere
  54012. * @param options defines the options used to create the sphere
  54013. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54014. * @param scene defines the hosting scene
  54015. */
  54016. setEmitterAsSphere(options: {
  54017. diameter: number;
  54018. segments: number;
  54019. color: Color3;
  54020. }, renderingGroupId: number, scene: Scene): void;
  54021. /**
  54022. * Starts all particle systems of the set
  54023. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54024. */
  54025. start(emitter?: AbstractMesh): void;
  54026. /**
  54027. * Release all associated resources
  54028. */
  54029. dispose(): void;
  54030. /**
  54031. * Serialize the set into a JSON compatible object
  54032. * @returns a JSON compatible representation of the set
  54033. */
  54034. serialize(): any;
  54035. /**
  54036. * Parse a new ParticleSystemSet from a serialized source
  54037. * @param data defines a JSON compatible representation of the set
  54038. * @param scene defines the hosting scene
  54039. * @param gpu defines if we want GPU particles or CPU particles
  54040. * @returns a new ParticleSystemSet
  54041. */
  54042. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54043. }
  54044. }
  54045. declare module "babylonjs/Particles/particleHelper" {
  54046. import { Nullable } from "babylonjs/types";
  54047. import { Scene } from "babylonjs/scene";
  54048. import { Vector3 } from "babylonjs/Maths/math";
  54049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54050. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54051. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  54052. /**
  54053. * This class is made for on one-liner static method to help creating particle system set.
  54054. */
  54055. export class ParticleHelper {
  54056. /**
  54057. * Gets or sets base Assets URL
  54058. */
  54059. static BaseAssetsUrl: string;
  54060. /**
  54061. * Create a default particle system that you can tweak
  54062. * @param emitter defines the emitter to use
  54063. * @param capacity defines the system capacity (default is 500 particles)
  54064. * @param scene defines the hosting scene
  54065. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54066. * @returns the new Particle system
  54067. */
  54068. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54069. /**
  54070. * This is the main static method (one-liner) of this helper to create different particle systems
  54071. * @param type This string represents the type to the particle system to create
  54072. * @param scene The scene where the particle system should live
  54073. * @param gpu If the system will use gpu
  54074. * @returns the ParticleSystemSet created
  54075. */
  54076. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54077. /**
  54078. * Static function used to export a particle system to a ParticleSystemSet variable.
  54079. * Please note that the emitter shape is not exported
  54080. * @param systems defines the particle systems to export
  54081. * @returns the created particle system set
  54082. */
  54083. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54084. }
  54085. }
  54086. declare module "babylonjs/Particles/particleSystemComponent" {
  54087. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54088. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54089. import "babylonjs/Shaders/particles.vertex";
  54090. module "babylonjs/Engines/engine" {
  54091. interface Engine {
  54092. /**
  54093. * Create an effect to use with particle systems.
  54094. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54095. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54096. * @param uniformsNames defines a list of attribute names
  54097. * @param samplers defines an array of string used to represent textures
  54098. * @param defines defines the string containing the defines to use to compile the shaders
  54099. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54100. * @param onCompiled defines a function to call when the effect creation is successful
  54101. * @param onError defines a function to call when the effect creation has failed
  54102. * @returns the new Effect
  54103. */
  54104. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54105. }
  54106. }
  54107. module "babylonjs/Meshes/mesh" {
  54108. interface Mesh {
  54109. /**
  54110. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54111. * @returns an array of IParticleSystem
  54112. */
  54113. getEmittedParticleSystems(): IParticleSystem[];
  54114. /**
  54115. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54116. * @returns an array of IParticleSystem
  54117. */
  54118. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54119. }
  54120. }
  54121. /**
  54122. * @hidden
  54123. */
  54124. export var _IDoNeedToBeInTheBuild: number;
  54125. }
  54126. declare module "babylonjs/Particles/index" {
  54127. export * from "babylonjs/Particles/baseParticleSystem";
  54128. export * from "babylonjs/Particles/EmitterTypes/index";
  54129. export * from "babylonjs/Particles/gpuParticleSystem";
  54130. export * from "babylonjs/Particles/IParticleSystem";
  54131. export * from "babylonjs/Particles/particle";
  54132. export * from "babylonjs/Particles/particleHelper";
  54133. export * from "babylonjs/Particles/particleSystem";
  54134. export * from "babylonjs/Particles/particleSystemComponent";
  54135. export * from "babylonjs/Particles/particleSystemSet";
  54136. export * from "babylonjs/Particles/solidParticle";
  54137. export * from "babylonjs/Particles/solidParticleSystem";
  54138. export * from "babylonjs/Particles/subEmitter";
  54139. }
  54140. declare module "babylonjs/Physics/physicsEngineComponent" {
  54141. import { Nullable } from "babylonjs/types";
  54142. import { Observable, Observer } from "babylonjs/Misc/observable";
  54143. import { Vector3 } from "babylonjs/Maths/math";
  54144. import { Mesh } from "babylonjs/Meshes/mesh";
  54145. import { ISceneComponent } from "babylonjs/sceneComponent";
  54146. import { Scene } from "babylonjs/scene";
  54147. import { Node } from "babylonjs/node";
  54148. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54149. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54150. module "babylonjs/scene" {
  54151. interface Scene {
  54152. /** @hidden (Backing field) */
  54153. _physicsEngine: Nullable<IPhysicsEngine>;
  54154. /**
  54155. * Gets the current physics engine
  54156. * @returns a IPhysicsEngine or null if none attached
  54157. */
  54158. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54159. /**
  54160. * Enables physics to the current scene
  54161. * @param gravity defines the scene's gravity for the physics engine
  54162. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54163. * @return a boolean indicating if the physics engine was initialized
  54164. */
  54165. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54166. /**
  54167. * Disables and disposes the physics engine associated with the scene
  54168. */
  54169. disablePhysicsEngine(): void;
  54170. /**
  54171. * Gets a boolean indicating if there is an active physics engine
  54172. * @returns a boolean indicating if there is an active physics engine
  54173. */
  54174. isPhysicsEnabled(): boolean;
  54175. /**
  54176. * Deletes a physics compound impostor
  54177. * @param compound defines the compound to delete
  54178. */
  54179. deleteCompoundImpostor(compound: any): void;
  54180. /**
  54181. * An event triggered when physic simulation is about to be run
  54182. */
  54183. onBeforePhysicsObservable: Observable<Scene>;
  54184. /**
  54185. * An event triggered when physic simulation has been done
  54186. */
  54187. onAfterPhysicsObservable: Observable<Scene>;
  54188. }
  54189. }
  54190. module "babylonjs/Meshes/abstractMesh" {
  54191. interface AbstractMesh {
  54192. /** @hidden */
  54193. _physicsImpostor: Nullable<PhysicsImpostor>;
  54194. /**
  54195. * Gets or sets impostor used for physic simulation
  54196. * @see http://doc.babylonjs.com/features/physics_engine
  54197. */
  54198. physicsImpostor: Nullable<PhysicsImpostor>;
  54199. /**
  54200. * Gets the current physics impostor
  54201. * @see http://doc.babylonjs.com/features/physics_engine
  54202. * @returns a physics impostor or null
  54203. */
  54204. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54205. /** Apply a physic impulse to the mesh
  54206. * @param force defines the force to apply
  54207. * @param contactPoint defines where to apply the force
  54208. * @returns the current mesh
  54209. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54210. */
  54211. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54212. /**
  54213. * Creates a physic joint between two meshes
  54214. * @param otherMesh defines the other mesh to use
  54215. * @param pivot1 defines the pivot to use on this mesh
  54216. * @param pivot2 defines the pivot to use on the other mesh
  54217. * @param options defines additional options (can be plugin dependent)
  54218. * @returns the current mesh
  54219. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54220. */
  54221. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54222. /** @hidden */
  54223. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54224. }
  54225. }
  54226. /**
  54227. * Defines the physics engine scene component responsible to manage a physics engine
  54228. */
  54229. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54230. /**
  54231. * The component name helpful to identify the component in the list of scene components.
  54232. */
  54233. readonly name: string;
  54234. /**
  54235. * The scene the component belongs to.
  54236. */
  54237. scene: Scene;
  54238. /**
  54239. * Creates a new instance of the component for the given scene
  54240. * @param scene Defines the scene to register the component in
  54241. */
  54242. constructor(scene: Scene);
  54243. /**
  54244. * Registers the component in a given scene
  54245. */
  54246. register(): void;
  54247. /**
  54248. * Rebuilds the elements related to this component in case of
  54249. * context lost for instance.
  54250. */
  54251. rebuild(): void;
  54252. /**
  54253. * Disposes the component and the associated ressources
  54254. */
  54255. dispose(): void;
  54256. }
  54257. }
  54258. declare module "babylonjs/Physics/physicsHelper" {
  54259. import { Nullable } from "babylonjs/types";
  54260. import { Vector3 } from "babylonjs/Maths/math";
  54261. import { Mesh } from "babylonjs/Meshes/mesh";
  54262. import { Scene } from "babylonjs/scene";
  54263. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54264. /**
  54265. * A helper for physics simulations
  54266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54267. */
  54268. export class PhysicsHelper {
  54269. private _scene;
  54270. private _physicsEngine;
  54271. /**
  54272. * Initializes the Physics helper
  54273. * @param scene Babylon.js scene
  54274. */
  54275. constructor(scene: Scene);
  54276. /**
  54277. * Applies a radial explosion impulse
  54278. * @param origin the origin of the explosion
  54279. * @param radiusOrEventOptions the radius or the options of radial explosion
  54280. * @param strength the explosion strength
  54281. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54282. * @returns A physics radial explosion event, or null
  54283. */
  54284. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54285. /**
  54286. * Applies a radial explosion force
  54287. * @param origin the origin of the explosion
  54288. * @param radiusOrEventOptions the radius or the options of radial explosion
  54289. * @param strength the explosion strength
  54290. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54291. * @returns A physics radial explosion event, or null
  54292. */
  54293. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54294. /**
  54295. * Creates a gravitational field
  54296. * @param origin the origin of the explosion
  54297. * @param radiusOrEventOptions the radius or the options of radial explosion
  54298. * @param strength the explosion strength
  54299. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54300. * @returns A physics gravitational field event, or null
  54301. */
  54302. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54303. /**
  54304. * Creates a physics updraft event
  54305. * @param origin the origin of the updraft
  54306. * @param radiusOrEventOptions the radius or the options of the updraft
  54307. * @param strength the strength of the updraft
  54308. * @param height the height of the updraft
  54309. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54310. * @returns A physics updraft event, or null
  54311. */
  54312. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54313. /**
  54314. * Creates a physics vortex event
  54315. * @param origin the of the vortex
  54316. * @param radiusOrEventOptions the radius or the options of the vortex
  54317. * @param strength the strength of the vortex
  54318. * @param height the height of the vortex
  54319. * @returns a Physics vortex event, or null
  54320. * A physics vortex event or null
  54321. */
  54322. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54323. }
  54324. /**
  54325. * Represents a physics radial explosion event
  54326. */
  54327. class PhysicsRadialExplosionEvent {
  54328. private _scene;
  54329. private _options;
  54330. private _sphere;
  54331. private _dataFetched;
  54332. /**
  54333. * Initializes a radial explosioin event
  54334. * @param _scene BabylonJS scene
  54335. * @param _options The options for the vortex event
  54336. */
  54337. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54338. /**
  54339. * Returns the data related to the radial explosion event (sphere).
  54340. * @returns The radial explosion event data
  54341. */
  54342. getData(): PhysicsRadialExplosionEventData;
  54343. /**
  54344. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54345. * @param impostor A physics imposter
  54346. * @param origin the origin of the explosion
  54347. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54348. */
  54349. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54350. /**
  54351. * Triggers affecterd impostors callbacks
  54352. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54353. */
  54354. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54355. /**
  54356. * Disposes the sphere.
  54357. * @param force Specifies if the sphere should be disposed by force
  54358. */
  54359. dispose(force?: boolean): void;
  54360. /*** Helpers ***/
  54361. private _prepareSphere;
  54362. private _intersectsWithSphere;
  54363. }
  54364. /**
  54365. * Represents a gravitational field event
  54366. */
  54367. class PhysicsGravitationalFieldEvent {
  54368. private _physicsHelper;
  54369. private _scene;
  54370. private _origin;
  54371. private _options;
  54372. private _tickCallback;
  54373. private _sphere;
  54374. private _dataFetched;
  54375. /**
  54376. * Initializes the physics gravitational field event
  54377. * @param _physicsHelper A physics helper
  54378. * @param _scene BabylonJS scene
  54379. * @param _origin The origin position of the gravitational field event
  54380. * @param _options The options for the vortex event
  54381. */
  54382. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54383. /**
  54384. * Returns the data related to the gravitational field event (sphere).
  54385. * @returns A gravitational field event
  54386. */
  54387. getData(): PhysicsGravitationalFieldEventData;
  54388. /**
  54389. * Enables the gravitational field.
  54390. */
  54391. enable(): void;
  54392. /**
  54393. * Disables the gravitational field.
  54394. */
  54395. disable(): void;
  54396. /**
  54397. * Disposes the sphere.
  54398. * @param force The force to dispose from the gravitational field event
  54399. */
  54400. dispose(force?: boolean): void;
  54401. private _tick;
  54402. }
  54403. /**
  54404. * Represents a physics updraft event
  54405. */
  54406. class PhysicsUpdraftEvent {
  54407. private _scene;
  54408. private _origin;
  54409. private _options;
  54410. private _physicsEngine;
  54411. private _originTop;
  54412. private _originDirection;
  54413. private _tickCallback;
  54414. private _cylinder;
  54415. private _cylinderPosition;
  54416. private _dataFetched;
  54417. /**
  54418. * Initializes the physics updraft event
  54419. * @param _scene BabylonJS scene
  54420. * @param _origin The origin position of the updraft
  54421. * @param _options The options for the updraft event
  54422. */
  54423. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54424. /**
  54425. * Returns the data related to the updraft event (cylinder).
  54426. * @returns A physics updraft event
  54427. */
  54428. getData(): PhysicsUpdraftEventData;
  54429. /**
  54430. * Enables the updraft.
  54431. */
  54432. enable(): void;
  54433. /**
  54434. * Disables the updraft.
  54435. */
  54436. disable(): void;
  54437. /**
  54438. * Disposes the cylinder.
  54439. * @param force Specifies if the updraft should be disposed by force
  54440. */
  54441. dispose(force?: boolean): void;
  54442. private getImpostorHitData;
  54443. private _tick;
  54444. /*** Helpers ***/
  54445. private _prepareCylinder;
  54446. private _intersectsWithCylinder;
  54447. }
  54448. /**
  54449. * Represents a physics vortex event
  54450. */
  54451. class PhysicsVortexEvent {
  54452. private _scene;
  54453. private _origin;
  54454. private _options;
  54455. private _physicsEngine;
  54456. private _originTop;
  54457. private _tickCallback;
  54458. private _cylinder;
  54459. private _cylinderPosition;
  54460. private _dataFetched;
  54461. /**
  54462. * Initializes the physics vortex event
  54463. * @param _scene The BabylonJS scene
  54464. * @param _origin The origin position of the vortex
  54465. * @param _options The options for the vortex event
  54466. */
  54467. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54468. /**
  54469. * Returns the data related to the vortex event (cylinder).
  54470. * @returns The physics vortex event data
  54471. */
  54472. getData(): PhysicsVortexEventData;
  54473. /**
  54474. * Enables the vortex.
  54475. */
  54476. enable(): void;
  54477. /**
  54478. * Disables the cortex.
  54479. */
  54480. disable(): void;
  54481. /**
  54482. * Disposes the sphere.
  54483. * @param force
  54484. */
  54485. dispose(force?: boolean): void;
  54486. private getImpostorHitData;
  54487. private _tick;
  54488. /*** Helpers ***/
  54489. private _prepareCylinder;
  54490. private _intersectsWithCylinder;
  54491. }
  54492. /**
  54493. * Options fot the radial explosion event
  54494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54495. */
  54496. export class PhysicsRadialExplosionEventOptions {
  54497. /**
  54498. * The radius of the sphere for the radial explosion.
  54499. */
  54500. radius: number;
  54501. /**
  54502. * The strenth of the explosion.
  54503. */
  54504. strength: number;
  54505. /**
  54506. * The strenght of the force in correspondence to the distance of the affected object
  54507. */
  54508. falloff: PhysicsRadialImpulseFalloff;
  54509. /**
  54510. * Sphere options for the radial explosion.
  54511. */
  54512. sphere: {
  54513. segments: number;
  54514. diameter: number;
  54515. };
  54516. /**
  54517. * Sphere options for the radial explosion.
  54518. */
  54519. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54520. }
  54521. /**
  54522. * Options fot the updraft event
  54523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54524. */
  54525. export class PhysicsUpdraftEventOptions {
  54526. /**
  54527. * The radius of the cylinder for the vortex
  54528. */
  54529. radius: number;
  54530. /**
  54531. * The strenth of the updraft.
  54532. */
  54533. strength: number;
  54534. /**
  54535. * The height of the cylinder for the updraft.
  54536. */
  54537. height: number;
  54538. /**
  54539. * The mode for the the updraft.
  54540. */
  54541. updraftMode: PhysicsUpdraftMode;
  54542. }
  54543. /**
  54544. * Options fot the vortex event
  54545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54546. */
  54547. export class PhysicsVortexEventOptions {
  54548. /**
  54549. * The radius of the cylinder for the vortex
  54550. */
  54551. radius: number;
  54552. /**
  54553. * The strenth of the vortex.
  54554. */
  54555. strength: number;
  54556. /**
  54557. * The height of the cylinder for the vortex.
  54558. */
  54559. height: number;
  54560. /**
  54561. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54562. */
  54563. centripetalForceThreshold: number;
  54564. /**
  54565. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54566. */
  54567. centripetalForceMultiplier: number;
  54568. /**
  54569. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54570. */
  54571. centrifugalForceMultiplier: number;
  54572. /**
  54573. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54574. */
  54575. updraftForceMultiplier: number;
  54576. }
  54577. /**
  54578. * The strenght of the force in correspondence to the distance of the affected object
  54579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54580. */
  54581. export enum PhysicsRadialImpulseFalloff {
  54582. /** Defines that impulse is constant in strength across it's whole radius */
  54583. Constant = 0,
  54584. /** Defines that impulse gets weaker if it's further from the origin */
  54585. Linear = 1
  54586. }
  54587. /**
  54588. * The strength of the force in correspondence to the distance of the affected object
  54589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54590. */
  54591. export enum PhysicsUpdraftMode {
  54592. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54593. Center = 0,
  54594. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54595. Perpendicular = 1
  54596. }
  54597. /**
  54598. * Interface for a physics hit data
  54599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54600. */
  54601. export interface PhysicsHitData {
  54602. /**
  54603. * The force applied at the contact point
  54604. */
  54605. force: Vector3;
  54606. /**
  54607. * The contact point
  54608. */
  54609. contactPoint: Vector3;
  54610. /**
  54611. * The distance from the origin to the contact point
  54612. */
  54613. distanceFromOrigin: number;
  54614. }
  54615. /**
  54616. * Interface for radial explosion event data
  54617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54618. */
  54619. export interface PhysicsRadialExplosionEventData {
  54620. /**
  54621. * A sphere used for the radial explosion event
  54622. */
  54623. sphere: Mesh;
  54624. }
  54625. /**
  54626. * Interface for gravitational field event data
  54627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54628. */
  54629. export interface PhysicsGravitationalFieldEventData {
  54630. /**
  54631. * A sphere mesh used for the gravitational field event
  54632. */
  54633. sphere: Mesh;
  54634. }
  54635. /**
  54636. * Interface for updraft event data
  54637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54638. */
  54639. export interface PhysicsUpdraftEventData {
  54640. /**
  54641. * A cylinder used for the updraft event
  54642. */
  54643. cylinder: Mesh;
  54644. }
  54645. /**
  54646. * Interface for vortex event data
  54647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54648. */
  54649. export interface PhysicsVortexEventData {
  54650. /**
  54651. * A cylinder used for the vortex event
  54652. */
  54653. cylinder: Mesh;
  54654. }
  54655. /**
  54656. * Interface for an affected physics impostor
  54657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54658. */
  54659. export interface PhysicsAffectedImpostorWithData {
  54660. /**
  54661. * The impostor affected by the effect
  54662. */
  54663. impostor: PhysicsImpostor;
  54664. /**
  54665. * The data about the hit/horce from the explosion
  54666. */
  54667. hitData: PhysicsHitData;
  54668. }
  54669. }
  54670. declare module "babylonjs/Physics/Plugins/index" {
  54671. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54672. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54673. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54674. }
  54675. declare module "babylonjs/Physics/index" {
  54676. export * from "babylonjs/Physics/IPhysicsEngine";
  54677. export * from "babylonjs/Physics/physicsEngine";
  54678. export * from "babylonjs/Physics/physicsEngineComponent";
  54679. export * from "babylonjs/Physics/physicsHelper";
  54680. export * from "babylonjs/Physics/physicsImpostor";
  54681. export * from "babylonjs/Physics/physicsJoint";
  54682. export * from "babylonjs/Physics/Plugins/index";
  54683. }
  54684. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54685. /** @hidden */
  54686. export var blackAndWhitePixelShader: {
  54687. name: string;
  54688. shader: string;
  54689. };
  54690. }
  54691. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54692. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54693. import { Camera } from "babylonjs/Cameras/camera";
  54694. import { Engine } from "babylonjs/Engines/engine";
  54695. import "babylonjs/Shaders/blackAndWhite.fragment";
  54696. /**
  54697. * Post process used to render in black and white
  54698. */
  54699. export class BlackAndWhitePostProcess extends PostProcess {
  54700. /**
  54701. * Linear about to convert he result to black and white (default: 1)
  54702. */
  54703. degree: number;
  54704. /**
  54705. * Creates a black and white post process
  54706. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54707. * @param name The name of the effect.
  54708. * @param options The required width/height ratio to downsize to before computing the render pass.
  54709. * @param camera The camera to apply the render pass to.
  54710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54711. * @param engine The engine which the post process will be applied. (default: current engine)
  54712. * @param reusable If the post process can be reused on the same frame. (default: false)
  54713. */
  54714. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54715. }
  54716. }
  54717. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54718. import { Nullable } from "babylonjs/types";
  54719. import { Camera } from "babylonjs/Cameras/camera";
  54720. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54721. import { Engine } from "babylonjs/Engines/engine";
  54722. /**
  54723. * This represents a set of one or more post processes in Babylon.
  54724. * A post process can be used to apply a shader to a texture after it is rendered.
  54725. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54726. */
  54727. export class PostProcessRenderEffect {
  54728. private _postProcesses;
  54729. private _getPostProcesses;
  54730. private _singleInstance;
  54731. private _cameras;
  54732. private _indicesForCamera;
  54733. /**
  54734. * Name of the effect
  54735. * @hidden
  54736. */
  54737. _name: string;
  54738. /**
  54739. * Instantiates a post process render effect.
  54740. * A post process can be used to apply a shader to a texture after it is rendered.
  54741. * @param engine The engine the effect is tied to
  54742. * @param name The name of the effect
  54743. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54744. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54745. */
  54746. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54747. /**
  54748. * Checks if all the post processes in the effect are supported.
  54749. */
  54750. readonly isSupported: boolean;
  54751. /**
  54752. * Updates the current state of the effect
  54753. * @hidden
  54754. */
  54755. _update(): void;
  54756. /**
  54757. * Attaches the effect on cameras
  54758. * @param cameras The camera to attach to.
  54759. * @hidden
  54760. */
  54761. _attachCameras(cameras: Camera): void;
  54762. /**
  54763. * Attaches the effect on cameras
  54764. * @param cameras The camera to attach to.
  54765. * @hidden
  54766. */
  54767. _attachCameras(cameras: Camera[]): void;
  54768. /**
  54769. * Detaches the effect on cameras
  54770. * @param cameras The camera to detatch from.
  54771. * @hidden
  54772. */
  54773. _detachCameras(cameras: Camera): void;
  54774. /**
  54775. * Detatches the effect on cameras
  54776. * @param cameras The camera to detatch from.
  54777. * @hidden
  54778. */
  54779. _detachCameras(cameras: Camera[]): void;
  54780. /**
  54781. * Enables the effect on given cameras
  54782. * @param cameras The camera to enable.
  54783. * @hidden
  54784. */
  54785. _enable(cameras: Camera): void;
  54786. /**
  54787. * Enables the effect on given cameras
  54788. * @param cameras The camera to enable.
  54789. * @hidden
  54790. */
  54791. _enable(cameras: Nullable<Camera[]>): void;
  54792. /**
  54793. * Disables the effect on the given cameras
  54794. * @param cameras The camera to disable.
  54795. * @hidden
  54796. */
  54797. _disable(cameras: Camera): void;
  54798. /**
  54799. * Disables the effect on the given cameras
  54800. * @param cameras The camera to disable.
  54801. * @hidden
  54802. */
  54803. _disable(cameras: Nullable<Camera[]>): void;
  54804. /**
  54805. * Gets a list of the post processes contained in the effect.
  54806. * @param camera The camera to get the post processes on.
  54807. * @returns The list of the post processes in the effect.
  54808. */
  54809. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54810. }
  54811. }
  54812. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54813. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54814. /** @hidden */
  54815. export var extractHighlightsPixelShader: {
  54816. name: string;
  54817. shader: string;
  54818. };
  54819. }
  54820. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54821. import { Nullable } from "babylonjs/types";
  54822. import { Camera } from "babylonjs/Cameras/camera";
  54823. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54824. import { Engine } from "babylonjs/Engines/engine";
  54825. import "babylonjs/Shaders/extractHighlights.fragment";
  54826. /**
  54827. * 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.
  54828. */
  54829. export class ExtractHighlightsPostProcess extends PostProcess {
  54830. /**
  54831. * The luminance threshold, pixels below this value will be set to black.
  54832. */
  54833. threshold: number;
  54834. /** @hidden */
  54835. _exposure: number;
  54836. /**
  54837. * Post process which has the input texture to be used when performing highlight extraction
  54838. * @hidden
  54839. */
  54840. _inputPostProcess: Nullable<PostProcess>;
  54841. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54842. }
  54843. }
  54844. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54845. /** @hidden */
  54846. export var bloomMergePixelShader: {
  54847. name: string;
  54848. shader: string;
  54849. };
  54850. }
  54851. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54852. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54853. import { Nullable } from "babylonjs/types";
  54854. import { Engine } from "babylonjs/Engines/engine";
  54855. import { Camera } from "babylonjs/Cameras/camera";
  54856. import "babylonjs/Shaders/bloomMerge.fragment";
  54857. /**
  54858. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54859. */
  54860. export class BloomMergePostProcess extends PostProcess {
  54861. /** Weight of the bloom to be added to the original input. */
  54862. weight: number;
  54863. /**
  54864. * Creates a new instance of @see BloomMergePostProcess
  54865. * @param name The name of the effect.
  54866. * @param originalFromInput Post process which's input will be used for the merge.
  54867. * @param blurred Blurred highlights post process which's output will be used.
  54868. * @param weight Weight of the bloom to be added to the original input.
  54869. * @param options The required width/height ratio to downsize to before computing the render pass.
  54870. * @param camera The camera to apply the render pass to.
  54871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54872. * @param engine The engine which the post process will be applied. (default: current engine)
  54873. * @param reusable If the post process can be reused on the same frame. (default: false)
  54874. * @param textureType Type of textures used when performing the post process. (default: 0)
  54875. * @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)
  54876. */
  54877. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54878. /** Weight of the bloom to be added to the original input. */
  54879. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54880. }
  54881. }
  54882. declare module "babylonjs/PostProcesses/bloomEffect" {
  54883. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54884. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54885. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54886. import { Camera } from "babylonjs/Cameras/camera";
  54887. import { Scene } from "babylonjs/scene";
  54888. /**
  54889. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54890. */
  54891. export class BloomEffect extends PostProcessRenderEffect {
  54892. private bloomScale;
  54893. /**
  54894. * @hidden Internal
  54895. */
  54896. _effects: Array<PostProcess>;
  54897. /**
  54898. * @hidden Internal
  54899. */
  54900. _downscale: ExtractHighlightsPostProcess;
  54901. private _blurX;
  54902. private _blurY;
  54903. private _merge;
  54904. /**
  54905. * The luminance threshold to find bright areas of the image to bloom.
  54906. */
  54907. threshold: number;
  54908. /**
  54909. * The strength of the bloom.
  54910. */
  54911. weight: number;
  54912. /**
  54913. * Specifies the size of the bloom blur kernel, relative to the final output size
  54914. */
  54915. kernel: number;
  54916. /**
  54917. * Creates a new instance of @see BloomEffect
  54918. * @param scene The scene the effect belongs to.
  54919. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54920. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54921. * @param bloomWeight The the strength of bloom.
  54922. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54923. * @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)
  54924. */
  54925. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54926. /**
  54927. * Disposes each of the internal effects for a given camera.
  54928. * @param camera The camera to dispose the effect on.
  54929. */
  54930. disposeEffects(camera: Camera): void;
  54931. /**
  54932. * @hidden Internal
  54933. */
  54934. _updateEffects(): void;
  54935. /**
  54936. * Internal
  54937. * @returns if all the contained post processes are ready.
  54938. * @hidden
  54939. */
  54940. _isReady(): boolean;
  54941. }
  54942. }
  54943. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54944. /** @hidden */
  54945. export var chromaticAberrationPixelShader: {
  54946. name: string;
  54947. shader: string;
  54948. };
  54949. }
  54950. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54951. import { Vector2 } from "babylonjs/Maths/math";
  54952. import { Nullable } from "babylonjs/types";
  54953. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54954. import { Camera } from "babylonjs/Cameras/camera";
  54955. import { Engine } from "babylonjs/Engines/engine";
  54956. import "babylonjs/Shaders/chromaticAberration.fragment";
  54957. /**
  54958. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54959. */
  54960. export class ChromaticAberrationPostProcess extends PostProcess {
  54961. /**
  54962. * The amount of seperation of rgb channels (default: 30)
  54963. */
  54964. aberrationAmount: number;
  54965. /**
  54966. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54967. */
  54968. radialIntensity: number;
  54969. /**
  54970. * 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))
  54971. */
  54972. direction: Vector2;
  54973. /**
  54974. * 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))
  54975. */
  54976. centerPosition: Vector2;
  54977. /**
  54978. * Creates a new instance ChromaticAberrationPostProcess
  54979. * @param name The name of the effect.
  54980. * @param screenWidth The width of the screen to apply the effect on.
  54981. * @param screenHeight The height of the screen to apply the effect on.
  54982. * @param options The required width/height ratio to downsize to before computing the render pass.
  54983. * @param camera The camera to apply the render pass to.
  54984. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54985. * @param engine The engine which the post process will be applied. (default: current engine)
  54986. * @param reusable If the post process can be reused on the same frame. (default: false)
  54987. * @param textureType Type of textures used when performing the post process. (default: 0)
  54988. * @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)
  54989. */
  54990. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54991. }
  54992. }
  54993. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54994. /** @hidden */
  54995. export var circleOfConfusionPixelShader: {
  54996. name: string;
  54997. shader: string;
  54998. };
  54999. }
  55000. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  55001. import { Nullable } from "babylonjs/types";
  55002. import { Engine } from "babylonjs/Engines/engine";
  55003. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55004. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55005. import { Camera } from "babylonjs/Cameras/camera";
  55006. import "babylonjs/Shaders/circleOfConfusion.fragment";
  55007. /**
  55008. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55009. */
  55010. export class CircleOfConfusionPostProcess extends PostProcess {
  55011. /**
  55012. * 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.
  55013. */
  55014. lensSize: number;
  55015. /**
  55016. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55017. */
  55018. fStop: number;
  55019. /**
  55020. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55021. */
  55022. focusDistance: number;
  55023. /**
  55024. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55025. */
  55026. focalLength: number;
  55027. private _depthTexture;
  55028. /**
  55029. * Creates a new instance CircleOfConfusionPostProcess
  55030. * @param name The name of the effect.
  55031. * @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.
  55032. * @param options The required width/height ratio to downsize to before computing the render pass.
  55033. * @param camera The camera to apply the render pass to.
  55034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55035. * @param engine The engine which the post process will be applied. (default: current engine)
  55036. * @param reusable If the post process can be reused on the same frame. (default: false)
  55037. * @param textureType Type of textures used when performing the post process. (default: 0)
  55038. * @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)
  55039. */
  55040. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55041. /**
  55042. * 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.
  55043. */
  55044. depthTexture: RenderTargetTexture;
  55045. }
  55046. }
  55047. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  55048. /** @hidden */
  55049. export var colorCorrectionPixelShader: {
  55050. name: string;
  55051. shader: string;
  55052. };
  55053. }
  55054. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  55055. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55056. import { Engine } from "babylonjs/Engines/engine";
  55057. import { Camera } from "babylonjs/Cameras/camera";
  55058. import "babylonjs/Shaders/colorCorrection.fragment";
  55059. /**
  55060. *
  55061. * This post-process allows the modification of rendered colors by using
  55062. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55063. *
  55064. * The object needs to be provided an url to a texture containing the color
  55065. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55066. * Use an image editing software to tweak the LUT to match your needs.
  55067. *
  55068. * For an example of a color LUT, see here:
  55069. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55070. * For explanations on color grading, see here:
  55071. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55072. *
  55073. */
  55074. export class ColorCorrectionPostProcess extends PostProcess {
  55075. private _colorTableTexture;
  55076. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55077. }
  55078. }
  55079. declare module "babylonjs/Shaders/convolution.fragment" {
  55080. /** @hidden */
  55081. export var convolutionPixelShader: {
  55082. name: string;
  55083. shader: string;
  55084. };
  55085. }
  55086. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  55087. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55088. import { Nullable } from "babylonjs/types";
  55089. import { Camera } from "babylonjs/Cameras/camera";
  55090. import { Engine } from "babylonjs/Engines/engine";
  55091. import "babylonjs/Shaders/convolution.fragment";
  55092. /**
  55093. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55094. * input texture to perform effects such as edge detection or sharpening
  55095. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55096. */
  55097. export class ConvolutionPostProcess extends PostProcess {
  55098. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55099. kernel: number[];
  55100. /**
  55101. * Creates a new instance ConvolutionPostProcess
  55102. * @param name The name of the effect.
  55103. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  55104. * @param options The required width/height ratio to downsize to before computing the render pass.
  55105. * @param camera The camera to apply the render pass to.
  55106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55107. * @param engine The engine which the post process will be applied. (default: current engine)
  55108. * @param reusable If the post process can be reused on the same frame. (default: false)
  55109. * @param textureType Type of textures used when performing the post process. (default: 0)
  55110. */
  55111. constructor(name: string,
  55112. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55113. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55114. /**
  55115. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55116. */
  55117. static EdgeDetect0Kernel: number[];
  55118. /**
  55119. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55120. */
  55121. static EdgeDetect1Kernel: number[];
  55122. /**
  55123. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55124. */
  55125. static EdgeDetect2Kernel: number[];
  55126. /**
  55127. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55128. */
  55129. static SharpenKernel: number[];
  55130. /**
  55131. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55132. */
  55133. static EmbossKernel: number[];
  55134. /**
  55135. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55136. */
  55137. static GaussianKernel: number[];
  55138. }
  55139. }
  55140. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  55141. import { Nullable } from "babylonjs/types";
  55142. import { Vector2 } from "babylonjs/Maths/math";
  55143. import { Camera } from "babylonjs/Cameras/camera";
  55144. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55145. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55146. import { Engine } from "babylonjs/Engines/engine";
  55147. import { Scene } from "babylonjs/scene";
  55148. /**
  55149. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55150. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55151. * based on samples that have a large difference in distance than the center pixel.
  55152. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55153. */
  55154. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55155. direction: Vector2;
  55156. /**
  55157. * Creates a new instance CircleOfConfusionPostProcess
  55158. * @param name The name of the effect.
  55159. * @param scene The scene the effect belongs to.
  55160. * @param direction The direction the blur should be applied.
  55161. * @param kernel The size of the kernel used to blur.
  55162. * @param options The required width/height ratio to downsize to before computing the render pass.
  55163. * @param camera The camera to apply the render pass to.
  55164. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55165. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55166. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55167. * @param engine The engine which the post process will be applied. (default: current engine)
  55168. * @param reusable If the post process can be reused on the same frame. (default: false)
  55169. * @param textureType Type of textures used when performing the post process. (default: 0)
  55170. * @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)
  55171. */
  55172. 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);
  55173. }
  55174. }
  55175. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  55176. /** @hidden */
  55177. export var depthOfFieldMergePixelShader: {
  55178. name: string;
  55179. shader: string;
  55180. };
  55181. }
  55182. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  55183. import { Nullable } from "babylonjs/types";
  55184. import { Camera } from "babylonjs/Cameras/camera";
  55185. import { Effect } from "babylonjs/Materials/effect";
  55186. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55187. import { Engine } from "babylonjs/Engines/engine";
  55188. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  55189. /**
  55190. * Options to be set when merging outputs from the default pipeline.
  55191. */
  55192. export class DepthOfFieldMergePostProcessOptions {
  55193. /**
  55194. * The original image to merge on top of
  55195. */
  55196. originalFromInput: PostProcess;
  55197. /**
  55198. * Parameters to perform the merge of the depth of field effect
  55199. */
  55200. depthOfField?: {
  55201. circleOfConfusion: PostProcess;
  55202. blurSteps: Array<PostProcess>;
  55203. };
  55204. /**
  55205. * Parameters to perform the merge of bloom effect
  55206. */
  55207. bloom?: {
  55208. blurred: PostProcess;
  55209. weight: number;
  55210. };
  55211. }
  55212. /**
  55213. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55214. */
  55215. export class DepthOfFieldMergePostProcess extends PostProcess {
  55216. private blurSteps;
  55217. /**
  55218. * Creates a new instance of DepthOfFieldMergePostProcess
  55219. * @param name The name of the effect.
  55220. * @param originalFromInput Post process which's input will be used for the merge.
  55221. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55222. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55223. * @param options The required width/height ratio to downsize to before computing the render pass.
  55224. * @param camera The camera to apply the render pass to.
  55225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55226. * @param engine The engine which the post process will be applied. (default: current engine)
  55227. * @param reusable If the post process can be reused on the same frame. (default: false)
  55228. * @param textureType Type of textures used when performing the post process. (default: 0)
  55229. * @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)
  55230. */
  55231. 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);
  55232. /**
  55233. * Updates the effect with the current post process compile time values and recompiles the shader.
  55234. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55235. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55236. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55237. * @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
  55238. * @param onCompiled Called when the shader has been compiled.
  55239. * @param onError Called if there is an error when compiling a shader.
  55240. */
  55241. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55242. }
  55243. }
  55244. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  55245. import { Nullable } from "babylonjs/types";
  55246. import { Camera } from "babylonjs/Cameras/camera";
  55247. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55248. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55249. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55250. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55251. import { Scene } from "babylonjs/scene";
  55252. /**
  55253. * Specifies the level of max blur that should be applied when using the depth of field effect
  55254. */
  55255. export enum DepthOfFieldEffectBlurLevel {
  55256. /**
  55257. * Subtle blur
  55258. */
  55259. Low = 0,
  55260. /**
  55261. * Medium blur
  55262. */
  55263. Medium = 1,
  55264. /**
  55265. * Large blur
  55266. */
  55267. High = 2
  55268. }
  55269. /**
  55270. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55271. */
  55272. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55273. private _circleOfConfusion;
  55274. /**
  55275. * @hidden Internal, blurs from high to low
  55276. */
  55277. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55278. private _depthOfFieldBlurY;
  55279. private _dofMerge;
  55280. /**
  55281. * @hidden Internal post processes in depth of field effect
  55282. */
  55283. _effects: Array<PostProcess>;
  55284. /**
  55285. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55286. */
  55287. focalLength: number;
  55288. /**
  55289. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55290. */
  55291. fStop: number;
  55292. /**
  55293. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55294. */
  55295. focusDistance: number;
  55296. /**
  55297. * 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.
  55298. */
  55299. lensSize: number;
  55300. /**
  55301. * Creates a new instance DepthOfFieldEffect
  55302. * @param scene The scene the effect belongs to.
  55303. * @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.
  55304. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55305. * @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)
  55306. */
  55307. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55308. /**
  55309. * Get the current class name of the current effet
  55310. * @returns "DepthOfFieldEffect"
  55311. */
  55312. getClassName(): string;
  55313. /**
  55314. * 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.
  55315. */
  55316. depthTexture: RenderTargetTexture;
  55317. /**
  55318. * Disposes each of the internal effects for a given camera.
  55319. * @param camera The camera to dispose the effect on.
  55320. */
  55321. disposeEffects(camera: Camera): void;
  55322. /**
  55323. * @hidden Internal
  55324. */
  55325. _updateEffects(): void;
  55326. /**
  55327. * Internal
  55328. * @returns if all the contained post processes are ready.
  55329. * @hidden
  55330. */
  55331. _isReady(): boolean;
  55332. }
  55333. }
  55334. declare module "babylonjs/Shaders/displayPass.fragment" {
  55335. /** @hidden */
  55336. export var displayPassPixelShader: {
  55337. name: string;
  55338. shader: string;
  55339. };
  55340. }
  55341. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  55342. import { Nullable } from "babylonjs/types";
  55343. import { Camera } from "babylonjs/Cameras/camera";
  55344. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55345. import { Engine } from "babylonjs/Engines/engine";
  55346. import "babylonjs/Shaders/displayPass.fragment";
  55347. /**
  55348. * DisplayPassPostProcess which produces an output the same as it's input
  55349. */
  55350. export class DisplayPassPostProcess extends PostProcess {
  55351. /**
  55352. * Creates the DisplayPassPostProcess
  55353. * @param name The name of the effect.
  55354. * @param options The required width/height ratio to downsize to before computing the render pass.
  55355. * @param camera The camera to apply the render pass to.
  55356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55357. * @param engine The engine which the post process will be applied. (default: current engine)
  55358. * @param reusable If the post process can be reused on the same frame. (default: false)
  55359. */
  55360. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55361. }
  55362. }
  55363. declare module "babylonjs/Shaders/filter.fragment" {
  55364. /** @hidden */
  55365. export var filterPixelShader: {
  55366. name: string;
  55367. shader: string;
  55368. };
  55369. }
  55370. declare module "babylonjs/PostProcesses/filterPostProcess" {
  55371. import { Nullable } from "babylonjs/types";
  55372. import { Matrix } from "babylonjs/Maths/math";
  55373. import { Camera } from "babylonjs/Cameras/camera";
  55374. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55375. import { Engine } from "babylonjs/Engines/engine";
  55376. import "babylonjs/Shaders/filter.fragment";
  55377. /**
  55378. * Applies a kernel filter to the image
  55379. */
  55380. export class FilterPostProcess extends PostProcess {
  55381. /** The matrix to be applied to the image */
  55382. kernelMatrix: Matrix;
  55383. /**
  55384. *
  55385. * @param name The name of the effect.
  55386. * @param kernelMatrix The matrix to be applied to the image
  55387. * @param options The required width/height ratio to downsize to before computing the render pass.
  55388. * @param camera The camera to apply the render pass to.
  55389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55390. * @param engine The engine which the post process will be applied. (default: current engine)
  55391. * @param reusable If the post process can be reused on the same frame. (default: false)
  55392. */
  55393. constructor(name: string,
  55394. /** The matrix to be applied to the image */
  55395. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55396. }
  55397. }
  55398. declare module "babylonjs/Shaders/fxaa.fragment" {
  55399. /** @hidden */
  55400. export var fxaaPixelShader: {
  55401. name: string;
  55402. shader: string;
  55403. };
  55404. }
  55405. declare module "babylonjs/Shaders/fxaa.vertex" {
  55406. /** @hidden */
  55407. export var fxaaVertexShader: {
  55408. name: string;
  55409. shader: string;
  55410. };
  55411. }
  55412. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  55413. import { Nullable } from "babylonjs/types";
  55414. import { Camera } from "babylonjs/Cameras/camera";
  55415. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55416. import { Engine } from "babylonjs/Engines/engine";
  55417. import "babylonjs/Shaders/fxaa.fragment";
  55418. import "babylonjs/Shaders/fxaa.vertex";
  55419. /**
  55420. * Fxaa post process
  55421. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55422. */
  55423. export class FxaaPostProcess extends PostProcess {
  55424. /** @hidden */
  55425. texelWidth: number;
  55426. /** @hidden */
  55427. texelHeight: number;
  55428. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55429. private _getDefines;
  55430. }
  55431. }
  55432. declare module "babylonjs/Shaders/grain.fragment" {
  55433. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55434. /** @hidden */
  55435. export var grainPixelShader: {
  55436. name: string;
  55437. shader: string;
  55438. };
  55439. }
  55440. declare module "babylonjs/PostProcesses/grainPostProcess" {
  55441. import { Nullable } from "babylonjs/types";
  55442. import { Camera } from "babylonjs/Cameras/camera";
  55443. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55444. import { Engine } from "babylonjs/Engines/engine";
  55445. import "babylonjs/Shaders/grain.fragment";
  55446. /**
  55447. * The GrainPostProcess adds noise to the image at mid luminance levels
  55448. */
  55449. export class GrainPostProcess extends PostProcess {
  55450. /**
  55451. * The intensity of the grain added (default: 30)
  55452. */
  55453. intensity: number;
  55454. /**
  55455. * If the grain should be randomized on every frame
  55456. */
  55457. animated: boolean;
  55458. /**
  55459. * Creates a new instance of @see GrainPostProcess
  55460. * @param name The name of the effect.
  55461. * @param options The required width/height ratio to downsize to before computing the render pass.
  55462. * @param camera The camera to apply the render pass to.
  55463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55464. * @param engine The engine which the post process will be applied. (default: current engine)
  55465. * @param reusable If the post process can be reused on the same frame. (default: false)
  55466. * @param textureType Type of textures used when performing the post process. (default: 0)
  55467. * @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)
  55468. */
  55469. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55470. }
  55471. }
  55472. declare module "babylonjs/Shaders/highlights.fragment" {
  55473. /** @hidden */
  55474. export var highlightsPixelShader: {
  55475. name: string;
  55476. shader: string;
  55477. };
  55478. }
  55479. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  55480. import { Nullable } from "babylonjs/types";
  55481. import { Camera } from "babylonjs/Cameras/camera";
  55482. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55483. import { Engine } from "babylonjs/Engines/engine";
  55484. import "babylonjs/Shaders/highlights.fragment";
  55485. /**
  55486. * Extracts highlights from the image
  55487. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55488. */
  55489. export class HighlightsPostProcess extends PostProcess {
  55490. /**
  55491. * Extracts highlights from the image
  55492. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55493. * @param name The name of the effect.
  55494. * @param options The required width/height ratio to downsize to before computing the render pass.
  55495. * @param camera The camera to apply the render pass to.
  55496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55497. * @param engine The engine which the post process will be applied. (default: current engine)
  55498. * @param reusable If the post process can be reused on the same frame. (default: false)
  55499. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55500. */
  55501. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55502. }
  55503. }
  55504. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  55505. /** @hidden */
  55506. export var mrtFragmentDeclaration: {
  55507. name: string;
  55508. shader: string;
  55509. };
  55510. }
  55511. declare module "babylonjs/Shaders/geometry.fragment" {
  55512. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  55513. /** @hidden */
  55514. export var geometryPixelShader: {
  55515. name: string;
  55516. shader: string;
  55517. };
  55518. }
  55519. declare module "babylonjs/Shaders/geometry.vertex" {
  55520. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55521. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55522. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55523. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55524. /** @hidden */
  55525. export var geometryVertexShader: {
  55526. name: string;
  55527. shader: string;
  55528. };
  55529. }
  55530. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55531. import { Matrix } from "babylonjs/Maths/math";
  55532. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55533. import { Mesh } from "babylonjs/Meshes/mesh";
  55534. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55535. import { Effect } from "babylonjs/Materials/effect";
  55536. import { Scene } from "babylonjs/scene";
  55537. import "babylonjs/Shaders/geometry.fragment";
  55538. import "babylonjs/Shaders/geometry.vertex";
  55539. /**
  55540. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55541. */
  55542. export class GeometryBufferRenderer {
  55543. /**
  55544. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55545. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55546. */
  55547. static readonly POSITION_TEXTURE_TYPE: number;
  55548. /**
  55549. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55550. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55551. */
  55552. static readonly VELOCITY_TEXTURE_TYPE: number;
  55553. /**
  55554. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55555. * in order to compute objects velocities when enableVelocity is set to "true"
  55556. * @hidden
  55557. */
  55558. _previousTransformationMatrices: {
  55559. [index: number]: Matrix;
  55560. };
  55561. private _scene;
  55562. private _multiRenderTarget;
  55563. private _ratio;
  55564. private _enablePosition;
  55565. private _enableVelocity;
  55566. private _positionIndex;
  55567. private _velocityIndex;
  55568. protected _effect: Effect;
  55569. protected _cachedDefines: string;
  55570. /**
  55571. * Set the render list (meshes to be rendered) used in the G buffer.
  55572. */
  55573. renderList: Mesh[];
  55574. /**
  55575. * Gets wether or not G buffer are supported by the running hardware.
  55576. * This requires draw buffer supports
  55577. */
  55578. readonly isSupported: boolean;
  55579. /**
  55580. * Returns the index of the given texture type in the G-Buffer textures array
  55581. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55582. * @returns the index of the given texture type in the G-Buffer textures array
  55583. */
  55584. getTextureIndex(textureType: number): number;
  55585. /**
  55586. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55587. */
  55588. /**
  55589. * Sets whether or not objects positions are enabled for the G buffer.
  55590. */
  55591. enablePosition: boolean;
  55592. /**
  55593. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55594. */
  55595. /**
  55596. * Sets wether or not objects velocities are enabled for the G buffer.
  55597. */
  55598. enableVelocity: boolean;
  55599. /**
  55600. * Gets the scene associated with the buffer.
  55601. */
  55602. readonly scene: Scene;
  55603. /**
  55604. * Gets the ratio used by the buffer during its creation.
  55605. * How big is the buffer related to the main canvas.
  55606. */
  55607. readonly ratio: number;
  55608. /** @hidden */
  55609. static _SceneComponentInitialization: (scene: Scene) => void;
  55610. /**
  55611. * Creates a new G Buffer for the scene
  55612. * @param scene The scene the buffer belongs to
  55613. * @param ratio How big is the buffer related to the main canvas.
  55614. */
  55615. constructor(scene: Scene, ratio?: number);
  55616. /**
  55617. * Checks wether everything is ready to render a submesh to the G buffer.
  55618. * @param subMesh the submesh to check readiness for
  55619. * @param useInstances is the mesh drawn using instance or not
  55620. * @returns true if ready otherwise false
  55621. */
  55622. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55623. /**
  55624. * Gets the current underlying G Buffer.
  55625. * @returns the buffer
  55626. */
  55627. getGBuffer(): MultiRenderTarget;
  55628. /**
  55629. * Gets the number of samples used to render the buffer (anti aliasing).
  55630. */
  55631. /**
  55632. * Sets the number of samples used to render the buffer (anti aliasing).
  55633. */
  55634. samples: number;
  55635. /**
  55636. * Disposes the renderer and frees up associated resources.
  55637. */
  55638. dispose(): void;
  55639. protected _createRenderTargets(): void;
  55640. }
  55641. }
  55642. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55643. import { Nullable } from "babylonjs/types";
  55644. import { Scene } from "babylonjs/scene";
  55645. import { ISceneComponent } from "babylonjs/sceneComponent";
  55646. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55647. module "babylonjs/scene" {
  55648. interface Scene {
  55649. /** @hidden (Backing field) */
  55650. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55651. /**
  55652. * Gets or Sets the current geometry buffer associated to the scene.
  55653. */
  55654. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55655. /**
  55656. * Enables a GeometryBufferRender and associates it with the scene
  55657. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55658. * @returns the GeometryBufferRenderer
  55659. */
  55660. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55661. /**
  55662. * Disables the GeometryBufferRender associated with the scene
  55663. */
  55664. disableGeometryBufferRenderer(): void;
  55665. }
  55666. }
  55667. /**
  55668. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55669. * in several rendering techniques.
  55670. */
  55671. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55672. /**
  55673. * The component name helpful to identify the component in the list of scene components.
  55674. */
  55675. readonly name: string;
  55676. /**
  55677. * The scene the component belongs to.
  55678. */
  55679. scene: Scene;
  55680. /**
  55681. * Creates a new instance of the component for the given scene
  55682. * @param scene Defines the scene to register the component in
  55683. */
  55684. constructor(scene: Scene);
  55685. /**
  55686. * Registers the component in a given scene
  55687. */
  55688. register(): void;
  55689. /**
  55690. * Rebuilds the elements related to this component in case of
  55691. * context lost for instance.
  55692. */
  55693. rebuild(): void;
  55694. /**
  55695. * Disposes the component and the associated ressources
  55696. */
  55697. dispose(): void;
  55698. private _gatherRenderTargets;
  55699. }
  55700. }
  55701. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55702. /** @hidden */
  55703. export var motionBlurPixelShader: {
  55704. name: string;
  55705. shader: string;
  55706. };
  55707. }
  55708. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55709. import { Nullable } from "babylonjs/types";
  55710. import { Camera } from "babylonjs/Cameras/camera";
  55711. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55712. import { Scene } from "babylonjs/scene";
  55713. import "babylonjs/Animations/animatable";
  55714. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55715. import "babylonjs/Shaders/motionBlur.fragment";
  55716. import { Engine } from "babylonjs/Engines/engine";
  55717. /**
  55718. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55719. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55720. * As an example, all you have to do is to create the post-process:
  55721. * var mb = new BABYLON.MotionBlurPostProcess(
  55722. * 'mb', // The name of the effect.
  55723. * scene, // The scene containing the objects to blur according to their velocity.
  55724. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55725. * camera // The camera to apply the render pass to.
  55726. * );
  55727. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55728. */
  55729. export class MotionBlurPostProcess extends PostProcess {
  55730. /**
  55731. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55732. */
  55733. motionStrength: number;
  55734. /**
  55735. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55736. */
  55737. /**
  55738. * Sets the number of iterations to be used for motion blur quality
  55739. */
  55740. motionBlurSamples: number;
  55741. private _motionBlurSamples;
  55742. private _geometryBufferRenderer;
  55743. /**
  55744. * Creates a new instance MotionBlurPostProcess
  55745. * @param name The name of the effect.
  55746. * @param scene The scene containing the objects to blur according to their velocity.
  55747. * @param options The required width/height ratio to downsize to before computing the render pass.
  55748. * @param camera The camera to apply the render pass to.
  55749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55750. * @param engine The engine which the post process will be applied. (default: current engine)
  55751. * @param reusable If the post process can be reused on the same frame. (default: false)
  55752. * @param textureType Type of textures used when performing the post process. (default: 0)
  55753. * @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)
  55754. */
  55755. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55756. /**
  55757. * Disposes the post process.
  55758. * @param camera The camera to dispose the post process on.
  55759. */
  55760. dispose(camera?: Camera): void;
  55761. }
  55762. }
  55763. declare module "babylonjs/Shaders/refraction.fragment" {
  55764. /** @hidden */
  55765. export var refractionPixelShader: {
  55766. name: string;
  55767. shader: string;
  55768. };
  55769. }
  55770. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55771. import { Color3 } from "babylonjs/Maths/math";
  55772. import { Camera } from "babylonjs/Cameras/camera";
  55773. import { Texture } from "babylonjs/Materials/Textures/texture";
  55774. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55775. import { Engine } from "babylonjs/Engines/engine";
  55776. import "babylonjs/Shaders/refraction.fragment";
  55777. /**
  55778. * Post process which applies a refractin texture
  55779. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55780. */
  55781. export class RefractionPostProcess extends PostProcess {
  55782. /** the base color of the refraction (used to taint the rendering) */
  55783. color: Color3;
  55784. /** simulated refraction depth */
  55785. depth: number;
  55786. /** the coefficient of the base color (0 to remove base color tainting) */
  55787. colorLevel: number;
  55788. private _refTexture;
  55789. private _ownRefractionTexture;
  55790. /**
  55791. * Gets or sets the refraction texture
  55792. * Please note that you are responsible for disposing the texture if you set it manually
  55793. */
  55794. refractionTexture: Texture;
  55795. /**
  55796. * Initializes the RefractionPostProcess
  55797. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55798. * @param name The name of the effect.
  55799. * @param refractionTextureUrl Url of the refraction texture to use
  55800. * @param color the base color of the refraction (used to taint the rendering)
  55801. * @param depth simulated refraction depth
  55802. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55803. * @param camera The camera to apply the render pass to.
  55804. * @param options The required width/height ratio to downsize to before computing the render pass.
  55805. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55806. * @param engine The engine which the post process will be applied. (default: current engine)
  55807. * @param reusable If the post process can be reused on the same frame. (default: false)
  55808. */
  55809. constructor(name: string, refractionTextureUrl: string,
  55810. /** the base color of the refraction (used to taint the rendering) */
  55811. color: Color3,
  55812. /** simulated refraction depth */
  55813. depth: number,
  55814. /** the coefficient of the base color (0 to remove base color tainting) */
  55815. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55816. /**
  55817. * Disposes of the post process
  55818. * @param camera Camera to dispose post process on
  55819. */
  55820. dispose(camera: Camera): void;
  55821. }
  55822. }
  55823. declare module "babylonjs/Shaders/sharpen.fragment" {
  55824. /** @hidden */
  55825. export var sharpenPixelShader: {
  55826. name: string;
  55827. shader: string;
  55828. };
  55829. }
  55830. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55831. import { Nullable } from "babylonjs/types";
  55832. import { Camera } from "babylonjs/Cameras/camera";
  55833. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55834. import "babylonjs/Shaders/sharpen.fragment";
  55835. import { Engine } from "babylonjs/Engines/engine";
  55836. /**
  55837. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55838. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55839. */
  55840. export class SharpenPostProcess extends PostProcess {
  55841. /**
  55842. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55843. */
  55844. colorAmount: number;
  55845. /**
  55846. * How much sharpness should be applied (default: 0.3)
  55847. */
  55848. edgeAmount: number;
  55849. /**
  55850. * Creates a new instance ConvolutionPostProcess
  55851. * @param name The name of the effect.
  55852. * @param options The required width/height ratio to downsize to before computing the render pass.
  55853. * @param camera The camera to apply the render pass to.
  55854. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55855. * @param engine The engine which the post process will be applied. (default: current engine)
  55856. * @param reusable If the post process can be reused on the same frame. (default: false)
  55857. * @param textureType Type of textures used when performing the post process. (default: 0)
  55858. * @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)
  55859. */
  55860. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55861. }
  55862. }
  55863. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55864. import { Nullable } from "babylonjs/types";
  55865. import { Camera } from "babylonjs/Cameras/camera";
  55866. import { Engine } from "babylonjs/Engines/engine";
  55867. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55868. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55869. /**
  55870. * PostProcessRenderPipeline
  55871. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55872. */
  55873. export class PostProcessRenderPipeline {
  55874. private engine;
  55875. private _renderEffects;
  55876. private _renderEffectsForIsolatedPass;
  55877. /**
  55878. * List of inspectable custom properties (used by the Inspector)
  55879. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55880. */
  55881. inspectableCustomProperties: IInspectable[];
  55882. /**
  55883. * @hidden
  55884. */
  55885. protected _cameras: Camera[];
  55886. /** @hidden */
  55887. _name: string;
  55888. /**
  55889. * Gets pipeline name
  55890. */
  55891. readonly name: string;
  55892. /**
  55893. * Initializes a PostProcessRenderPipeline
  55894. * @param engine engine to add the pipeline to
  55895. * @param name name of the pipeline
  55896. */
  55897. constructor(engine: Engine, name: string);
  55898. /**
  55899. * Gets the class name
  55900. * @returns "PostProcessRenderPipeline"
  55901. */
  55902. getClassName(): string;
  55903. /**
  55904. * If all the render effects in the pipeline are supported
  55905. */
  55906. readonly isSupported: boolean;
  55907. /**
  55908. * Adds an effect to the pipeline
  55909. * @param renderEffect the effect to add
  55910. */
  55911. addEffect(renderEffect: PostProcessRenderEffect): void;
  55912. /** @hidden */
  55913. _rebuild(): void;
  55914. /** @hidden */
  55915. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55916. /** @hidden */
  55917. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55918. /** @hidden */
  55919. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55920. /** @hidden */
  55921. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55922. /** @hidden */
  55923. _attachCameras(cameras: Camera, unique: boolean): void;
  55924. /** @hidden */
  55925. _attachCameras(cameras: Camera[], unique: boolean): void;
  55926. /** @hidden */
  55927. _detachCameras(cameras: Camera): void;
  55928. /** @hidden */
  55929. _detachCameras(cameras: Nullable<Camera[]>): void;
  55930. /** @hidden */
  55931. _update(): void;
  55932. /** @hidden */
  55933. _reset(): void;
  55934. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55935. /**
  55936. * Disposes of the pipeline
  55937. */
  55938. dispose(): void;
  55939. }
  55940. }
  55941. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55942. import { Camera } from "babylonjs/Cameras/camera";
  55943. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55944. /**
  55945. * PostProcessRenderPipelineManager class
  55946. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55947. */
  55948. export class PostProcessRenderPipelineManager {
  55949. private _renderPipelines;
  55950. /**
  55951. * Initializes a PostProcessRenderPipelineManager
  55952. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55953. */
  55954. constructor();
  55955. /**
  55956. * Gets the list of supported render pipelines
  55957. */
  55958. readonly supportedPipelines: PostProcessRenderPipeline[];
  55959. /**
  55960. * Adds a pipeline to the manager
  55961. * @param renderPipeline The pipeline to add
  55962. */
  55963. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55964. /**
  55965. * Attaches a camera to the pipeline
  55966. * @param renderPipelineName The name of the pipeline to attach to
  55967. * @param cameras the camera to attach
  55968. * @param unique if the camera can be attached multiple times to the pipeline
  55969. */
  55970. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55971. /**
  55972. * Detaches a camera from the pipeline
  55973. * @param renderPipelineName The name of the pipeline to detach from
  55974. * @param cameras the camera to detach
  55975. */
  55976. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55977. /**
  55978. * Enables an effect by name on a pipeline
  55979. * @param renderPipelineName the name of the pipeline to enable the effect in
  55980. * @param renderEffectName the name of the effect to enable
  55981. * @param cameras the cameras that the effect should be enabled on
  55982. */
  55983. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55984. /**
  55985. * Disables an effect by name on a pipeline
  55986. * @param renderPipelineName the name of the pipeline to disable the effect in
  55987. * @param renderEffectName the name of the effect to disable
  55988. * @param cameras the cameras that the effect should be disabled on
  55989. */
  55990. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55991. /**
  55992. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55993. */
  55994. update(): void;
  55995. /** @hidden */
  55996. _rebuild(): void;
  55997. /**
  55998. * Disposes of the manager and pipelines
  55999. */
  56000. dispose(): void;
  56001. }
  56002. }
  56003. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  56004. import { ISceneComponent } from "babylonjs/sceneComponent";
  56005. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56006. import { Scene } from "babylonjs/scene";
  56007. module "babylonjs/scene" {
  56008. interface Scene {
  56009. /** @hidden (Backing field) */
  56010. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56011. /**
  56012. * Gets the postprocess render pipeline manager
  56013. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56014. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56015. */
  56016. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56017. }
  56018. }
  56019. /**
  56020. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56021. */
  56022. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56023. /**
  56024. * The component name helpfull to identify the component in the list of scene components.
  56025. */
  56026. readonly name: string;
  56027. /**
  56028. * The scene the component belongs to.
  56029. */
  56030. scene: Scene;
  56031. /**
  56032. * Creates a new instance of the component for the given scene
  56033. * @param scene Defines the scene to register the component in
  56034. */
  56035. constructor(scene: Scene);
  56036. /**
  56037. * Registers the component in a given scene
  56038. */
  56039. register(): void;
  56040. /**
  56041. * Rebuilds the elements related to this component in case of
  56042. * context lost for instance.
  56043. */
  56044. rebuild(): void;
  56045. /**
  56046. * Disposes the component and the associated ressources
  56047. */
  56048. dispose(): void;
  56049. private _gatherRenderTargets;
  56050. }
  56051. }
  56052. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  56053. import { Nullable } from "babylonjs/types";
  56054. import { IAnimatable } from "babylonjs/Misc/tools";
  56055. import { Camera } from "babylonjs/Cameras/camera";
  56056. import { IDisposable } from "babylonjs/scene";
  56057. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  56058. import { Scene } from "babylonjs/scene";
  56059. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  56060. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56061. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56062. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  56063. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56064. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56065. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  56066. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56067. import { Animation } from "babylonjs/Animations/animation";
  56068. /**
  56069. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56070. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56071. */
  56072. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56073. private _scene;
  56074. private _camerasToBeAttached;
  56075. /**
  56076. * ID of the sharpen post process,
  56077. */
  56078. private readonly SharpenPostProcessId;
  56079. /**
  56080. * @ignore
  56081. * ID of the image processing post process;
  56082. */
  56083. readonly ImageProcessingPostProcessId: string;
  56084. /**
  56085. * @ignore
  56086. * ID of the Fast Approximate Anti-Aliasing post process;
  56087. */
  56088. readonly FxaaPostProcessId: string;
  56089. /**
  56090. * ID of the chromatic aberration post process,
  56091. */
  56092. private readonly ChromaticAberrationPostProcessId;
  56093. /**
  56094. * ID of the grain post process
  56095. */
  56096. private readonly GrainPostProcessId;
  56097. /**
  56098. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56099. */
  56100. sharpen: SharpenPostProcess;
  56101. private _sharpenEffect;
  56102. private bloom;
  56103. /**
  56104. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56105. */
  56106. depthOfField: DepthOfFieldEffect;
  56107. /**
  56108. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56109. */
  56110. fxaa: FxaaPostProcess;
  56111. /**
  56112. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56113. */
  56114. imageProcessing: ImageProcessingPostProcess;
  56115. /**
  56116. * Chromatic aberration post process which will shift rgb colors in the image
  56117. */
  56118. chromaticAberration: ChromaticAberrationPostProcess;
  56119. private _chromaticAberrationEffect;
  56120. /**
  56121. * Grain post process which add noise to the image
  56122. */
  56123. grain: GrainPostProcess;
  56124. private _grainEffect;
  56125. /**
  56126. * Glow post process which adds a glow to emissive areas of the image
  56127. */
  56128. private _glowLayer;
  56129. /**
  56130. * Animations which can be used to tweak settings over a period of time
  56131. */
  56132. animations: Animation[];
  56133. private _imageProcessingConfigurationObserver;
  56134. private _sharpenEnabled;
  56135. private _bloomEnabled;
  56136. private _depthOfFieldEnabled;
  56137. private _depthOfFieldBlurLevel;
  56138. private _fxaaEnabled;
  56139. private _imageProcessingEnabled;
  56140. private _defaultPipelineTextureType;
  56141. private _bloomScale;
  56142. private _chromaticAberrationEnabled;
  56143. private _grainEnabled;
  56144. private _buildAllowed;
  56145. /**
  56146. * Gets active scene
  56147. */
  56148. readonly scene: Scene;
  56149. /**
  56150. * Enable or disable the sharpen process from the pipeline
  56151. */
  56152. sharpenEnabled: boolean;
  56153. private _resizeObserver;
  56154. private _hardwareScaleLevel;
  56155. private _bloomKernel;
  56156. /**
  56157. * Specifies the size of the bloom blur kernel, relative to the final output size
  56158. */
  56159. bloomKernel: number;
  56160. /**
  56161. * Specifies the weight of the bloom in the final rendering
  56162. */
  56163. private _bloomWeight;
  56164. /**
  56165. * Specifies the luma threshold for the area that will be blurred by the bloom
  56166. */
  56167. private _bloomThreshold;
  56168. private _hdr;
  56169. /**
  56170. * The strength of the bloom.
  56171. */
  56172. bloomWeight: number;
  56173. /**
  56174. * The strength of the bloom.
  56175. */
  56176. bloomThreshold: number;
  56177. /**
  56178. * The scale of the bloom, lower value will provide better performance.
  56179. */
  56180. bloomScale: number;
  56181. /**
  56182. * Enable or disable the bloom from the pipeline
  56183. */
  56184. bloomEnabled: boolean;
  56185. private _rebuildBloom;
  56186. /**
  56187. * If the depth of field is enabled.
  56188. */
  56189. depthOfFieldEnabled: boolean;
  56190. /**
  56191. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56192. */
  56193. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56194. /**
  56195. * If the anti aliasing is enabled.
  56196. */
  56197. fxaaEnabled: boolean;
  56198. private _samples;
  56199. /**
  56200. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56201. */
  56202. samples: number;
  56203. /**
  56204. * If image processing is enabled.
  56205. */
  56206. imageProcessingEnabled: boolean;
  56207. /**
  56208. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56209. */
  56210. glowLayerEnabled: boolean;
  56211. /**
  56212. * Gets the glow layer (or null if not defined)
  56213. */
  56214. readonly glowLayer: Nullable<GlowLayer>;
  56215. /**
  56216. * Enable or disable the chromaticAberration process from the pipeline
  56217. */
  56218. chromaticAberrationEnabled: boolean;
  56219. /**
  56220. * Enable or disable the grain process from the pipeline
  56221. */
  56222. grainEnabled: boolean;
  56223. /**
  56224. * @constructor
  56225. * @param name - The rendering pipeline name (default: "")
  56226. * @param hdr - If high dynamic range textures should be used (default: true)
  56227. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56228. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56229. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56230. */
  56231. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56232. /**
  56233. * Get the class name
  56234. * @returns "DefaultRenderingPipeline"
  56235. */
  56236. getClassName(): string;
  56237. /**
  56238. * Force the compilation of the entire pipeline.
  56239. */
  56240. prepare(): void;
  56241. private _hasCleared;
  56242. private _prevPostProcess;
  56243. private _prevPrevPostProcess;
  56244. private _setAutoClearAndTextureSharing;
  56245. private _depthOfFieldSceneObserver;
  56246. private _buildPipeline;
  56247. private _disposePostProcesses;
  56248. /**
  56249. * Adds a camera to the pipeline
  56250. * @param camera the camera to be added
  56251. */
  56252. addCamera(camera: Camera): void;
  56253. /**
  56254. * Removes a camera from the pipeline
  56255. * @param camera the camera to remove
  56256. */
  56257. removeCamera(camera: Camera): void;
  56258. /**
  56259. * Dispose of the pipeline and stop all post processes
  56260. */
  56261. dispose(): void;
  56262. /**
  56263. * Serialize the rendering pipeline (Used when exporting)
  56264. * @returns the serialized object
  56265. */
  56266. serialize(): any;
  56267. /**
  56268. * Parse the serialized pipeline
  56269. * @param source Source pipeline.
  56270. * @param scene The scene to load the pipeline to.
  56271. * @param rootUrl The URL of the serialized pipeline.
  56272. * @returns An instantiated pipeline from the serialized object.
  56273. */
  56274. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56275. }
  56276. }
  56277. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  56278. /** @hidden */
  56279. export var lensHighlightsPixelShader: {
  56280. name: string;
  56281. shader: string;
  56282. };
  56283. }
  56284. declare module "babylonjs/Shaders/depthOfField.fragment" {
  56285. /** @hidden */
  56286. export var depthOfFieldPixelShader: {
  56287. name: string;
  56288. shader: string;
  56289. };
  56290. }
  56291. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  56292. import { Camera } from "babylonjs/Cameras/camera";
  56293. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56294. import { Scene } from "babylonjs/scene";
  56295. import "babylonjs/Shaders/chromaticAberration.fragment";
  56296. import "babylonjs/Shaders/lensHighlights.fragment";
  56297. import "babylonjs/Shaders/depthOfField.fragment";
  56298. /**
  56299. * BABYLON.JS Chromatic Aberration GLSL Shader
  56300. * Author: Olivier Guyot
  56301. * Separates very slightly R, G and B colors on the edges of the screen
  56302. * Inspired by Francois Tarlier & Martins Upitis
  56303. */
  56304. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56305. /**
  56306. * @ignore
  56307. * The chromatic aberration PostProcess id in the pipeline
  56308. */
  56309. LensChromaticAberrationEffect: string;
  56310. /**
  56311. * @ignore
  56312. * The highlights enhancing PostProcess id in the pipeline
  56313. */
  56314. HighlightsEnhancingEffect: string;
  56315. /**
  56316. * @ignore
  56317. * The depth-of-field PostProcess id in the pipeline
  56318. */
  56319. LensDepthOfFieldEffect: string;
  56320. private _scene;
  56321. private _depthTexture;
  56322. private _grainTexture;
  56323. private _chromaticAberrationPostProcess;
  56324. private _highlightsPostProcess;
  56325. private _depthOfFieldPostProcess;
  56326. private _edgeBlur;
  56327. private _grainAmount;
  56328. private _chromaticAberration;
  56329. private _distortion;
  56330. private _highlightsGain;
  56331. private _highlightsThreshold;
  56332. private _dofDistance;
  56333. private _dofAperture;
  56334. private _dofDarken;
  56335. private _dofPentagon;
  56336. private _blurNoise;
  56337. /**
  56338. * @constructor
  56339. *
  56340. * Effect parameters are as follow:
  56341. * {
  56342. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56343. * edge_blur: number; // from 0 to x (1 for realism)
  56344. * distortion: number; // from 0 to x (1 for realism)
  56345. * grain_amount: number; // from 0 to 1
  56346. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56347. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56348. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56349. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56350. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56351. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56352. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56353. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56354. * }
  56355. * Note: if an effect parameter is unset, effect is disabled
  56356. *
  56357. * @param name The rendering pipeline name
  56358. * @param parameters - An object containing all parameters (see above)
  56359. * @param scene The scene linked to this pipeline
  56360. * @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)
  56361. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56362. */
  56363. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56364. /**
  56365. * Get the class name
  56366. * @returns "LensRenderingPipeline"
  56367. */
  56368. getClassName(): string;
  56369. /**
  56370. * Gets associated scene
  56371. */
  56372. readonly scene: Scene;
  56373. /**
  56374. * Gets or sets the edge blur
  56375. */
  56376. edgeBlur: number;
  56377. /**
  56378. * Gets or sets the grain amount
  56379. */
  56380. grainAmount: number;
  56381. /**
  56382. * Gets or sets the chromatic aberration amount
  56383. */
  56384. chromaticAberration: number;
  56385. /**
  56386. * Gets or sets the depth of field aperture
  56387. */
  56388. dofAperture: number;
  56389. /**
  56390. * Gets or sets the edge distortion
  56391. */
  56392. edgeDistortion: number;
  56393. /**
  56394. * Gets or sets the depth of field distortion
  56395. */
  56396. dofDistortion: number;
  56397. /**
  56398. * Gets or sets the darken out of focus amount
  56399. */
  56400. darkenOutOfFocus: number;
  56401. /**
  56402. * Gets or sets a boolean indicating if blur noise is enabled
  56403. */
  56404. blurNoise: boolean;
  56405. /**
  56406. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56407. */
  56408. pentagonBokeh: boolean;
  56409. /**
  56410. * Gets or sets the highlight grain amount
  56411. */
  56412. highlightsGain: number;
  56413. /**
  56414. * Gets or sets the highlight threshold
  56415. */
  56416. highlightsThreshold: number;
  56417. /**
  56418. * Sets the amount of blur at the edges
  56419. * @param amount blur amount
  56420. */
  56421. setEdgeBlur(amount: number): void;
  56422. /**
  56423. * Sets edge blur to 0
  56424. */
  56425. disableEdgeBlur(): void;
  56426. /**
  56427. * Sets the amout of grain
  56428. * @param amount Amount of grain
  56429. */
  56430. setGrainAmount(amount: number): void;
  56431. /**
  56432. * Set grain amount to 0
  56433. */
  56434. disableGrain(): void;
  56435. /**
  56436. * Sets the chromatic aberration amount
  56437. * @param amount amount of chromatic aberration
  56438. */
  56439. setChromaticAberration(amount: number): void;
  56440. /**
  56441. * Sets chromatic aberration amount to 0
  56442. */
  56443. disableChromaticAberration(): void;
  56444. /**
  56445. * Sets the EdgeDistortion amount
  56446. * @param amount amount of EdgeDistortion
  56447. */
  56448. setEdgeDistortion(amount: number): void;
  56449. /**
  56450. * Sets edge distortion to 0
  56451. */
  56452. disableEdgeDistortion(): void;
  56453. /**
  56454. * Sets the FocusDistance amount
  56455. * @param amount amount of FocusDistance
  56456. */
  56457. setFocusDistance(amount: number): void;
  56458. /**
  56459. * Disables depth of field
  56460. */
  56461. disableDepthOfField(): void;
  56462. /**
  56463. * Sets the Aperture amount
  56464. * @param amount amount of Aperture
  56465. */
  56466. setAperture(amount: number): void;
  56467. /**
  56468. * Sets the DarkenOutOfFocus amount
  56469. * @param amount amount of DarkenOutOfFocus
  56470. */
  56471. setDarkenOutOfFocus(amount: number): void;
  56472. private _pentagonBokehIsEnabled;
  56473. /**
  56474. * Creates a pentagon bokeh effect
  56475. */
  56476. enablePentagonBokeh(): void;
  56477. /**
  56478. * Disables the pentagon bokeh effect
  56479. */
  56480. disablePentagonBokeh(): void;
  56481. /**
  56482. * Enables noise blur
  56483. */
  56484. enableNoiseBlur(): void;
  56485. /**
  56486. * Disables noise blur
  56487. */
  56488. disableNoiseBlur(): void;
  56489. /**
  56490. * Sets the HighlightsGain amount
  56491. * @param amount amount of HighlightsGain
  56492. */
  56493. setHighlightsGain(amount: number): void;
  56494. /**
  56495. * Sets the HighlightsThreshold amount
  56496. * @param amount amount of HighlightsThreshold
  56497. */
  56498. setHighlightsThreshold(amount: number): void;
  56499. /**
  56500. * Disables highlights
  56501. */
  56502. disableHighlights(): void;
  56503. /**
  56504. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56505. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56506. */
  56507. dispose(disableDepthRender?: boolean): void;
  56508. private _createChromaticAberrationPostProcess;
  56509. private _createHighlightsPostProcess;
  56510. private _createDepthOfFieldPostProcess;
  56511. private _createGrainTexture;
  56512. }
  56513. }
  56514. declare module "babylonjs/Shaders/ssao2.fragment" {
  56515. /** @hidden */
  56516. export var ssao2PixelShader: {
  56517. name: string;
  56518. shader: string;
  56519. };
  56520. }
  56521. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  56522. /** @hidden */
  56523. export var ssaoCombinePixelShader: {
  56524. name: string;
  56525. shader: string;
  56526. };
  56527. }
  56528. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56529. import { Camera } from "babylonjs/Cameras/camera";
  56530. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56531. import { Scene } from "babylonjs/scene";
  56532. import "babylonjs/Shaders/ssao2.fragment";
  56533. import "babylonjs/Shaders/ssaoCombine.fragment";
  56534. /**
  56535. * Render pipeline to produce ssao effect
  56536. */
  56537. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56538. /**
  56539. * @ignore
  56540. * The PassPostProcess id in the pipeline that contains the original scene color
  56541. */
  56542. SSAOOriginalSceneColorEffect: string;
  56543. /**
  56544. * @ignore
  56545. * The SSAO PostProcess id in the pipeline
  56546. */
  56547. SSAORenderEffect: string;
  56548. /**
  56549. * @ignore
  56550. * The horizontal blur PostProcess id in the pipeline
  56551. */
  56552. SSAOBlurHRenderEffect: string;
  56553. /**
  56554. * @ignore
  56555. * The vertical blur PostProcess id in the pipeline
  56556. */
  56557. SSAOBlurVRenderEffect: string;
  56558. /**
  56559. * @ignore
  56560. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56561. */
  56562. SSAOCombineRenderEffect: string;
  56563. /**
  56564. * The output strength of the SSAO post-process. Default value is 1.0.
  56565. */
  56566. totalStrength: number;
  56567. /**
  56568. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56569. */
  56570. maxZ: number;
  56571. /**
  56572. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56573. */
  56574. minZAspect: number;
  56575. private _samples;
  56576. /**
  56577. * Number of samples used for the SSAO calculations. Default value is 8
  56578. */
  56579. samples: number;
  56580. private _textureSamples;
  56581. /**
  56582. * Number of samples to use for antialiasing
  56583. */
  56584. textureSamples: number;
  56585. /**
  56586. * Ratio object used for SSAO ratio and blur ratio
  56587. */
  56588. private _ratio;
  56589. /**
  56590. * Dynamically generated sphere sampler.
  56591. */
  56592. private _sampleSphere;
  56593. /**
  56594. * Blur filter offsets
  56595. */
  56596. private _samplerOffsets;
  56597. private _expensiveBlur;
  56598. /**
  56599. * If bilateral blur should be used
  56600. */
  56601. expensiveBlur: boolean;
  56602. /**
  56603. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56604. */
  56605. radius: number;
  56606. /**
  56607. * The base color of the SSAO post-process
  56608. * The final result is "base + ssao" between [0, 1]
  56609. */
  56610. base: number;
  56611. /**
  56612. * Support test.
  56613. */
  56614. static readonly IsSupported: boolean;
  56615. private _scene;
  56616. private _depthTexture;
  56617. private _normalTexture;
  56618. private _randomTexture;
  56619. private _originalColorPostProcess;
  56620. private _ssaoPostProcess;
  56621. private _blurHPostProcess;
  56622. private _blurVPostProcess;
  56623. private _ssaoCombinePostProcess;
  56624. private _firstUpdate;
  56625. /**
  56626. * Gets active scene
  56627. */
  56628. readonly scene: Scene;
  56629. /**
  56630. * @constructor
  56631. * @param name The rendering pipeline name
  56632. * @param scene The scene linked to this pipeline
  56633. * @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 }
  56634. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56635. */
  56636. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56637. /**
  56638. * Get the class name
  56639. * @returns "SSAO2RenderingPipeline"
  56640. */
  56641. getClassName(): string;
  56642. /**
  56643. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56644. */
  56645. dispose(disableGeometryBufferRenderer?: boolean): void;
  56646. private _createBlurPostProcess;
  56647. /** @hidden */
  56648. _rebuild(): void;
  56649. private _bits;
  56650. private _radicalInverse_VdC;
  56651. private _hammersley;
  56652. private _hemisphereSample_uniform;
  56653. private _generateHemisphere;
  56654. private _createSSAOPostProcess;
  56655. private _createSSAOCombinePostProcess;
  56656. private _createRandomTexture;
  56657. /**
  56658. * Serialize the rendering pipeline (Used when exporting)
  56659. * @returns the serialized object
  56660. */
  56661. serialize(): any;
  56662. /**
  56663. * Parse the serialized pipeline
  56664. * @param source Source pipeline.
  56665. * @param scene The scene to load the pipeline to.
  56666. * @param rootUrl The URL of the serialized pipeline.
  56667. * @returns An instantiated pipeline from the serialized object.
  56668. */
  56669. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56670. }
  56671. }
  56672. declare module "babylonjs/Shaders/ssao.fragment" {
  56673. /** @hidden */
  56674. export var ssaoPixelShader: {
  56675. name: string;
  56676. shader: string;
  56677. };
  56678. }
  56679. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56680. import { Camera } from "babylonjs/Cameras/camera";
  56681. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56682. import { Scene } from "babylonjs/scene";
  56683. import "babylonjs/Shaders/ssao.fragment";
  56684. import "babylonjs/Shaders/ssaoCombine.fragment";
  56685. /**
  56686. * Render pipeline to produce ssao effect
  56687. */
  56688. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56689. /**
  56690. * @ignore
  56691. * The PassPostProcess id in the pipeline that contains the original scene color
  56692. */
  56693. SSAOOriginalSceneColorEffect: string;
  56694. /**
  56695. * @ignore
  56696. * The SSAO PostProcess id in the pipeline
  56697. */
  56698. SSAORenderEffect: string;
  56699. /**
  56700. * @ignore
  56701. * The horizontal blur PostProcess id in the pipeline
  56702. */
  56703. SSAOBlurHRenderEffect: string;
  56704. /**
  56705. * @ignore
  56706. * The vertical blur PostProcess id in the pipeline
  56707. */
  56708. SSAOBlurVRenderEffect: string;
  56709. /**
  56710. * @ignore
  56711. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56712. */
  56713. SSAOCombineRenderEffect: string;
  56714. /**
  56715. * The output strength of the SSAO post-process. Default value is 1.0.
  56716. */
  56717. totalStrength: number;
  56718. /**
  56719. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56720. */
  56721. radius: number;
  56722. /**
  56723. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56724. * Must not be equal to fallOff and superior to fallOff.
  56725. * Default value is 0.0075
  56726. */
  56727. area: number;
  56728. /**
  56729. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56730. * Must not be equal to area and inferior to area.
  56731. * Default value is 0.000001
  56732. */
  56733. fallOff: number;
  56734. /**
  56735. * The base color of the SSAO post-process
  56736. * The final result is "base + ssao" between [0, 1]
  56737. */
  56738. base: number;
  56739. private _scene;
  56740. private _depthTexture;
  56741. private _randomTexture;
  56742. private _originalColorPostProcess;
  56743. private _ssaoPostProcess;
  56744. private _blurHPostProcess;
  56745. private _blurVPostProcess;
  56746. private _ssaoCombinePostProcess;
  56747. private _firstUpdate;
  56748. /**
  56749. * Gets active scene
  56750. */
  56751. readonly scene: Scene;
  56752. /**
  56753. * @constructor
  56754. * @param name - The rendering pipeline name
  56755. * @param scene - The scene linked to this pipeline
  56756. * @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 }
  56757. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56758. */
  56759. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56760. /**
  56761. * Get the class name
  56762. * @returns "SSAORenderingPipeline"
  56763. */
  56764. getClassName(): string;
  56765. /**
  56766. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56767. */
  56768. dispose(disableDepthRender?: boolean): void;
  56769. private _createBlurPostProcess;
  56770. /** @hidden */
  56771. _rebuild(): void;
  56772. private _createSSAOPostProcess;
  56773. private _createSSAOCombinePostProcess;
  56774. private _createRandomTexture;
  56775. }
  56776. }
  56777. declare module "babylonjs/Shaders/standard.fragment" {
  56778. /** @hidden */
  56779. export var standardPixelShader: {
  56780. name: string;
  56781. shader: string;
  56782. };
  56783. }
  56784. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56785. import { Nullable } from "babylonjs/types";
  56786. import { IAnimatable } from "babylonjs/Misc/tools";
  56787. import { Camera } from "babylonjs/Cameras/camera";
  56788. import { Texture } from "babylonjs/Materials/Textures/texture";
  56789. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56790. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56791. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56792. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56793. import { IDisposable } from "babylonjs/scene";
  56794. import { SpotLight } from "babylonjs/Lights/spotLight";
  56795. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56796. import { Scene } from "babylonjs/scene";
  56797. import { Animation } from "babylonjs/Animations/animation";
  56798. import "babylonjs/Shaders/standard.fragment";
  56799. /**
  56800. * Standard rendering pipeline
  56801. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56802. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56803. */
  56804. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56805. /**
  56806. * Public members
  56807. */
  56808. /**
  56809. * Post-process which contains the original scene color before the pipeline applies all the effects
  56810. */
  56811. originalPostProcess: Nullable<PostProcess>;
  56812. /**
  56813. * Post-process used to down scale an image x4
  56814. */
  56815. downSampleX4PostProcess: Nullable<PostProcess>;
  56816. /**
  56817. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56818. */
  56819. brightPassPostProcess: Nullable<PostProcess>;
  56820. /**
  56821. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56822. */
  56823. blurHPostProcesses: PostProcess[];
  56824. /**
  56825. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56826. */
  56827. blurVPostProcesses: PostProcess[];
  56828. /**
  56829. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56830. */
  56831. textureAdderPostProcess: Nullable<PostProcess>;
  56832. /**
  56833. * Post-process used to create volumetric lighting effect
  56834. */
  56835. volumetricLightPostProcess: Nullable<PostProcess>;
  56836. /**
  56837. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56838. */
  56839. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56840. /**
  56841. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56842. */
  56843. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56844. /**
  56845. * Post-process used to merge the volumetric light effect and the real scene color
  56846. */
  56847. volumetricLightMergePostProces: Nullable<PostProcess>;
  56848. /**
  56849. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56850. */
  56851. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56852. /**
  56853. * Base post-process used to calculate the average luminance of the final image for HDR
  56854. */
  56855. luminancePostProcess: Nullable<PostProcess>;
  56856. /**
  56857. * Post-processes used to create down sample post-processes in order to get
  56858. * the average luminance of the final image for HDR
  56859. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56860. */
  56861. luminanceDownSamplePostProcesses: PostProcess[];
  56862. /**
  56863. * Post-process used to create a HDR effect (light adaptation)
  56864. */
  56865. hdrPostProcess: Nullable<PostProcess>;
  56866. /**
  56867. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56868. */
  56869. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56870. /**
  56871. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56872. */
  56873. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56874. /**
  56875. * Post-process used to merge the final HDR post-process and the real scene color
  56876. */
  56877. hdrFinalPostProcess: Nullable<PostProcess>;
  56878. /**
  56879. * Post-process used to create a lens flare effect
  56880. */
  56881. lensFlarePostProcess: Nullable<PostProcess>;
  56882. /**
  56883. * Post-process that merges the result of the lens flare post-process and the real scene color
  56884. */
  56885. lensFlareComposePostProcess: Nullable<PostProcess>;
  56886. /**
  56887. * Post-process used to create a motion blur effect
  56888. */
  56889. motionBlurPostProcess: Nullable<PostProcess>;
  56890. /**
  56891. * Post-process used to create a depth of field effect
  56892. */
  56893. depthOfFieldPostProcess: Nullable<PostProcess>;
  56894. /**
  56895. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56896. */
  56897. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56898. /**
  56899. * Represents the brightness threshold in order to configure the illuminated surfaces
  56900. */
  56901. brightThreshold: number;
  56902. /**
  56903. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56904. */
  56905. blurWidth: number;
  56906. /**
  56907. * Sets if the blur for highlighted surfaces must be only horizontal
  56908. */
  56909. horizontalBlur: boolean;
  56910. /**
  56911. * Gets the overall exposure used by the pipeline
  56912. */
  56913. /**
  56914. * Sets the overall exposure used by the pipeline
  56915. */
  56916. exposure: number;
  56917. /**
  56918. * Texture used typically to simulate "dirty" on camera lens
  56919. */
  56920. lensTexture: Nullable<Texture>;
  56921. /**
  56922. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56923. */
  56924. volumetricLightCoefficient: number;
  56925. /**
  56926. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56927. */
  56928. volumetricLightPower: number;
  56929. /**
  56930. * Used the set the blur intensity to smooth the volumetric lights
  56931. */
  56932. volumetricLightBlurScale: number;
  56933. /**
  56934. * Light (spot or directional) used to generate the volumetric lights rays
  56935. * The source light must have a shadow generate so the pipeline can get its
  56936. * depth map
  56937. */
  56938. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56939. /**
  56940. * For eye adaptation, represents the minimum luminance the eye can see
  56941. */
  56942. hdrMinimumLuminance: number;
  56943. /**
  56944. * For eye adaptation, represents the decrease luminance speed
  56945. */
  56946. hdrDecreaseRate: number;
  56947. /**
  56948. * For eye adaptation, represents the increase luminance speed
  56949. */
  56950. hdrIncreaseRate: number;
  56951. /**
  56952. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56953. */
  56954. /**
  56955. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56956. */
  56957. hdrAutoExposure: boolean;
  56958. /**
  56959. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56960. */
  56961. lensColorTexture: Nullable<Texture>;
  56962. /**
  56963. * The overall strengh for the lens flare effect
  56964. */
  56965. lensFlareStrength: number;
  56966. /**
  56967. * Dispersion coefficient for lens flare ghosts
  56968. */
  56969. lensFlareGhostDispersal: number;
  56970. /**
  56971. * Main lens flare halo width
  56972. */
  56973. lensFlareHaloWidth: number;
  56974. /**
  56975. * Based on the lens distortion effect, defines how much the lens flare result
  56976. * is distorted
  56977. */
  56978. lensFlareDistortionStrength: number;
  56979. /**
  56980. * Lens star texture must be used to simulate rays on the flares and is available
  56981. * in the documentation
  56982. */
  56983. lensStarTexture: Nullable<Texture>;
  56984. /**
  56985. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56986. * flare effect by taking account of the dirt texture
  56987. */
  56988. lensFlareDirtTexture: Nullable<Texture>;
  56989. /**
  56990. * Represents the focal length for the depth of field effect
  56991. */
  56992. depthOfFieldDistance: number;
  56993. /**
  56994. * Represents the blur intensity for the blurred part of the depth of field effect
  56995. */
  56996. depthOfFieldBlurWidth: number;
  56997. /**
  56998. * For motion blur, defines how much the image is blurred by the movement
  56999. */
  57000. motionStrength: number;
  57001. /**
  57002. * List of animations for the pipeline (IAnimatable implementation)
  57003. */
  57004. animations: Animation[];
  57005. /**
  57006. * Private members
  57007. */
  57008. private _scene;
  57009. private _currentDepthOfFieldSource;
  57010. private _basePostProcess;
  57011. private _fixedExposure;
  57012. private _currentExposure;
  57013. private _hdrAutoExposure;
  57014. private _hdrCurrentLuminance;
  57015. private _floatTextureType;
  57016. private _ratio;
  57017. private _bloomEnabled;
  57018. private _depthOfFieldEnabled;
  57019. private _vlsEnabled;
  57020. private _lensFlareEnabled;
  57021. private _hdrEnabled;
  57022. private _motionBlurEnabled;
  57023. private _fxaaEnabled;
  57024. private _motionBlurSamples;
  57025. private _volumetricLightStepsCount;
  57026. private _samples;
  57027. /**
  57028. * @ignore
  57029. * Specifies if the bloom pipeline is enabled
  57030. */
  57031. BloomEnabled: boolean;
  57032. /**
  57033. * @ignore
  57034. * Specifies if the depth of field pipeline is enabed
  57035. */
  57036. DepthOfFieldEnabled: boolean;
  57037. /**
  57038. * @ignore
  57039. * Specifies if the lens flare pipeline is enabed
  57040. */
  57041. LensFlareEnabled: boolean;
  57042. /**
  57043. * @ignore
  57044. * Specifies if the HDR pipeline is enabled
  57045. */
  57046. HDREnabled: boolean;
  57047. /**
  57048. * @ignore
  57049. * Specifies if the volumetric lights scattering effect is enabled
  57050. */
  57051. VLSEnabled: boolean;
  57052. /**
  57053. * @ignore
  57054. * Specifies if the motion blur effect is enabled
  57055. */
  57056. MotionBlurEnabled: boolean;
  57057. /**
  57058. * Specifies if anti-aliasing is enabled
  57059. */
  57060. fxaaEnabled: boolean;
  57061. /**
  57062. * Specifies the number of steps used to calculate the volumetric lights
  57063. * Typically in interval [50, 200]
  57064. */
  57065. volumetricLightStepsCount: number;
  57066. /**
  57067. * Specifies the number of samples used for the motion blur effect
  57068. * Typically in interval [16, 64]
  57069. */
  57070. motionBlurSamples: number;
  57071. /**
  57072. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57073. */
  57074. samples: number;
  57075. /**
  57076. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57077. * @constructor
  57078. * @param name The rendering pipeline name
  57079. * @param scene The scene linked to this pipeline
  57080. * @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)
  57081. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57082. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57083. */
  57084. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57085. private _buildPipeline;
  57086. private _createDownSampleX4PostProcess;
  57087. private _createBrightPassPostProcess;
  57088. private _createBlurPostProcesses;
  57089. private _createTextureAdderPostProcess;
  57090. private _createVolumetricLightPostProcess;
  57091. private _createLuminancePostProcesses;
  57092. private _createHdrPostProcess;
  57093. private _createLensFlarePostProcess;
  57094. private _createDepthOfFieldPostProcess;
  57095. private _createMotionBlurPostProcess;
  57096. private _getDepthTexture;
  57097. private _disposePostProcesses;
  57098. /**
  57099. * Dispose of the pipeline and stop all post processes
  57100. */
  57101. dispose(): void;
  57102. /**
  57103. * Serialize the rendering pipeline (Used when exporting)
  57104. * @returns the serialized object
  57105. */
  57106. serialize(): any;
  57107. /**
  57108. * Parse the serialized pipeline
  57109. * @param source Source pipeline.
  57110. * @param scene The scene to load the pipeline to.
  57111. * @param rootUrl The URL of the serialized pipeline.
  57112. * @returns An instantiated pipeline from the serialized object.
  57113. */
  57114. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57115. /**
  57116. * Luminance steps
  57117. */
  57118. static LuminanceSteps: number;
  57119. }
  57120. }
  57121. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  57122. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  57123. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  57124. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  57125. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  57126. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  57127. }
  57128. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  57129. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  57130. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57131. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  57132. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  57133. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  57134. }
  57135. declare module "babylonjs/Shaders/tonemap.fragment" {
  57136. /** @hidden */
  57137. export var tonemapPixelShader: {
  57138. name: string;
  57139. shader: string;
  57140. };
  57141. }
  57142. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  57143. import { Camera } from "babylonjs/Cameras/camera";
  57144. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57145. import "babylonjs/Shaders/tonemap.fragment";
  57146. import { Engine } from "babylonjs/Engines/engine";
  57147. /** Defines operator used for tonemapping */
  57148. export enum TonemappingOperator {
  57149. /** Hable */
  57150. Hable = 0,
  57151. /** Reinhard */
  57152. Reinhard = 1,
  57153. /** HejiDawson */
  57154. HejiDawson = 2,
  57155. /** Photographic */
  57156. Photographic = 3
  57157. }
  57158. /**
  57159. * Defines a post process to apply tone mapping
  57160. */
  57161. export class TonemapPostProcess extends PostProcess {
  57162. private _operator;
  57163. /** Defines the required exposure adjustement */
  57164. exposureAdjustment: number;
  57165. /**
  57166. * Creates a new TonemapPostProcess
  57167. * @param name defines the name of the postprocess
  57168. * @param _operator defines the operator to use
  57169. * @param exposureAdjustment defines the required exposure adjustement
  57170. * @param camera defines the camera to use (can be null)
  57171. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57172. * @param engine defines the hosting engine (can be ignore if camera is set)
  57173. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57174. */
  57175. constructor(name: string, _operator: TonemappingOperator,
  57176. /** Defines the required exposure adjustement */
  57177. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57178. }
  57179. }
  57180. declare module "babylonjs/Shaders/depth.vertex" {
  57181. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57182. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57183. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57184. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57185. /** @hidden */
  57186. export var depthVertexShader: {
  57187. name: string;
  57188. shader: string;
  57189. };
  57190. }
  57191. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  57192. /** @hidden */
  57193. export var volumetricLightScatteringPixelShader: {
  57194. name: string;
  57195. shader: string;
  57196. };
  57197. }
  57198. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  57199. /** @hidden */
  57200. export var volumetricLightScatteringPassPixelShader: {
  57201. name: string;
  57202. shader: string;
  57203. };
  57204. }
  57205. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  57206. import { Vector3 } from "babylonjs/Maths/math";
  57207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57208. import { Mesh } from "babylonjs/Meshes/mesh";
  57209. import { Camera } from "babylonjs/Cameras/camera";
  57210. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57211. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57212. import { Scene } from "babylonjs/scene";
  57213. import "babylonjs/Meshes/Builders/planeBuilder";
  57214. import "babylonjs/Shaders/depth.vertex";
  57215. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  57216. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  57217. import { Engine } from "babylonjs/Engines/engine";
  57218. /**
  57219. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57220. */
  57221. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57222. private _volumetricLightScatteringPass;
  57223. private _volumetricLightScatteringRTT;
  57224. private _viewPort;
  57225. private _screenCoordinates;
  57226. private _cachedDefines;
  57227. /**
  57228. * If not undefined, the mesh position is computed from the attached node position
  57229. */
  57230. attachedNode: {
  57231. position: Vector3;
  57232. };
  57233. /**
  57234. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57235. */
  57236. customMeshPosition: Vector3;
  57237. /**
  57238. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57239. */
  57240. useCustomMeshPosition: boolean;
  57241. /**
  57242. * If the post-process should inverse the light scattering direction
  57243. */
  57244. invert: boolean;
  57245. /**
  57246. * The internal mesh used by the post-process
  57247. */
  57248. mesh: Mesh;
  57249. /**
  57250. * @hidden
  57251. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57252. */
  57253. useDiffuseColor: boolean;
  57254. /**
  57255. * Array containing the excluded meshes not rendered in the internal pass
  57256. */
  57257. excludedMeshes: AbstractMesh[];
  57258. /**
  57259. * Controls the overall intensity of the post-process
  57260. */
  57261. exposure: number;
  57262. /**
  57263. * Dissipates each sample's contribution in range [0, 1]
  57264. */
  57265. decay: number;
  57266. /**
  57267. * Controls the overall intensity of each sample
  57268. */
  57269. weight: number;
  57270. /**
  57271. * Controls the density of each sample
  57272. */
  57273. density: number;
  57274. /**
  57275. * @constructor
  57276. * @param name The post-process name
  57277. * @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)
  57278. * @param camera The camera that the post-process will be attached to
  57279. * @param mesh The mesh used to create the light scattering
  57280. * @param samples The post-process quality, default 100
  57281. * @param samplingModeThe post-process filtering mode
  57282. * @param engine The babylon engine
  57283. * @param reusable If the post-process is reusable
  57284. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57285. */
  57286. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57287. /**
  57288. * Returns the string "VolumetricLightScatteringPostProcess"
  57289. * @returns "VolumetricLightScatteringPostProcess"
  57290. */
  57291. getClassName(): string;
  57292. private _isReady;
  57293. /**
  57294. * Sets the new light position for light scattering effect
  57295. * @param position The new custom light position
  57296. */
  57297. setCustomMeshPosition(position: Vector3): void;
  57298. /**
  57299. * Returns the light position for light scattering effect
  57300. * @return Vector3 The custom light position
  57301. */
  57302. getCustomMeshPosition(): Vector3;
  57303. /**
  57304. * Disposes the internal assets and detaches the post-process from the camera
  57305. */
  57306. dispose(camera: Camera): void;
  57307. /**
  57308. * Returns the render target texture used by the post-process
  57309. * @return the render target texture used by the post-process
  57310. */
  57311. getPass(): RenderTargetTexture;
  57312. private _meshExcluded;
  57313. private _createPass;
  57314. private _updateMeshScreenCoordinates;
  57315. /**
  57316. * Creates a default mesh for the Volumeric Light Scattering post-process
  57317. * @param name The mesh name
  57318. * @param scene The scene where to create the mesh
  57319. * @return the default mesh
  57320. */
  57321. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57322. }
  57323. }
  57324. declare module "babylonjs/PostProcesses/index" {
  57325. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  57326. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  57327. export * from "babylonjs/PostProcesses/bloomEffect";
  57328. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  57329. export * from "babylonjs/PostProcesses/blurPostProcess";
  57330. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  57331. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  57332. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  57333. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  57334. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57335. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  57336. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  57337. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  57338. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57339. export * from "babylonjs/PostProcesses/filterPostProcess";
  57340. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  57341. export * from "babylonjs/PostProcesses/grainPostProcess";
  57342. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  57343. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  57344. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  57345. export * from "babylonjs/PostProcesses/passPostProcess";
  57346. export * from "babylonjs/PostProcesses/postProcess";
  57347. export * from "babylonjs/PostProcesses/postProcessManager";
  57348. export * from "babylonjs/PostProcesses/refractionPostProcess";
  57349. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  57350. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  57351. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  57352. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  57353. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  57354. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  57355. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  57356. }
  57357. declare module "babylonjs/Probes/index" {
  57358. export * from "babylonjs/Probes/reflectionProbe";
  57359. }
  57360. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  57361. import { Scene } from "babylonjs/scene";
  57362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57363. import { Color3 } from "babylonjs/Maths/math";
  57364. import { SmartArray } from "babylonjs/Misc/smartArray";
  57365. import { ISceneComponent } from "babylonjs/sceneComponent";
  57366. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  57367. import "babylonjs/Meshes/Builders/boxBuilder";
  57368. import "babylonjs/Shaders/color.fragment";
  57369. import "babylonjs/Shaders/color.vertex";
  57370. module "babylonjs/scene" {
  57371. interface Scene {
  57372. /** @hidden (Backing field) */
  57373. _boundingBoxRenderer: BoundingBoxRenderer;
  57374. /** @hidden (Backing field) */
  57375. _forceShowBoundingBoxes: boolean;
  57376. /**
  57377. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57378. */
  57379. forceShowBoundingBoxes: boolean;
  57380. /**
  57381. * Gets the bounding box renderer associated with the scene
  57382. * @returns a BoundingBoxRenderer
  57383. */
  57384. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57385. }
  57386. }
  57387. module "babylonjs/Meshes/abstractMesh" {
  57388. interface AbstractMesh {
  57389. /** @hidden (Backing field) */
  57390. _showBoundingBox: boolean;
  57391. /**
  57392. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57393. */
  57394. showBoundingBox: boolean;
  57395. }
  57396. }
  57397. /**
  57398. * Component responsible of rendering the bounding box of the meshes in a scene.
  57399. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57400. */
  57401. export class BoundingBoxRenderer implements ISceneComponent {
  57402. /**
  57403. * The component name helpfull to identify the component in the list of scene components.
  57404. */
  57405. readonly name: string;
  57406. /**
  57407. * The scene the component belongs to.
  57408. */
  57409. scene: Scene;
  57410. /**
  57411. * Color of the bounding box lines placed in front of an object
  57412. */
  57413. frontColor: Color3;
  57414. /**
  57415. * Color of the bounding box lines placed behind an object
  57416. */
  57417. backColor: Color3;
  57418. /**
  57419. * Defines if the renderer should show the back lines or not
  57420. */
  57421. showBackLines: boolean;
  57422. /**
  57423. * @hidden
  57424. */
  57425. renderList: SmartArray<BoundingBox>;
  57426. private _colorShader;
  57427. private _vertexBuffers;
  57428. private _indexBuffer;
  57429. /**
  57430. * Instantiates a new bounding box renderer in a scene.
  57431. * @param scene the scene the renderer renders in
  57432. */
  57433. constructor(scene: Scene);
  57434. /**
  57435. * Registers the component in a given scene
  57436. */
  57437. register(): void;
  57438. private _evaluateSubMesh;
  57439. private _activeMesh;
  57440. private _prepareRessources;
  57441. private _createIndexBuffer;
  57442. /**
  57443. * Rebuilds the elements related to this component in case of
  57444. * context lost for instance.
  57445. */
  57446. rebuild(): void;
  57447. /**
  57448. * @hidden
  57449. */
  57450. reset(): void;
  57451. /**
  57452. * Render the bounding boxes of a specific rendering group
  57453. * @param renderingGroupId defines the rendering group to render
  57454. */
  57455. render(renderingGroupId: number): void;
  57456. /**
  57457. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57458. * @param mesh Define the mesh to render the occlusion bounding box for
  57459. */
  57460. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57461. /**
  57462. * Dispose and release the resources attached to this renderer.
  57463. */
  57464. dispose(): void;
  57465. }
  57466. }
  57467. declare module "babylonjs/Shaders/depth.fragment" {
  57468. /** @hidden */
  57469. export var depthPixelShader: {
  57470. name: string;
  57471. shader: string;
  57472. };
  57473. }
  57474. declare module "babylonjs/Rendering/depthRenderer" {
  57475. import { Nullable } from "babylonjs/types";
  57476. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57477. import { Scene } from "babylonjs/scene";
  57478. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57479. import { Camera } from "babylonjs/Cameras/camera";
  57480. import "babylonjs/Shaders/depth.fragment";
  57481. import "babylonjs/Shaders/depth.vertex";
  57482. /**
  57483. * This represents a depth renderer in Babylon.
  57484. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57485. */
  57486. export class DepthRenderer {
  57487. private _scene;
  57488. private _depthMap;
  57489. private _effect;
  57490. private _cachedDefines;
  57491. private _camera;
  57492. /**
  57493. * Specifiess that the depth renderer will only be used within
  57494. * the camera it is created for.
  57495. * This can help forcing its rendering during the camera processing.
  57496. */
  57497. useOnlyInActiveCamera: boolean;
  57498. /** @hidden */
  57499. static _SceneComponentInitialization: (scene: Scene) => void;
  57500. /**
  57501. * Instantiates a depth renderer
  57502. * @param scene The scene the renderer belongs to
  57503. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57504. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57505. */
  57506. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57507. /**
  57508. * Creates the depth rendering effect and checks if the effect is ready.
  57509. * @param subMesh The submesh to be used to render the depth map of
  57510. * @param useInstances If multiple world instances should be used
  57511. * @returns if the depth renderer is ready to render the depth map
  57512. */
  57513. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57514. /**
  57515. * Gets the texture which the depth map will be written to.
  57516. * @returns The depth map texture
  57517. */
  57518. getDepthMap(): RenderTargetTexture;
  57519. /**
  57520. * Disposes of the depth renderer.
  57521. */
  57522. dispose(): void;
  57523. }
  57524. }
  57525. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57526. import { Nullable } from "babylonjs/types";
  57527. import { Scene } from "babylonjs/scene";
  57528. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57529. import { Camera } from "babylonjs/Cameras/camera";
  57530. import { ISceneComponent } from "babylonjs/sceneComponent";
  57531. module "babylonjs/scene" {
  57532. interface Scene {
  57533. /** @hidden (Backing field) */
  57534. _depthRenderer: {
  57535. [id: string]: DepthRenderer;
  57536. };
  57537. /**
  57538. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57539. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57540. * @returns the created depth renderer
  57541. */
  57542. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57543. /**
  57544. * Disables a depth renderer for a given camera
  57545. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57546. */
  57547. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57548. }
  57549. }
  57550. /**
  57551. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57552. * in several rendering techniques.
  57553. */
  57554. export class DepthRendererSceneComponent implements ISceneComponent {
  57555. /**
  57556. * The component name helpfull to identify the component in the list of scene components.
  57557. */
  57558. readonly name: string;
  57559. /**
  57560. * The scene the component belongs to.
  57561. */
  57562. scene: Scene;
  57563. /**
  57564. * Creates a new instance of the component for the given scene
  57565. * @param scene Defines the scene to register the component in
  57566. */
  57567. constructor(scene: Scene);
  57568. /**
  57569. * Registers the component in a given scene
  57570. */
  57571. register(): void;
  57572. /**
  57573. * Rebuilds the elements related to this component in case of
  57574. * context lost for instance.
  57575. */
  57576. rebuild(): void;
  57577. /**
  57578. * Disposes the component and the associated ressources
  57579. */
  57580. dispose(): void;
  57581. private _gatherRenderTargets;
  57582. private _gatherActiveCameraRenderTargets;
  57583. }
  57584. }
  57585. declare module "babylonjs/Shaders/outline.fragment" {
  57586. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57587. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57588. /** @hidden */
  57589. export var outlinePixelShader: {
  57590. name: string;
  57591. shader: string;
  57592. };
  57593. }
  57594. declare module "babylonjs/Shaders/outline.vertex" {
  57595. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57596. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57597. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57598. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57599. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57600. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57601. /** @hidden */
  57602. export var outlineVertexShader: {
  57603. name: string;
  57604. shader: string;
  57605. };
  57606. }
  57607. declare module "babylonjs/Rendering/outlineRenderer" {
  57608. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57609. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57610. import { Scene } from "babylonjs/scene";
  57611. import { ISceneComponent } from "babylonjs/sceneComponent";
  57612. import "babylonjs/Shaders/outline.fragment";
  57613. import "babylonjs/Shaders/outline.vertex";
  57614. module "babylonjs/scene" {
  57615. interface Scene {
  57616. /** @hidden */
  57617. _outlineRenderer: OutlineRenderer;
  57618. /**
  57619. * Gets the outline renderer associated with the scene
  57620. * @returns a OutlineRenderer
  57621. */
  57622. getOutlineRenderer(): OutlineRenderer;
  57623. }
  57624. }
  57625. module "babylonjs/Meshes/abstractMesh" {
  57626. interface AbstractMesh {
  57627. /** @hidden (Backing field) */
  57628. _renderOutline: boolean;
  57629. /**
  57630. * Gets or sets a boolean indicating if the outline must be rendered as well
  57631. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57632. */
  57633. renderOutline: boolean;
  57634. /** @hidden (Backing field) */
  57635. _renderOverlay: boolean;
  57636. /**
  57637. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57638. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57639. */
  57640. renderOverlay: boolean;
  57641. }
  57642. }
  57643. /**
  57644. * This class is responsible to draw bothe outline/overlay of meshes.
  57645. * It should not be used directly but through the available method on mesh.
  57646. */
  57647. export class OutlineRenderer implements ISceneComponent {
  57648. /**
  57649. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57650. */
  57651. private static _StencilReference;
  57652. /**
  57653. * The name of the component. Each component must have a unique name.
  57654. */
  57655. name: string;
  57656. /**
  57657. * The scene the component belongs to.
  57658. */
  57659. scene: Scene;
  57660. /**
  57661. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57662. */
  57663. zOffset: number;
  57664. private _engine;
  57665. private _effect;
  57666. private _cachedDefines;
  57667. private _savedDepthWrite;
  57668. /**
  57669. * Instantiates a new outline renderer. (There could be only one per scene).
  57670. * @param scene Defines the scene it belongs to
  57671. */
  57672. constructor(scene: Scene);
  57673. /**
  57674. * Register the component to one instance of a scene.
  57675. */
  57676. register(): void;
  57677. /**
  57678. * Rebuilds the elements related to this component in case of
  57679. * context lost for instance.
  57680. */
  57681. rebuild(): void;
  57682. /**
  57683. * Disposes the component and the associated ressources.
  57684. */
  57685. dispose(): void;
  57686. /**
  57687. * Renders the outline in the canvas.
  57688. * @param subMesh Defines the sumesh to render
  57689. * @param batch Defines the batch of meshes in case of instances
  57690. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57691. */
  57692. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57693. /**
  57694. * Returns whether or not the outline renderer is ready for a given submesh.
  57695. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57696. * @param subMesh Defines the submesh to check readyness for
  57697. * @param useInstances Defines wheter wee are trying to render instances or not
  57698. * @returns true if ready otherwise false
  57699. */
  57700. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57701. private _beforeRenderingMesh;
  57702. private _afterRenderingMesh;
  57703. }
  57704. }
  57705. declare module "babylonjs/Rendering/index" {
  57706. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57707. export * from "babylonjs/Rendering/depthRenderer";
  57708. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57709. export * from "babylonjs/Rendering/edgesRenderer";
  57710. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57711. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57712. export * from "babylonjs/Rendering/outlineRenderer";
  57713. export * from "babylonjs/Rendering/renderingGroup";
  57714. export * from "babylonjs/Rendering/renderingManager";
  57715. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57716. }
  57717. declare module "babylonjs/Sprites/index" {
  57718. export * from "babylonjs/Sprites/sprite";
  57719. export * from "babylonjs/Sprites/spriteManager";
  57720. export * from "babylonjs/Sprites/spriteSceneComponent";
  57721. }
  57722. declare module "babylonjs/Misc/assetsManager" {
  57723. import { Scene } from "babylonjs/scene";
  57724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57725. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57726. import { Skeleton } from "babylonjs/Bones/skeleton";
  57727. import { Observable } from "babylonjs/Misc/observable";
  57728. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57729. import { Texture } from "babylonjs/Materials/Textures/texture";
  57730. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57731. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57732. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57733. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57734. /**
  57735. * Defines the list of states available for a task inside a AssetsManager
  57736. */
  57737. export enum AssetTaskState {
  57738. /**
  57739. * Initialization
  57740. */
  57741. INIT = 0,
  57742. /**
  57743. * Running
  57744. */
  57745. RUNNING = 1,
  57746. /**
  57747. * Done
  57748. */
  57749. DONE = 2,
  57750. /**
  57751. * Error
  57752. */
  57753. ERROR = 3
  57754. }
  57755. /**
  57756. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57757. */
  57758. export abstract class AbstractAssetTask {
  57759. /**
  57760. * Task name
  57761. */ name: string;
  57762. /**
  57763. * Callback called when the task is successful
  57764. */
  57765. onSuccess: (task: any) => void;
  57766. /**
  57767. * Callback called when the task is not successful
  57768. */
  57769. onError: (task: any, message?: string, exception?: any) => void;
  57770. /**
  57771. * Creates a new AssetsManager
  57772. * @param name defines the name of the task
  57773. */
  57774. constructor(
  57775. /**
  57776. * Task name
  57777. */ name: string);
  57778. private _isCompleted;
  57779. private _taskState;
  57780. private _errorObject;
  57781. /**
  57782. * Get if the task is completed
  57783. */
  57784. readonly isCompleted: boolean;
  57785. /**
  57786. * Gets the current state of the task
  57787. */
  57788. readonly taskState: AssetTaskState;
  57789. /**
  57790. * Gets the current error object (if task is in error)
  57791. */
  57792. readonly errorObject: {
  57793. message?: string;
  57794. exception?: any;
  57795. };
  57796. /**
  57797. * Internal only
  57798. * @hidden
  57799. */
  57800. _setErrorObject(message?: string, exception?: any): void;
  57801. /**
  57802. * Execute the current task
  57803. * @param scene defines the scene where you want your assets to be loaded
  57804. * @param onSuccess is a callback called when the task is successfully executed
  57805. * @param onError is a callback called if an error occurs
  57806. */
  57807. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57808. /**
  57809. * Execute the current task
  57810. * @param scene defines the scene where you want your assets to be loaded
  57811. * @param onSuccess is a callback called when the task is successfully executed
  57812. * @param onError is a callback called if an error occurs
  57813. */
  57814. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57815. /**
  57816. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57817. * This can be used with failed tasks that have the reason for failure fixed.
  57818. */
  57819. reset(): void;
  57820. private onErrorCallback;
  57821. private onDoneCallback;
  57822. }
  57823. /**
  57824. * Define the interface used by progress events raised during assets loading
  57825. */
  57826. export interface IAssetsProgressEvent {
  57827. /**
  57828. * Defines the number of remaining tasks to process
  57829. */
  57830. remainingCount: number;
  57831. /**
  57832. * Defines the total number of tasks
  57833. */
  57834. totalCount: number;
  57835. /**
  57836. * Defines the task that was just processed
  57837. */
  57838. task: AbstractAssetTask;
  57839. }
  57840. /**
  57841. * Class used to share progress information about assets loading
  57842. */
  57843. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57844. /**
  57845. * Defines the number of remaining tasks to process
  57846. */
  57847. remainingCount: number;
  57848. /**
  57849. * Defines the total number of tasks
  57850. */
  57851. totalCount: number;
  57852. /**
  57853. * Defines the task that was just processed
  57854. */
  57855. task: AbstractAssetTask;
  57856. /**
  57857. * Creates a AssetsProgressEvent
  57858. * @param remainingCount defines the number of remaining tasks to process
  57859. * @param totalCount defines the total number of tasks
  57860. * @param task defines the task that was just processed
  57861. */
  57862. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57863. }
  57864. /**
  57865. * Define a task used by AssetsManager to load meshes
  57866. */
  57867. export class MeshAssetTask extends AbstractAssetTask {
  57868. /**
  57869. * Defines the name of the task
  57870. */
  57871. name: string;
  57872. /**
  57873. * Defines the list of mesh's names you want to load
  57874. */
  57875. meshesNames: any;
  57876. /**
  57877. * Defines the root url to use as a base to load your meshes and associated resources
  57878. */
  57879. rootUrl: string;
  57880. /**
  57881. * Defines the filename of the scene to load from
  57882. */
  57883. sceneFilename: string;
  57884. /**
  57885. * Gets the list of loaded meshes
  57886. */
  57887. loadedMeshes: Array<AbstractMesh>;
  57888. /**
  57889. * Gets the list of loaded particle systems
  57890. */
  57891. loadedParticleSystems: Array<IParticleSystem>;
  57892. /**
  57893. * Gets the list of loaded skeletons
  57894. */
  57895. loadedSkeletons: Array<Skeleton>;
  57896. /**
  57897. * Gets the list of loaded animation groups
  57898. */
  57899. loadedAnimationGroups: Array<AnimationGroup>;
  57900. /**
  57901. * Callback called when the task is successful
  57902. */
  57903. onSuccess: (task: MeshAssetTask) => void;
  57904. /**
  57905. * Callback called when the task is successful
  57906. */
  57907. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57908. /**
  57909. * Creates a new MeshAssetTask
  57910. * @param name defines the name of the task
  57911. * @param meshesNames defines the list of mesh's names you want to load
  57912. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57913. * @param sceneFilename defines the filename of the scene to load from
  57914. */
  57915. constructor(
  57916. /**
  57917. * Defines the name of the task
  57918. */
  57919. name: string,
  57920. /**
  57921. * Defines the list of mesh's names you want to load
  57922. */
  57923. meshesNames: any,
  57924. /**
  57925. * Defines the root url to use as a base to load your meshes and associated resources
  57926. */
  57927. rootUrl: string,
  57928. /**
  57929. * Defines the filename of the scene to load from
  57930. */
  57931. sceneFilename: string);
  57932. /**
  57933. * Execute the current task
  57934. * @param scene defines the scene where you want your assets to be loaded
  57935. * @param onSuccess is a callback called when the task is successfully executed
  57936. * @param onError is a callback called if an error occurs
  57937. */
  57938. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57939. }
  57940. /**
  57941. * Define a task used by AssetsManager to load text content
  57942. */
  57943. export class TextFileAssetTask extends AbstractAssetTask {
  57944. /**
  57945. * Defines the name of the task
  57946. */
  57947. name: string;
  57948. /**
  57949. * Defines the location of the file to load
  57950. */
  57951. url: string;
  57952. /**
  57953. * Gets the loaded text string
  57954. */
  57955. text: string;
  57956. /**
  57957. * Callback called when the task is successful
  57958. */
  57959. onSuccess: (task: TextFileAssetTask) => void;
  57960. /**
  57961. * Callback called when the task is successful
  57962. */
  57963. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57964. /**
  57965. * Creates a new TextFileAssetTask object
  57966. * @param name defines the name of the task
  57967. * @param url defines the location of the file to load
  57968. */
  57969. constructor(
  57970. /**
  57971. * Defines the name of the task
  57972. */
  57973. name: string,
  57974. /**
  57975. * Defines the location of the file to load
  57976. */
  57977. url: string);
  57978. /**
  57979. * Execute the current task
  57980. * @param scene defines the scene where you want your assets to be loaded
  57981. * @param onSuccess is a callback called when the task is successfully executed
  57982. * @param onError is a callback called if an error occurs
  57983. */
  57984. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57985. }
  57986. /**
  57987. * Define a task used by AssetsManager to load binary data
  57988. */
  57989. export class BinaryFileAssetTask extends AbstractAssetTask {
  57990. /**
  57991. * Defines the name of the task
  57992. */
  57993. name: string;
  57994. /**
  57995. * Defines the location of the file to load
  57996. */
  57997. url: string;
  57998. /**
  57999. * Gets the lodaded data (as an array buffer)
  58000. */
  58001. data: ArrayBuffer;
  58002. /**
  58003. * Callback called when the task is successful
  58004. */
  58005. onSuccess: (task: BinaryFileAssetTask) => void;
  58006. /**
  58007. * Callback called when the task is successful
  58008. */
  58009. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58010. /**
  58011. * Creates a new BinaryFileAssetTask object
  58012. * @param name defines the name of the new task
  58013. * @param url defines the location of the file to load
  58014. */
  58015. constructor(
  58016. /**
  58017. * Defines the name of the task
  58018. */
  58019. name: string,
  58020. /**
  58021. * Defines the location of the file to load
  58022. */
  58023. url: string);
  58024. /**
  58025. * Execute the current task
  58026. * @param scene defines the scene where you want your assets to be loaded
  58027. * @param onSuccess is a callback called when the task is successfully executed
  58028. * @param onError is a callback called if an error occurs
  58029. */
  58030. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58031. }
  58032. /**
  58033. * Define a task used by AssetsManager to load images
  58034. */
  58035. export class ImageAssetTask extends AbstractAssetTask {
  58036. /**
  58037. * Defines the name of the task
  58038. */
  58039. name: string;
  58040. /**
  58041. * Defines the location of the image to load
  58042. */
  58043. url: string;
  58044. /**
  58045. * Gets the loaded images
  58046. */
  58047. image: HTMLImageElement;
  58048. /**
  58049. * Callback called when the task is successful
  58050. */
  58051. onSuccess: (task: ImageAssetTask) => void;
  58052. /**
  58053. * Callback called when the task is successful
  58054. */
  58055. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58056. /**
  58057. * Creates a new ImageAssetTask
  58058. * @param name defines the name of the task
  58059. * @param url defines the location of the image to load
  58060. */
  58061. constructor(
  58062. /**
  58063. * Defines the name of the task
  58064. */
  58065. name: string,
  58066. /**
  58067. * Defines the location of the image to load
  58068. */
  58069. url: string);
  58070. /**
  58071. * Execute the current task
  58072. * @param scene defines the scene where you want your assets to be loaded
  58073. * @param onSuccess is a callback called when the task is successfully executed
  58074. * @param onError is a callback called if an error occurs
  58075. */
  58076. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58077. }
  58078. /**
  58079. * Defines the interface used by texture loading tasks
  58080. */
  58081. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58082. /**
  58083. * Gets the loaded texture
  58084. */
  58085. texture: TEX;
  58086. }
  58087. /**
  58088. * Define a task used by AssetsManager to load 2D textures
  58089. */
  58090. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58091. /**
  58092. * Defines the name of the task
  58093. */
  58094. name: string;
  58095. /**
  58096. * Defines the location of the file to load
  58097. */
  58098. url: string;
  58099. /**
  58100. * Defines if mipmap should not be generated (default is false)
  58101. */
  58102. noMipmap?: boolean | undefined;
  58103. /**
  58104. * Defines if texture must be inverted on Y axis (default is false)
  58105. */
  58106. invertY?: boolean | undefined;
  58107. /**
  58108. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58109. */
  58110. samplingMode: number;
  58111. /**
  58112. * Gets the loaded texture
  58113. */
  58114. texture: Texture;
  58115. /**
  58116. * Callback called when the task is successful
  58117. */
  58118. onSuccess: (task: TextureAssetTask) => void;
  58119. /**
  58120. * Callback called when the task is successful
  58121. */
  58122. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58123. /**
  58124. * Creates a new TextureAssetTask object
  58125. * @param name defines the name of the task
  58126. * @param url defines the location of the file to load
  58127. * @param noMipmap defines if mipmap should not be generated (default is false)
  58128. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58129. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58130. */
  58131. constructor(
  58132. /**
  58133. * Defines the name of the task
  58134. */
  58135. name: string,
  58136. /**
  58137. * Defines the location of the file to load
  58138. */
  58139. url: string,
  58140. /**
  58141. * Defines if mipmap should not be generated (default is false)
  58142. */
  58143. noMipmap?: boolean | undefined,
  58144. /**
  58145. * Defines if texture must be inverted on Y axis (default is false)
  58146. */
  58147. invertY?: boolean | undefined,
  58148. /**
  58149. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58150. */
  58151. samplingMode?: number);
  58152. /**
  58153. * Execute the current task
  58154. * @param scene defines the scene where you want your assets to be loaded
  58155. * @param onSuccess is a callback called when the task is successfully executed
  58156. * @param onError is a callback called if an error occurs
  58157. */
  58158. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58159. }
  58160. /**
  58161. * Define a task used by AssetsManager to load cube textures
  58162. */
  58163. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58164. /**
  58165. * Defines the name of the task
  58166. */
  58167. name: string;
  58168. /**
  58169. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58170. */
  58171. url: string;
  58172. /**
  58173. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58174. */
  58175. extensions?: string[] | undefined;
  58176. /**
  58177. * Defines if mipmaps should not be generated (default is false)
  58178. */
  58179. noMipmap?: boolean | undefined;
  58180. /**
  58181. * Defines the explicit list of files (undefined by default)
  58182. */
  58183. files?: string[] | undefined;
  58184. /**
  58185. * Gets the loaded texture
  58186. */
  58187. texture: CubeTexture;
  58188. /**
  58189. * Callback called when the task is successful
  58190. */
  58191. onSuccess: (task: CubeTextureAssetTask) => void;
  58192. /**
  58193. * Callback called when the task is successful
  58194. */
  58195. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58196. /**
  58197. * Creates a new CubeTextureAssetTask
  58198. * @param name defines the name of the task
  58199. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58200. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58201. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58202. * @param files defines the explicit list of files (undefined by default)
  58203. */
  58204. constructor(
  58205. /**
  58206. * Defines the name of the task
  58207. */
  58208. name: string,
  58209. /**
  58210. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58211. */
  58212. url: string,
  58213. /**
  58214. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58215. */
  58216. extensions?: string[] | undefined,
  58217. /**
  58218. * Defines if mipmaps should not be generated (default is false)
  58219. */
  58220. noMipmap?: boolean | undefined,
  58221. /**
  58222. * Defines the explicit list of files (undefined by default)
  58223. */
  58224. files?: string[] | undefined);
  58225. /**
  58226. * Execute the current task
  58227. * @param scene defines the scene where you want your assets to be loaded
  58228. * @param onSuccess is a callback called when the task is successfully executed
  58229. * @param onError is a callback called if an error occurs
  58230. */
  58231. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58232. }
  58233. /**
  58234. * Define a task used by AssetsManager to load HDR cube textures
  58235. */
  58236. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58237. /**
  58238. * Defines the name of the task
  58239. */
  58240. name: string;
  58241. /**
  58242. * Defines the location of the file to load
  58243. */
  58244. url: string;
  58245. /**
  58246. * Defines the desired size (the more it increases the longer the generation will be)
  58247. */
  58248. size: number;
  58249. /**
  58250. * Defines if mipmaps should not be generated (default is false)
  58251. */
  58252. noMipmap: boolean;
  58253. /**
  58254. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58255. */
  58256. generateHarmonics: boolean;
  58257. /**
  58258. * 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)
  58259. */
  58260. gammaSpace: boolean;
  58261. /**
  58262. * Internal Use Only
  58263. */
  58264. reserved: boolean;
  58265. /**
  58266. * Gets the loaded texture
  58267. */
  58268. texture: HDRCubeTexture;
  58269. /**
  58270. * Callback called when the task is successful
  58271. */
  58272. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58273. /**
  58274. * Callback called when the task is successful
  58275. */
  58276. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58277. /**
  58278. * Creates a new HDRCubeTextureAssetTask object
  58279. * @param name defines the name of the task
  58280. * @param url defines the location of the file to load
  58281. * @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.
  58282. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58283. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58284. * @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)
  58285. * @param reserved Internal use only
  58286. */
  58287. constructor(
  58288. /**
  58289. * Defines the name of the task
  58290. */
  58291. name: string,
  58292. /**
  58293. * Defines the location of the file to load
  58294. */
  58295. url: string,
  58296. /**
  58297. * Defines the desired size (the more it increases the longer the generation will be)
  58298. */
  58299. size: number,
  58300. /**
  58301. * Defines if mipmaps should not be generated (default is false)
  58302. */
  58303. noMipmap?: boolean,
  58304. /**
  58305. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58306. */
  58307. generateHarmonics?: boolean,
  58308. /**
  58309. * 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)
  58310. */
  58311. gammaSpace?: boolean,
  58312. /**
  58313. * Internal Use Only
  58314. */
  58315. reserved?: boolean);
  58316. /**
  58317. * Execute the current task
  58318. * @param scene defines the scene where you want your assets to be loaded
  58319. * @param onSuccess is a callback called when the task is successfully executed
  58320. * @param onError is a callback called if an error occurs
  58321. */
  58322. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58323. }
  58324. /**
  58325. * Define a task used by AssetsManager to load Equirectangular cube textures
  58326. */
  58327. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58328. /**
  58329. * Defines the name of the task
  58330. */
  58331. name: string;
  58332. /**
  58333. * Defines the location of the file to load
  58334. */
  58335. url: string;
  58336. /**
  58337. * Defines the desired size (the more it increases the longer the generation will be)
  58338. */
  58339. size: number;
  58340. /**
  58341. * Defines if mipmaps should not be generated (default is false)
  58342. */
  58343. noMipmap: boolean;
  58344. /**
  58345. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58346. * but the standard material would require them in Gamma space) (default is true)
  58347. */
  58348. gammaSpace: boolean;
  58349. /**
  58350. * Gets the loaded texture
  58351. */
  58352. texture: EquiRectangularCubeTexture;
  58353. /**
  58354. * Callback called when the task is successful
  58355. */
  58356. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58357. /**
  58358. * Callback called when the task is successful
  58359. */
  58360. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58361. /**
  58362. * Creates a new EquiRectangularCubeTextureAssetTask object
  58363. * @param name defines the name of the task
  58364. * @param url defines the location of the file to load
  58365. * @param size defines the desired size (the more it increases the longer the generation will be)
  58366. * If the size is omitted this implies you are using a preprocessed cubemap.
  58367. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58368. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58369. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58370. * (default is true)
  58371. */
  58372. constructor(
  58373. /**
  58374. * Defines the name of the task
  58375. */
  58376. name: string,
  58377. /**
  58378. * Defines the location of the file to load
  58379. */
  58380. url: string,
  58381. /**
  58382. * Defines the desired size (the more it increases the longer the generation will be)
  58383. */
  58384. size: number,
  58385. /**
  58386. * Defines if mipmaps should not be generated (default is false)
  58387. */
  58388. noMipmap?: boolean,
  58389. /**
  58390. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58391. * but the standard material would require them in Gamma space) (default is true)
  58392. */
  58393. gammaSpace?: boolean);
  58394. /**
  58395. * Execute the current task
  58396. * @param scene defines the scene where you want your assets to be loaded
  58397. * @param onSuccess is a callback called when the task is successfully executed
  58398. * @param onError is a callback called if an error occurs
  58399. */
  58400. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58401. }
  58402. /**
  58403. * This class can be used to easily import assets into a scene
  58404. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58405. */
  58406. export class AssetsManager {
  58407. private _scene;
  58408. private _isLoading;
  58409. protected _tasks: AbstractAssetTask[];
  58410. protected _waitingTasksCount: number;
  58411. protected _totalTasksCount: number;
  58412. /**
  58413. * Callback called when all tasks are processed
  58414. */
  58415. onFinish: (tasks: AbstractAssetTask[]) => void;
  58416. /**
  58417. * Callback called when a task is successful
  58418. */
  58419. onTaskSuccess: (task: AbstractAssetTask) => void;
  58420. /**
  58421. * Callback called when a task had an error
  58422. */
  58423. onTaskError: (task: AbstractAssetTask) => void;
  58424. /**
  58425. * Callback called when a task is done (whatever the result is)
  58426. */
  58427. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58428. /**
  58429. * Observable called when all tasks are processed
  58430. */
  58431. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58432. /**
  58433. * Observable called when a task had an error
  58434. */
  58435. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58436. /**
  58437. * Observable called when all tasks were executed
  58438. */
  58439. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58440. /**
  58441. * Observable called when a task is done (whatever the result is)
  58442. */
  58443. onProgressObservable: Observable<IAssetsProgressEvent>;
  58444. /**
  58445. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58446. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58447. */
  58448. useDefaultLoadingScreen: boolean;
  58449. /**
  58450. * Creates a new AssetsManager
  58451. * @param scene defines the scene to work on
  58452. */
  58453. constructor(scene: Scene);
  58454. /**
  58455. * Add a MeshAssetTask to the list of active tasks
  58456. * @param taskName defines the name of the new task
  58457. * @param meshesNames defines the name of meshes to load
  58458. * @param rootUrl defines the root url to use to locate files
  58459. * @param sceneFilename defines the filename of the scene file
  58460. * @returns a new MeshAssetTask object
  58461. */
  58462. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58463. /**
  58464. * Add a TextFileAssetTask to the list of active tasks
  58465. * @param taskName defines the name of the new task
  58466. * @param url defines the url of the file to load
  58467. * @returns a new TextFileAssetTask object
  58468. */
  58469. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58470. /**
  58471. * Add a BinaryFileAssetTask to the list of active tasks
  58472. * @param taskName defines the name of the new task
  58473. * @param url defines the url of the file to load
  58474. * @returns a new BinaryFileAssetTask object
  58475. */
  58476. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58477. /**
  58478. * Add a ImageAssetTask to the list of active tasks
  58479. * @param taskName defines the name of the new task
  58480. * @param url defines the url of the file to load
  58481. * @returns a new ImageAssetTask object
  58482. */
  58483. addImageTask(taskName: string, url: string): ImageAssetTask;
  58484. /**
  58485. * Add a TextureAssetTask to the list of active tasks
  58486. * @param taskName defines the name of the new task
  58487. * @param url defines the url of the file to load
  58488. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58489. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58490. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58491. * @returns a new TextureAssetTask object
  58492. */
  58493. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58494. /**
  58495. * Add a CubeTextureAssetTask to the list of active tasks
  58496. * @param taskName defines the name of the new task
  58497. * @param url defines the url of the file to load
  58498. * @param extensions defines the extension to use to load the cube map (can be null)
  58499. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58500. * @param files defines the list of files to load (can be null)
  58501. * @returns a new CubeTextureAssetTask object
  58502. */
  58503. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58504. /**
  58505. *
  58506. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58507. * @param taskName defines the name of the new task
  58508. * @param url defines the url of the file to load
  58509. * @param size defines the size you want for the cubemap (can be null)
  58510. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58511. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58512. * @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)
  58513. * @param reserved Internal use only
  58514. * @returns a new HDRCubeTextureAssetTask object
  58515. */
  58516. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58517. /**
  58518. *
  58519. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58520. * @param taskName defines the name of the new task
  58521. * @param url defines the url of the file to load
  58522. * @param size defines the size you want for the cubemap (can be null)
  58523. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58524. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58525. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58526. * @returns a new EquiRectangularCubeTextureAssetTask object
  58527. */
  58528. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58529. /**
  58530. * Remove a task from the assets manager.
  58531. * @param task the task to remove
  58532. */
  58533. removeTask(task: AbstractAssetTask): void;
  58534. private _decreaseWaitingTasksCount;
  58535. private _runTask;
  58536. /**
  58537. * Reset the AssetsManager and remove all tasks
  58538. * @return the current instance of the AssetsManager
  58539. */
  58540. reset(): AssetsManager;
  58541. /**
  58542. * Start the loading process
  58543. * @return the current instance of the AssetsManager
  58544. */
  58545. load(): AssetsManager;
  58546. /**
  58547. * Start the loading process as an async operation
  58548. * @return a promise returning the list of failed tasks
  58549. */
  58550. loadAsync(): Promise<void>;
  58551. }
  58552. }
  58553. declare module "babylonjs/Misc/deferred" {
  58554. /**
  58555. * Wrapper class for promise with external resolve and reject.
  58556. */
  58557. export class Deferred<T> {
  58558. /**
  58559. * The promise associated with this deferred object.
  58560. */
  58561. readonly promise: Promise<T>;
  58562. private _resolve;
  58563. private _reject;
  58564. /**
  58565. * The resolve method of the promise associated with this deferred object.
  58566. */
  58567. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58568. /**
  58569. * The reject method of the promise associated with this deferred object.
  58570. */
  58571. readonly reject: (reason?: any) => void;
  58572. /**
  58573. * Constructor for this deferred object.
  58574. */
  58575. constructor();
  58576. }
  58577. }
  58578. declare module "babylonjs/Misc/meshExploder" {
  58579. import { Mesh } from "babylonjs/Meshes/mesh";
  58580. /**
  58581. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58582. */
  58583. export class MeshExploder {
  58584. private _centerMesh;
  58585. private _meshes;
  58586. private _meshesOrigins;
  58587. private _toCenterVectors;
  58588. private _scaledDirection;
  58589. private _newPosition;
  58590. private _centerPosition;
  58591. /**
  58592. * Explodes meshes from a center mesh.
  58593. * @param meshes The meshes to explode.
  58594. * @param centerMesh The mesh to be center of explosion.
  58595. */
  58596. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58597. private _setCenterMesh;
  58598. /**
  58599. * Get class name
  58600. * @returns "MeshExploder"
  58601. */
  58602. getClassName(): string;
  58603. /**
  58604. * "Exploded meshes"
  58605. * @returns Array of meshes with the centerMesh at index 0.
  58606. */
  58607. getMeshes(): Array<Mesh>;
  58608. /**
  58609. * Explodes meshes giving a specific direction
  58610. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58611. */
  58612. explode(direction?: number): void;
  58613. }
  58614. }
  58615. declare module "babylonjs/Misc/filesInput" {
  58616. import { Engine } from "babylonjs/Engines/engine";
  58617. import { Scene } from "babylonjs/scene";
  58618. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58619. /**
  58620. * Class used to help managing file picking and drag'n'drop
  58621. */
  58622. export class FilesInput {
  58623. /**
  58624. * List of files ready to be loaded
  58625. */
  58626. static readonly FilesToLoad: {
  58627. [key: string]: File;
  58628. };
  58629. /**
  58630. * Callback called when a file is processed
  58631. */
  58632. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58633. private _engine;
  58634. private _currentScene;
  58635. private _sceneLoadedCallback;
  58636. private _progressCallback;
  58637. private _additionalRenderLoopLogicCallback;
  58638. private _textureLoadingCallback;
  58639. private _startingProcessingFilesCallback;
  58640. private _onReloadCallback;
  58641. private _errorCallback;
  58642. private _elementToMonitor;
  58643. private _sceneFileToLoad;
  58644. private _filesToLoad;
  58645. /**
  58646. * Creates a new FilesInput
  58647. * @param engine defines the rendering engine
  58648. * @param scene defines the hosting scene
  58649. * @param sceneLoadedCallback callback called when scene is loaded
  58650. * @param progressCallback callback called to track progress
  58651. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58652. * @param textureLoadingCallback callback called when a texture is loading
  58653. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58654. * @param onReloadCallback callback called when a reload is requested
  58655. * @param errorCallback callback call if an error occurs
  58656. */
  58657. 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);
  58658. private _dragEnterHandler;
  58659. private _dragOverHandler;
  58660. private _dropHandler;
  58661. /**
  58662. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58663. * @param elementToMonitor defines the DOM element to track
  58664. */
  58665. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58666. /**
  58667. * Release all associated resources
  58668. */
  58669. dispose(): void;
  58670. private renderFunction;
  58671. private drag;
  58672. private drop;
  58673. private _traverseFolder;
  58674. private _processFiles;
  58675. /**
  58676. * Load files from a drop event
  58677. * @param event defines the drop event to use as source
  58678. */
  58679. loadFiles(event: any): void;
  58680. private _processReload;
  58681. /**
  58682. * Reload the current scene from the loaded files
  58683. */
  58684. reload(): void;
  58685. }
  58686. }
  58687. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58688. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58689. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58690. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58691. }
  58692. declare module "babylonjs/Misc/sceneOptimizer" {
  58693. import { Scene, IDisposable } from "babylonjs/scene";
  58694. import { Observable } from "babylonjs/Misc/observable";
  58695. /**
  58696. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58697. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58698. */
  58699. export class SceneOptimization {
  58700. /**
  58701. * Defines the priority of this optimization (0 by default which means first in the list)
  58702. */
  58703. priority: number;
  58704. /**
  58705. * Gets a string describing the action executed by the current optimization
  58706. * @returns description string
  58707. */
  58708. getDescription(): string;
  58709. /**
  58710. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58711. * @param scene defines the current scene where to apply this optimization
  58712. * @param optimizer defines the current optimizer
  58713. * @returns true if everything that can be done was applied
  58714. */
  58715. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58716. /**
  58717. * Creates the SceneOptimization object
  58718. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58719. * @param desc defines the description associated with the optimization
  58720. */
  58721. constructor(
  58722. /**
  58723. * Defines the priority of this optimization (0 by default which means first in the list)
  58724. */
  58725. priority?: number);
  58726. }
  58727. /**
  58728. * Defines an optimization used to reduce the size of render target textures
  58729. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58730. */
  58731. export class TextureOptimization extends SceneOptimization {
  58732. /**
  58733. * Defines the priority of this optimization (0 by default which means first in the list)
  58734. */
  58735. priority: number;
  58736. /**
  58737. * 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
  58738. */
  58739. maximumSize: number;
  58740. /**
  58741. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58742. */
  58743. step: number;
  58744. /**
  58745. * Gets a string describing the action executed by the current optimization
  58746. * @returns description string
  58747. */
  58748. getDescription(): string;
  58749. /**
  58750. * Creates the TextureOptimization object
  58751. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58752. * @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
  58753. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58754. */
  58755. constructor(
  58756. /**
  58757. * Defines the priority of this optimization (0 by default which means first in the list)
  58758. */
  58759. priority?: number,
  58760. /**
  58761. * 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
  58762. */
  58763. maximumSize?: number,
  58764. /**
  58765. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58766. */
  58767. step?: number);
  58768. /**
  58769. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58770. * @param scene defines the current scene where to apply this optimization
  58771. * @param optimizer defines the current optimizer
  58772. * @returns true if everything that can be done was applied
  58773. */
  58774. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58775. }
  58776. /**
  58777. * Defines an optimization used to increase or decrease the rendering resolution
  58778. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58779. */
  58780. export class HardwareScalingOptimization extends SceneOptimization {
  58781. /**
  58782. * Defines the priority of this optimization (0 by default which means first in the list)
  58783. */
  58784. priority: number;
  58785. /**
  58786. * Defines the maximum scale to use (2 by default)
  58787. */
  58788. maximumScale: number;
  58789. /**
  58790. * Defines the step to use between two passes (0.5 by default)
  58791. */
  58792. step: number;
  58793. private _currentScale;
  58794. private _directionOffset;
  58795. /**
  58796. * Gets a string describing the action executed by the current optimization
  58797. * @return description string
  58798. */
  58799. getDescription(): string;
  58800. /**
  58801. * Creates the HardwareScalingOptimization object
  58802. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58803. * @param maximumScale defines the maximum scale to use (2 by default)
  58804. * @param step defines the step to use between two passes (0.5 by default)
  58805. */
  58806. constructor(
  58807. /**
  58808. * Defines the priority of this optimization (0 by default which means first in the list)
  58809. */
  58810. priority?: number,
  58811. /**
  58812. * Defines the maximum scale to use (2 by default)
  58813. */
  58814. maximumScale?: number,
  58815. /**
  58816. * Defines the step to use between two passes (0.5 by default)
  58817. */
  58818. step?: number);
  58819. /**
  58820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58821. * @param scene defines the current scene where to apply this optimization
  58822. * @param optimizer defines the current optimizer
  58823. * @returns true if everything that can be done was applied
  58824. */
  58825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58826. }
  58827. /**
  58828. * Defines an optimization used to remove shadows
  58829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58830. */
  58831. export class ShadowsOptimization extends SceneOptimization {
  58832. /**
  58833. * Gets a string describing the action executed by the current optimization
  58834. * @return description string
  58835. */
  58836. getDescription(): string;
  58837. /**
  58838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58839. * @param scene defines the current scene where to apply this optimization
  58840. * @param optimizer defines the current optimizer
  58841. * @returns true if everything that can be done was applied
  58842. */
  58843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58844. }
  58845. /**
  58846. * Defines an optimization used to turn post-processes off
  58847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58848. */
  58849. export class PostProcessesOptimization extends SceneOptimization {
  58850. /**
  58851. * Gets a string describing the action executed by the current optimization
  58852. * @return description string
  58853. */
  58854. getDescription(): string;
  58855. /**
  58856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58857. * @param scene defines the current scene where to apply this optimization
  58858. * @param optimizer defines the current optimizer
  58859. * @returns true if everything that can be done was applied
  58860. */
  58861. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58862. }
  58863. /**
  58864. * Defines an optimization used to turn lens flares off
  58865. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58866. */
  58867. export class LensFlaresOptimization extends SceneOptimization {
  58868. /**
  58869. * Gets a string describing the action executed by the current optimization
  58870. * @return description string
  58871. */
  58872. getDescription(): string;
  58873. /**
  58874. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58875. * @param scene defines the current scene where to apply this optimization
  58876. * @param optimizer defines the current optimizer
  58877. * @returns true if everything that can be done was applied
  58878. */
  58879. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58880. }
  58881. /**
  58882. * Defines an optimization based on user defined callback.
  58883. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58884. */
  58885. export class CustomOptimization extends SceneOptimization {
  58886. /**
  58887. * Callback called to apply the custom optimization.
  58888. */
  58889. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58890. /**
  58891. * Callback called to get custom description
  58892. */
  58893. onGetDescription: () => string;
  58894. /**
  58895. * Gets a string describing the action executed by the current optimization
  58896. * @returns description string
  58897. */
  58898. getDescription(): string;
  58899. /**
  58900. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58901. * @param scene defines the current scene where to apply this optimization
  58902. * @param optimizer defines the current optimizer
  58903. * @returns true if everything that can be done was applied
  58904. */
  58905. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58906. }
  58907. /**
  58908. * Defines an optimization used to turn particles off
  58909. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58910. */
  58911. export class ParticlesOptimization extends SceneOptimization {
  58912. /**
  58913. * Gets a string describing the action executed by the current optimization
  58914. * @return description string
  58915. */
  58916. getDescription(): string;
  58917. /**
  58918. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58919. * @param scene defines the current scene where to apply this optimization
  58920. * @param optimizer defines the current optimizer
  58921. * @returns true if everything that can be done was applied
  58922. */
  58923. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58924. }
  58925. /**
  58926. * Defines an optimization used to turn render targets off
  58927. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58928. */
  58929. export class RenderTargetsOptimization extends SceneOptimization {
  58930. /**
  58931. * Gets a string describing the action executed by the current optimization
  58932. * @return description string
  58933. */
  58934. getDescription(): string;
  58935. /**
  58936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58937. * @param scene defines the current scene where to apply this optimization
  58938. * @param optimizer defines the current optimizer
  58939. * @returns true if everything that can be done was applied
  58940. */
  58941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58942. }
  58943. /**
  58944. * Defines an optimization used to merge meshes with compatible materials
  58945. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58946. */
  58947. export class MergeMeshesOptimization extends SceneOptimization {
  58948. private static _UpdateSelectionTree;
  58949. /**
  58950. * Gets or sets a boolean which defines if optimization octree has to be updated
  58951. */
  58952. /**
  58953. * Gets or sets a boolean which defines if optimization octree has to be updated
  58954. */
  58955. static UpdateSelectionTree: boolean;
  58956. /**
  58957. * Gets a string describing the action executed by the current optimization
  58958. * @return description string
  58959. */
  58960. getDescription(): string;
  58961. private _canBeMerged;
  58962. /**
  58963. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58964. * @param scene defines the current scene where to apply this optimization
  58965. * @param optimizer defines the current optimizer
  58966. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58967. * @returns true if everything that can be done was applied
  58968. */
  58969. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58970. }
  58971. /**
  58972. * Defines a list of options used by SceneOptimizer
  58973. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58974. */
  58975. export class SceneOptimizerOptions {
  58976. /**
  58977. * Defines the target frame rate to reach (60 by default)
  58978. */
  58979. targetFrameRate: number;
  58980. /**
  58981. * Defines the interval between two checkes (2000ms by default)
  58982. */
  58983. trackerDuration: number;
  58984. /**
  58985. * Gets the list of optimizations to apply
  58986. */
  58987. optimizations: SceneOptimization[];
  58988. /**
  58989. * Creates a new list of options used by SceneOptimizer
  58990. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58991. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58992. */
  58993. constructor(
  58994. /**
  58995. * Defines the target frame rate to reach (60 by default)
  58996. */
  58997. targetFrameRate?: number,
  58998. /**
  58999. * Defines the interval between two checkes (2000ms by default)
  59000. */
  59001. trackerDuration?: number);
  59002. /**
  59003. * Add a new optimization
  59004. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59005. * @returns the current SceneOptimizerOptions
  59006. */
  59007. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59008. /**
  59009. * Add a new custom optimization
  59010. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59011. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59012. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59013. * @returns the current SceneOptimizerOptions
  59014. */
  59015. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59016. /**
  59017. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59018. * @param targetFrameRate defines the target frame rate (60 by default)
  59019. * @returns a SceneOptimizerOptions object
  59020. */
  59021. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59022. /**
  59023. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59024. * @param targetFrameRate defines the target frame rate (60 by default)
  59025. * @returns a SceneOptimizerOptions object
  59026. */
  59027. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59028. /**
  59029. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59030. * @param targetFrameRate defines the target frame rate (60 by default)
  59031. * @returns a SceneOptimizerOptions object
  59032. */
  59033. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59034. }
  59035. /**
  59036. * Class used to run optimizations in order to reach a target frame rate
  59037. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59038. */
  59039. export class SceneOptimizer implements IDisposable {
  59040. private _isRunning;
  59041. private _options;
  59042. private _scene;
  59043. private _currentPriorityLevel;
  59044. private _targetFrameRate;
  59045. private _trackerDuration;
  59046. private _currentFrameRate;
  59047. private _sceneDisposeObserver;
  59048. private _improvementMode;
  59049. /**
  59050. * Defines an observable called when the optimizer reaches the target frame rate
  59051. */
  59052. onSuccessObservable: Observable<SceneOptimizer>;
  59053. /**
  59054. * Defines an observable called when the optimizer enables an optimization
  59055. */
  59056. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59057. /**
  59058. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59059. */
  59060. onFailureObservable: Observable<SceneOptimizer>;
  59061. /**
  59062. * Gets a boolean indicating if the optimizer is in improvement mode
  59063. */
  59064. readonly isInImprovementMode: boolean;
  59065. /**
  59066. * Gets the current priority level (0 at start)
  59067. */
  59068. readonly currentPriorityLevel: number;
  59069. /**
  59070. * Gets the current frame rate checked by the SceneOptimizer
  59071. */
  59072. readonly currentFrameRate: number;
  59073. /**
  59074. * Gets or sets the current target frame rate (60 by default)
  59075. */
  59076. /**
  59077. * Gets or sets the current target frame rate (60 by default)
  59078. */
  59079. targetFrameRate: number;
  59080. /**
  59081. * Gets or sets the current interval between two checks (every 2000ms by default)
  59082. */
  59083. /**
  59084. * Gets or sets the current interval between two checks (every 2000ms by default)
  59085. */
  59086. trackerDuration: number;
  59087. /**
  59088. * Gets the list of active optimizations
  59089. */
  59090. readonly optimizations: SceneOptimization[];
  59091. /**
  59092. * Creates a new SceneOptimizer
  59093. * @param scene defines the scene to work on
  59094. * @param options defines the options to use with the SceneOptimizer
  59095. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59096. * @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)
  59097. */
  59098. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59099. /**
  59100. * Stops the current optimizer
  59101. */
  59102. stop(): void;
  59103. /**
  59104. * Reset the optimizer to initial step (current priority level = 0)
  59105. */
  59106. reset(): void;
  59107. /**
  59108. * Start the optimizer. By default it will try to reach a specific framerate
  59109. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59110. */
  59111. start(): void;
  59112. private _checkCurrentState;
  59113. /**
  59114. * Release all resources
  59115. */
  59116. dispose(): void;
  59117. /**
  59118. * Helper function to create a SceneOptimizer with one single line of code
  59119. * @param scene defines the scene to work on
  59120. * @param options defines the options to use with the SceneOptimizer
  59121. * @param onSuccess defines a callback to call on success
  59122. * @param onFailure defines a callback to call on failure
  59123. * @returns the new SceneOptimizer object
  59124. */
  59125. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59126. }
  59127. }
  59128. declare module "babylonjs/Misc/sceneSerializer" {
  59129. import { Scene } from "babylonjs/scene";
  59130. /**
  59131. * Class used to serialize a scene into a string
  59132. */
  59133. export class SceneSerializer {
  59134. /**
  59135. * Clear cache used by a previous serialization
  59136. */
  59137. static ClearCache(): void;
  59138. /**
  59139. * Serialize a scene into a JSON compatible object
  59140. * @param scene defines the scene to serialize
  59141. * @returns a JSON compatible object
  59142. */
  59143. static Serialize(scene: Scene): any;
  59144. /**
  59145. * Serialize a mesh into a JSON compatible object
  59146. * @param toSerialize defines the mesh to serialize
  59147. * @param withParents defines if parents must be serialized as well
  59148. * @param withChildren defines if children must be serialized as well
  59149. * @returns a JSON compatible object
  59150. */
  59151. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59152. }
  59153. }
  59154. declare module "babylonjs/Misc/textureTools" {
  59155. import { Texture } from "babylonjs/Materials/Textures/texture";
  59156. /**
  59157. * Class used to host texture specific utilities
  59158. */
  59159. export class TextureTools {
  59160. /**
  59161. * Uses the GPU to create a copy texture rescaled at a given size
  59162. * @param texture Texture to copy from
  59163. * @param width defines the desired width
  59164. * @param height defines the desired height
  59165. * @param useBilinearMode defines if bilinear mode has to be used
  59166. * @return the generated texture
  59167. */
  59168. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59169. }
  59170. }
  59171. declare module "babylonjs/Misc/videoRecorder" {
  59172. import { Nullable } from "babylonjs/types";
  59173. import { Engine } from "babylonjs/Engines/engine";
  59174. /**
  59175. * This represents the different options avilable for the video capture.
  59176. */
  59177. export interface VideoRecorderOptions {
  59178. /** Defines the mime type of the video */
  59179. mimeType: string;
  59180. /** Defines the video the video should be recorded at */
  59181. fps: number;
  59182. /** Defines the chunk size for the recording data */
  59183. recordChunckSize: number;
  59184. /** The audio tracks to attach to the record */
  59185. audioTracks?: MediaStreamTrack[];
  59186. }
  59187. /**
  59188. * This can helps recording videos from BabylonJS.
  59189. * This is based on the available WebRTC functionalities of the browser.
  59190. *
  59191. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59192. */
  59193. export class VideoRecorder {
  59194. private static readonly _defaultOptions;
  59195. /**
  59196. * Returns wehther or not the VideoRecorder is available in your browser.
  59197. * @param engine Defines the Babylon Engine to check the support for
  59198. * @returns true if supported otherwise false
  59199. */
  59200. static IsSupported(engine: Engine): boolean;
  59201. private readonly _options;
  59202. private _canvas;
  59203. private _mediaRecorder;
  59204. private _recordedChunks;
  59205. private _fileName;
  59206. private _resolve;
  59207. private _reject;
  59208. /**
  59209. * True wether a recording is already in progress.
  59210. */
  59211. readonly isRecording: boolean;
  59212. /**
  59213. * Create a new VideoCapture object which can help converting what you see in Babylon to
  59214. * a video file.
  59215. * @param engine Defines the BabylonJS Engine you wish to record
  59216. * @param options Defines options that can be used to customized the capture
  59217. */
  59218. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59219. /**
  59220. * Stops the current recording before the default capture timeout passed in the startRecording
  59221. * functions.
  59222. */
  59223. stopRecording(): void;
  59224. /**
  59225. * Starts recording the canvas for a max duration specified in parameters.
  59226. * @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.
  59227. * @param maxDuration Defines the maximum recording time in seconds.
  59228. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59229. * @return a promise callback at the end of the recording with the video data in Blob.
  59230. */
  59231. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59232. /**
  59233. * Releases internal resources used during the recording.
  59234. */
  59235. dispose(): void;
  59236. private _handleDataAvailable;
  59237. private _handleError;
  59238. private _handleStop;
  59239. }
  59240. }
  59241. declare module "babylonjs/Misc/screenshotTools" {
  59242. import { Camera } from "babylonjs/Cameras/camera";
  59243. import { Engine } from "babylonjs/Engines/engine";
  59244. /**
  59245. * Class containing a set of static utilities functions for screenshots
  59246. */
  59247. export class ScreenshotTools {
  59248. /**
  59249. * Captures a screenshot of the current rendering
  59250. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59251. * @param engine defines the rendering engine
  59252. * @param camera defines the source camera
  59253. * @param size This parameter can be set to a single number or to an object with the
  59254. * following (optional) properties: precision, width, height. If a single number is passed,
  59255. * it will be used for both width and height. If an object is passed, the screenshot size
  59256. * will be derived from the parameters. The precision property is a multiplier allowing
  59257. * rendering at a higher or lower resolution
  59258. * @param successCallback defines the callback receives a single parameter which contains the
  59259. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59260. * src parameter of an <img> to display it
  59261. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59262. * Check your browser for supported MIME types
  59263. */
  59264. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59265. /**
  59266. * Generates an image screenshot from the specified camera.
  59267. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59268. * @param engine The engine to use for rendering
  59269. * @param camera The camera to use for rendering
  59270. * @param size This parameter can be set to a single number or to an object with the
  59271. * following (optional) properties: precision, width, height. If a single number is passed,
  59272. * it will be used for both width and height. If an object is passed, the screenshot size
  59273. * will be derived from the parameters. The precision property is a multiplier allowing
  59274. * rendering at a higher or lower resolution
  59275. * @param successCallback The callback receives a single parameter which contains the
  59276. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59277. * src parameter of an <img> to display it
  59278. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59279. * Check your browser for supported MIME types
  59280. * @param samples Texture samples (default: 1)
  59281. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59282. * @param fileName A name for for the downloaded file.
  59283. */
  59284. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59285. }
  59286. }
  59287. declare module "babylonjs/Misc/index" {
  59288. export * from "babylonjs/Misc/andOrNotEvaluator";
  59289. export * from "babylonjs/Misc/assetsManager";
  59290. export * from "babylonjs/Misc/dds";
  59291. export * from "babylonjs/Misc/decorators";
  59292. export * from "babylonjs/Misc/deferred";
  59293. export * from "babylonjs/Misc/environmentTextureTools";
  59294. export * from "babylonjs/Misc/meshExploder";
  59295. export * from "babylonjs/Misc/filesInput";
  59296. export * from "babylonjs/Misc/HighDynamicRange/index";
  59297. export * from "babylonjs/Misc/khronosTextureContainer";
  59298. export * from "babylonjs/Misc/observable";
  59299. export * from "babylonjs/Misc/performanceMonitor";
  59300. export * from "babylonjs/Misc/promise";
  59301. export * from "babylonjs/Misc/sceneOptimizer";
  59302. export * from "babylonjs/Misc/sceneSerializer";
  59303. export * from "babylonjs/Misc/smartArray";
  59304. export * from "babylonjs/Misc/stringDictionary";
  59305. export * from "babylonjs/Misc/tags";
  59306. export * from "babylonjs/Misc/textureTools";
  59307. export * from "babylonjs/Misc/tga";
  59308. export * from "babylonjs/Misc/tools";
  59309. export * from "babylonjs/Misc/videoRecorder";
  59310. export * from "babylonjs/Misc/virtualJoystick";
  59311. export * from "babylonjs/Misc/workerPool";
  59312. export * from "babylonjs/Misc/logger";
  59313. export * from "babylonjs/Misc/typeStore";
  59314. export * from "babylonjs/Misc/filesInputStore";
  59315. export * from "babylonjs/Misc/deepCopier";
  59316. export * from "babylonjs/Misc/pivotTools";
  59317. export * from "babylonjs/Misc/precisionDate";
  59318. export * from "babylonjs/Misc/screenshotTools";
  59319. export * from "babylonjs/Misc/typeStore";
  59320. export * from "babylonjs/Misc/webRequest";
  59321. export * from "babylonjs/Misc/iInspectable";
  59322. }
  59323. declare module "babylonjs/index" {
  59324. export * from "babylonjs/abstractScene";
  59325. export * from "babylonjs/Actions/index";
  59326. export * from "babylonjs/Animations/index";
  59327. export * from "babylonjs/assetContainer";
  59328. export * from "babylonjs/Audio/index";
  59329. export * from "babylonjs/Behaviors/index";
  59330. export * from "babylonjs/Bones/index";
  59331. export * from "babylonjs/Cameras/index";
  59332. export * from "babylonjs/Collisions/index";
  59333. export * from "babylonjs/Culling/index";
  59334. export * from "babylonjs/Debug/index";
  59335. export * from "babylonjs/Engines/index";
  59336. export * from "babylonjs/Events/index";
  59337. export * from "babylonjs/Gamepads/index";
  59338. export * from "babylonjs/Gizmos/index";
  59339. export * from "babylonjs/Helpers/index";
  59340. export * from "babylonjs/Instrumentation/index";
  59341. export * from "babylonjs/Layers/index";
  59342. export * from "babylonjs/LensFlares/index";
  59343. export * from "babylonjs/Lights/index";
  59344. export * from "babylonjs/Loading/index";
  59345. export * from "babylonjs/Materials/index";
  59346. export * from "babylonjs/Maths/index";
  59347. export * from "babylonjs/Meshes/index";
  59348. export * from "babylonjs/Morph/index";
  59349. export * from "babylonjs/node";
  59350. export * from "babylonjs/Offline/index";
  59351. export * from "babylonjs/Particles/index";
  59352. export * from "babylonjs/Physics/index";
  59353. export * from "babylonjs/PostProcesses/index";
  59354. export * from "babylonjs/Probes/index";
  59355. export * from "babylonjs/Rendering/index";
  59356. export * from "babylonjs/scene";
  59357. export * from "babylonjs/sceneComponent";
  59358. export * from "babylonjs/Sprites/index";
  59359. export * from "babylonjs/States/index";
  59360. export * from "babylonjs/Misc/index";
  59361. export * from "babylonjs/types";
  59362. }
  59363. declare module "babylonjs/Animations/pathCursor" {
  59364. import { Path2, Vector3 } from "babylonjs/Maths/math";
  59365. /**
  59366. * A cursor which tracks a point on a path
  59367. */
  59368. export class PathCursor {
  59369. private path;
  59370. /**
  59371. * Stores path cursor callbacks for when an onchange event is triggered
  59372. */
  59373. private _onchange;
  59374. /**
  59375. * The value of the path cursor
  59376. */
  59377. value: number;
  59378. /**
  59379. * The animation array of the path cursor
  59380. */
  59381. animations: Animation[];
  59382. /**
  59383. * Initializes the path cursor
  59384. * @param path The path to track
  59385. */
  59386. constructor(path: Path2);
  59387. /**
  59388. * Gets the cursor point on the path
  59389. * @returns A point on the path cursor at the cursor location
  59390. */
  59391. getPoint(): Vector3;
  59392. /**
  59393. * Moves the cursor ahead by the step amount
  59394. * @param step The amount to move the cursor forward
  59395. * @returns This path cursor
  59396. */
  59397. moveAhead(step?: number): PathCursor;
  59398. /**
  59399. * Moves the cursor behind by the step amount
  59400. * @param step The amount to move the cursor back
  59401. * @returns This path cursor
  59402. */
  59403. moveBack(step?: number): PathCursor;
  59404. /**
  59405. * Moves the cursor by the step amount
  59406. * If the step amount is greater than one, an exception is thrown
  59407. * @param step The amount to move the cursor
  59408. * @returns This path cursor
  59409. */
  59410. move(step: number): PathCursor;
  59411. /**
  59412. * Ensures that the value is limited between zero and one
  59413. * @returns This path cursor
  59414. */
  59415. private ensureLimits;
  59416. /**
  59417. * Runs onchange callbacks on change (used by the animation engine)
  59418. * @returns This path cursor
  59419. */
  59420. private raiseOnChange;
  59421. /**
  59422. * Executes a function on change
  59423. * @param f A path cursor onchange callback
  59424. * @returns This path cursor
  59425. */
  59426. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59427. }
  59428. }
  59429. declare module "babylonjs/Legacy/legacy" {
  59430. import * as Babylon from "babylonjs/index";
  59431. export * from "babylonjs/index";
  59432. }
  59433. declare module "babylonjs/Shaders/blur.fragment" {
  59434. /** @hidden */
  59435. export var blurPixelShader: {
  59436. name: string;
  59437. shader: string;
  59438. };
  59439. }
  59440. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  59441. /** @hidden */
  59442. export var bones300Declaration: {
  59443. name: string;
  59444. shader: string;
  59445. };
  59446. }
  59447. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  59448. /** @hidden */
  59449. export var instances300Declaration: {
  59450. name: string;
  59451. shader: string;
  59452. };
  59453. }
  59454. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  59455. /** @hidden */
  59456. export var pointCloudVertexDeclaration: {
  59457. name: string;
  59458. shader: string;
  59459. };
  59460. }
  59461. // Mixins
  59462. interface Window {
  59463. mozIndexedDB: IDBFactory;
  59464. webkitIndexedDB: IDBFactory;
  59465. msIndexedDB: IDBFactory;
  59466. webkitURL: typeof URL;
  59467. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59468. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59469. WebGLRenderingContext: WebGLRenderingContext;
  59470. MSGesture: MSGesture;
  59471. CANNON: any;
  59472. AudioContext: AudioContext;
  59473. webkitAudioContext: AudioContext;
  59474. PointerEvent: any;
  59475. Math: Math;
  59476. Uint8Array: Uint8ArrayConstructor;
  59477. Float32Array: Float32ArrayConstructor;
  59478. mozURL: typeof URL;
  59479. msURL: typeof URL;
  59480. VRFrameData: any; // WebVR, from specs 1.1
  59481. DracoDecoderModule: any;
  59482. setImmediate(handler: (...args: any[]) => void): number;
  59483. }
  59484. interface HTMLCanvasElement {
  59485. requestPointerLock(): void;
  59486. msRequestPointerLock?(): void;
  59487. mozRequestPointerLock?(): void;
  59488. webkitRequestPointerLock?(): void;
  59489. /** Track wether a record is in progress */
  59490. isRecording: boolean;
  59491. /** Capture Stream method defined by some browsers */
  59492. captureStream(fps?: number): MediaStream;
  59493. }
  59494. interface CanvasRenderingContext2D {
  59495. msImageSmoothingEnabled: boolean;
  59496. }
  59497. interface MouseEvent {
  59498. mozMovementX: number;
  59499. mozMovementY: number;
  59500. webkitMovementX: number;
  59501. webkitMovementY: number;
  59502. msMovementX: number;
  59503. msMovementY: number;
  59504. }
  59505. interface Navigator {
  59506. mozGetVRDevices: (any: any) => any;
  59507. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59508. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59509. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59510. webkitGetGamepads(): Gamepad[];
  59511. msGetGamepads(): Gamepad[];
  59512. webkitGamepads(): Gamepad[];
  59513. }
  59514. interface HTMLVideoElement {
  59515. mozSrcObject: any;
  59516. }
  59517. interface Math {
  59518. fround(x: number): number;
  59519. imul(a: number, b: number): number;
  59520. }
  59521. interface WebGLRenderingContext {
  59522. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59523. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59524. vertexAttribDivisor(index: number, divisor: number): void;
  59525. createVertexArray(): any;
  59526. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59527. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59528. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59529. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59530. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59531. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59532. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59533. // Queries
  59534. createQuery(): WebGLQuery;
  59535. deleteQuery(query: WebGLQuery): void;
  59536. beginQuery(target: number, query: WebGLQuery): void;
  59537. endQuery(target: number): void;
  59538. getQueryParameter(query: WebGLQuery, pname: number): any;
  59539. getQuery(target: number, pname: number): any;
  59540. MAX_SAMPLES: number;
  59541. RGBA8: number;
  59542. READ_FRAMEBUFFER: number;
  59543. DRAW_FRAMEBUFFER: number;
  59544. UNIFORM_BUFFER: number;
  59545. HALF_FLOAT_OES: number;
  59546. RGBA16F: number;
  59547. RGBA32F: number;
  59548. R32F: number;
  59549. RG32F: number;
  59550. RGB32F: number;
  59551. R16F: number;
  59552. RG16F: number;
  59553. RGB16F: number;
  59554. RED: number;
  59555. RG: number;
  59556. R8: number;
  59557. RG8: number;
  59558. UNSIGNED_INT_24_8: number;
  59559. DEPTH24_STENCIL8: number;
  59560. /* Multiple Render Targets */
  59561. drawBuffers(buffers: number[]): void;
  59562. readBuffer(src: number): void;
  59563. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59564. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59565. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59566. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59567. // Occlusion Query
  59568. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59569. ANY_SAMPLES_PASSED: number;
  59570. QUERY_RESULT_AVAILABLE: number;
  59571. QUERY_RESULT: number;
  59572. }
  59573. interface WebGLProgram {
  59574. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59575. }
  59576. interface EXT_disjoint_timer_query {
  59577. QUERY_COUNTER_BITS_EXT: number;
  59578. TIME_ELAPSED_EXT: number;
  59579. TIMESTAMP_EXT: number;
  59580. GPU_DISJOINT_EXT: number;
  59581. QUERY_RESULT_EXT: number;
  59582. QUERY_RESULT_AVAILABLE_EXT: number;
  59583. queryCounterEXT(query: WebGLQuery, target: number): void;
  59584. createQueryEXT(): WebGLQuery;
  59585. beginQueryEXT(target: number, query: WebGLQuery): void;
  59586. endQueryEXT(target: number): void;
  59587. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59588. deleteQueryEXT(query: WebGLQuery): void;
  59589. }
  59590. interface WebGLUniformLocation {
  59591. _currentState: any;
  59592. }
  59593. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59594. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59595. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59596. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59597. interface WebGLRenderingContext {
  59598. readonly RASTERIZER_DISCARD: number;
  59599. readonly DEPTH_COMPONENT24: number;
  59600. readonly TEXTURE_3D: number;
  59601. readonly TEXTURE_2D_ARRAY: number;
  59602. readonly TEXTURE_COMPARE_FUNC: number;
  59603. readonly TEXTURE_COMPARE_MODE: number;
  59604. readonly COMPARE_REF_TO_TEXTURE: number;
  59605. readonly TEXTURE_WRAP_R: number;
  59606. readonly HALF_FLOAT: number;
  59607. readonly RGB8: number;
  59608. readonly RED_INTEGER: number;
  59609. readonly RG_INTEGER: number;
  59610. readonly RGB_INTEGER: number;
  59611. readonly RGBA_INTEGER: number;
  59612. readonly R8_SNORM: number;
  59613. readonly RG8_SNORM: number;
  59614. readonly RGB8_SNORM: number;
  59615. readonly RGBA8_SNORM: number;
  59616. readonly R8I: number;
  59617. readonly RG8I: number;
  59618. readonly RGB8I: number;
  59619. readonly RGBA8I: number;
  59620. readonly R8UI: number;
  59621. readonly RG8UI: number;
  59622. readonly RGB8UI: number;
  59623. readonly RGBA8UI: number;
  59624. readonly R16I: number;
  59625. readonly RG16I: number;
  59626. readonly RGB16I: number;
  59627. readonly RGBA16I: number;
  59628. readonly R16UI: number;
  59629. readonly RG16UI: number;
  59630. readonly RGB16UI: number;
  59631. readonly RGBA16UI: number;
  59632. readonly R32I: number;
  59633. readonly RG32I: number;
  59634. readonly RGB32I: number;
  59635. readonly RGBA32I: number;
  59636. readonly R32UI: number;
  59637. readonly RG32UI: number;
  59638. readonly RGB32UI: number;
  59639. readonly RGBA32UI: number;
  59640. readonly RGB10_A2UI: number;
  59641. readonly R11F_G11F_B10F: number;
  59642. readonly RGB9_E5: number;
  59643. readonly RGB10_A2: number;
  59644. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59645. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59646. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59647. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59648. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59649. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59650. 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;
  59651. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59652. readonly TRANSFORM_FEEDBACK: number;
  59653. readonly INTERLEAVED_ATTRIBS: number;
  59654. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59655. createTransformFeedback(): WebGLTransformFeedback;
  59656. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59657. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59658. beginTransformFeedback(primitiveMode: number): void;
  59659. endTransformFeedback(): void;
  59660. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59661. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59662. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59663. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59664. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59665. }
  59666. interface ImageBitmap {
  59667. readonly width: number;
  59668. readonly height: number;
  59669. close(): void;
  59670. }
  59671. interface WebGLQuery extends WebGLObject {
  59672. }
  59673. declare var WebGLQuery: {
  59674. prototype: WebGLQuery;
  59675. new(): WebGLQuery;
  59676. };
  59677. interface WebGLSampler extends WebGLObject {
  59678. }
  59679. declare var WebGLSampler: {
  59680. prototype: WebGLSampler;
  59681. new(): WebGLSampler;
  59682. };
  59683. interface WebGLSync extends WebGLObject {
  59684. }
  59685. declare var WebGLSync: {
  59686. prototype: WebGLSync;
  59687. new(): WebGLSync;
  59688. };
  59689. interface WebGLTransformFeedback extends WebGLObject {
  59690. }
  59691. declare var WebGLTransformFeedback: {
  59692. prototype: WebGLTransformFeedback;
  59693. new(): WebGLTransformFeedback;
  59694. };
  59695. interface WebGLVertexArrayObject extends WebGLObject {
  59696. }
  59697. declare var WebGLVertexArrayObject: {
  59698. prototype: WebGLVertexArrayObject;
  59699. new(): WebGLVertexArrayObject;
  59700. };
  59701. // Type definitions for WebVR API
  59702. // Project: https://w3c.github.io/webvr/
  59703. // Definitions by: six a <https://github.com/lostfictions>
  59704. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59705. interface VRDisplay extends EventTarget {
  59706. /**
  59707. * Dictionary of capabilities describing the VRDisplay.
  59708. */
  59709. readonly capabilities: VRDisplayCapabilities;
  59710. /**
  59711. * z-depth defining the far plane of the eye view frustum
  59712. * enables mapping of values in the render target depth
  59713. * attachment to scene coordinates. Initially set to 10000.0.
  59714. */
  59715. depthFar: number;
  59716. /**
  59717. * z-depth defining the near plane of the eye view frustum
  59718. * enables mapping of values in the render target depth
  59719. * attachment to scene coordinates. Initially set to 0.01.
  59720. */
  59721. depthNear: number;
  59722. /**
  59723. * An identifier for this distinct VRDisplay. Used as an
  59724. * association point in the Gamepad API.
  59725. */
  59726. readonly displayId: number;
  59727. /**
  59728. * A display name, a user-readable name identifying it.
  59729. */
  59730. readonly displayName: string;
  59731. readonly isConnected: boolean;
  59732. readonly isPresenting: boolean;
  59733. /**
  59734. * If this VRDisplay supports room-scale experiences, the optional
  59735. * stage attribute contains details on the room-scale parameters.
  59736. */
  59737. readonly stageParameters: VRStageParameters | null;
  59738. /**
  59739. * Passing the value returned by `requestAnimationFrame` to
  59740. * `cancelAnimationFrame` will unregister the callback.
  59741. * @param handle Define the hanle of the request to cancel
  59742. */
  59743. cancelAnimationFrame(handle: number): void;
  59744. /**
  59745. * Stops presenting to the VRDisplay.
  59746. * @returns a promise to know when it stopped
  59747. */
  59748. exitPresent(): Promise<void>;
  59749. /**
  59750. * Return the current VREyeParameters for the given eye.
  59751. * @param whichEye Define the eye we want the parameter for
  59752. * @returns the eye parameters
  59753. */
  59754. getEyeParameters(whichEye: string): VREyeParameters;
  59755. /**
  59756. * Populates the passed VRFrameData with the information required to render
  59757. * the current frame.
  59758. * @param frameData Define the data structure to populate
  59759. * @returns true if ok otherwise false
  59760. */
  59761. getFrameData(frameData: VRFrameData): boolean;
  59762. /**
  59763. * Get the layers currently being presented.
  59764. * @returns the list of VR layers
  59765. */
  59766. getLayers(): VRLayer[];
  59767. /**
  59768. * Return a VRPose containing the future predicted pose of the VRDisplay
  59769. * when the current frame will be presented. The value returned will not
  59770. * change until JavaScript has returned control to the browser.
  59771. *
  59772. * The VRPose will contain the position, orientation, velocity,
  59773. * and acceleration of each of these properties.
  59774. * @returns the pose object
  59775. */
  59776. getPose(): VRPose;
  59777. /**
  59778. * Return the current instantaneous pose of the VRDisplay, with no
  59779. * prediction applied.
  59780. * @returns the current instantaneous pose
  59781. */
  59782. getImmediatePose(): VRPose;
  59783. /**
  59784. * The callback passed to `requestAnimationFrame` will be called
  59785. * any time a new frame should be rendered. When the VRDisplay is
  59786. * presenting the callback will be called at the native refresh
  59787. * rate of the HMD. When not presenting this function acts
  59788. * identically to how window.requestAnimationFrame acts. Content should
  59789. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59790. * asynchronously from other displays and at differing refresh rates.
  59791. * @param callback Define the eaction to run next frame
  59792. * @returns the request handle it
  59793. */
  59794. requestAnimationFrame(callback: FrameRequestCallback): number;
  59795. /**
  59796. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59797. * Repeat calls while already presenting will update the VRLayers being displayed.
  59798. * @param layers Define the list of layer to present
  59799. * @returns a promise to know when the request has been fulfilled
  59800. */
  59801. requestPresent(layers: VRLayer[]): Promise<void>;
  59802. /**
  59803. * Reset the pose for this display, treating its current position and
  59804. * orientation as the "origin/zero" values. VRPose.position,
  59805. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59806. * updated when calling resetPose(). This should be called in only
  59807. * sitting-space experiences.
  59808. */
  59809. resetPose(): void;
  59810. /**
  59811. * The VRLayer provided to the VRDisplay will be captured and presented
  59812. * in the HMD. Calling this function has the same effect on the source
  59813. * canvas as any other operation that uses its source image, and canvases
  59814. * created without preserveDrawingBuffer set to true will be cleared.
  59815. * @param pose Define the pose to submit
  59816. */
  59817. submitFrame(pose?: VRPose): void;
  59818. }
  59819. declare var VRDisplay: {
  59820. prototype: VRDisplay;
  59821. new(): VRDisplay;
  59822. };
  59823. interface VRLayer {
  59824. leftBounds?: number[] | Float32Array | null;
  59825. rightBounds?: number[] | Float32Array | null;
  59826. source?: HTMLCanvasElement | null;
  59827. }
  59828. interface VRDisplayCapabilities {
  59829. readonly canPresent: boolean;
  59830. readonly hasExternalDisplay: boolean;
  59831. readonly hasOrientation: boolean;
  59832. readonly hasPosition: boolean;
  59833. readonly maxLayers: number;
  59834. }
  59835. interface VREyeParameters {
  59836. /** @deprecated */
  59837. readonly fieldOfView: VRFieldOfView;
  59838. readonly offset: Float32Array;
  59839. readonly renderHeight: number;
  59840. readonly renderWidth: number;
  59841. }
  59842. interface VRFieldOfView {
  59843. readonly downDegrees: number;
  59844. readonly leftDegrees: number;
  59845. readonly rightDegrees: number;
  59846. readonly upDegrees: number;
  59847. }
  59848. interface VRFrameData {
  59849. readonly leftProjectionMatrix: Float32Array;
  59850. readonly leftViewMatrix: Float32Array;
  59851. readonly pose: VRPose;
  59852. readonly rightProjectionMatrix: Float32Array;
  59853. readonly rightViewMatrix: Float32Array;
  59854. readonly timestamp: number;
  59855. }
  59856. interface VRPose {
  59857. readonly angularAcceleration: Float32Array | null;
  59858. readonly angularVelocity: Float32Array | null;
  59859. readonly linearAcceleration: Float32Array | null;
  59860. readonly linearVelocity: Float32Array | null;
  59861. readonly orientation: Float32Array | null;
  59862. readonly position: Float32Array | null;
  59863. readonly timestamp: number;
  59864. }
  59865. interface VRStageParameters {
  59866. sittingToStandingTransform?: Float32Array;
  59867. sizeX?: number;
  59868. sizeY?: number;
  59869. }
  59870. interface Navigator {
  59871. getVRDisplays(): Promise<VRDisplay[]>;
  59872. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59873. }
  59874. interface Window {
  59875. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59876. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59877. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59878. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59879. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59880. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59881. }
  59882. interface Gamepad {
  59883. readonly displayId: number;
  59884. }
  59885. interface XRDevice {
  59886. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59887. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59888. }
  59889. interface XRSession {
  59890. getInputSources(): Array<any>;
  59891. baseLayer: XRWebGLLayer;
  59892. requestFrameOfReference(type: string): Promise<void>;
  59893. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59894. end(): Promise<void>;
  59895. requestAnimationFrame: Function;
  59896. addEventListener: Function;
  59897. }
  59898. interface XRSessionCreationOptions {
  59899. outputContext?: WebGLRenderingContext | null;
  59900. immersive?: boolean;
  59901. environmentIntegration?: boolean;
  59902. }
  59903. interface XRLayer {
  59904. getViewport: Function;
  59905. framebufferWidth: number;
  59906. framebufferHeight: number;
  59907. }
  59908. interface XRView {
  59909. projectionMatrix: Float32Array;
  59910. }
  59911. interface XRFrame {
  59912. getDevicePose: Function;
  59913. getInputPose: Function;
  59914. views: Array<XRView>;
  59915. baseLayer: XRLayer;
  59916. }
  59917. interface XRFrameOfReference {
  59918. }
  59919. interface XRWebGLLayer extends XRLayer {
  59920. framebuffer: WebGLFramebuffer;
  59921. }
  59922. declare var XRWebGLLayer: {
  59923. prototype: XRWebGLLayer;
  59924. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59925. };
  59926. declare module "babylonjs" {
  59927. export * from "babylonjs/Legacy/legacy";
  59928. }
  59929. declare module BABYLON {
  59930. /** Alias type for value that can be null */
  59931. export type Nullable<T> = T | null;
  59932. /**
  59933. * Alias type for number that are floats
  59934. * @ignorenaming
  59935. */
  59936. export type float = number;
  59937. /**
  59938. * Alias type for number that are doubles.
  59939. * @ignorenaming
  59940. */
  59941. export type double = number;
  59942. /**
  59943. * Alias type for number that are integer
  59944. * @ignorenaming
  59945. */
  59946. export type int = number;
  59947. /** Alias type for number array or Float32Array */
  59948. export type FloatArray = number[] | Float32Array;
  59949. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59950. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59951. /**
  59952. * Alias for types that can be used by a Buffer or VertexBuffer.
  59953. */
  59954. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59955. /**
  59956. * Alias type for primitive types
  59957. * @ignorenaming
  59958. */
  59959. type Primitive = undefined | null | boolean | string | number | Function;
  59960. /**
  59961. * Type modifier to make all the properties of an object Readonly
  59962. */
  59963. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59964. /**
  59965. * Type modifier to make all the properties of an object Readonly recursively
  59966. */
  59967. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59968. /** @hidden */
  59969. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59970. }
  59971. /** @hidden */
  59972. /** @hidden */
  59973. type DeepImmutableObject<T> = {
  59974. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59975. };
  59976. }
  59977. declare module BABYLON {
  59978. /**
  59979. * Class containing a set of static utilities functions for arrays.
  59980. */
  59981. export class ArrayTools {
  59982. /**
  59983. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59984. * @param size the number of element to construct and put in the array
  59985. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59986. * @returns a new array filled with new objects
  59987. */
  59988. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59989. }
  59990. }
  59991. declare module BABYLON {
  59992. /**
  59993. * Scalar computation library
  59994. */
  59995. export class Scalar {
  59996. /**
  59997. * Two pi constants convenient for computation.
  59998. */
  59999. static TwoPi: number;
  60000. /**
  60001. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  60002. * @param a number
  60003. * @param b number
  60004. * @param epsilon (default = 1.401298E-45)
  60005. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  60006. */
  60007. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  60008. /**
  60009. * Returns a string : the upper case translation of the number i to hexadecimal.
  60010. * @param i number
  60011. * @returns the upper case translation of the number i to hexadecimal.
  60012. */
  60013. static ToHex(i: number): string;
  60014. /**
  60015. * Returns -1 if value is negative and +1 is value is positive.
  60016. * @param value the value
  60017. * @returns the value itself if it's equal to zero.
  60018. */
  60019. static Sign(value: number): number;
  60020. /**
  60021. * Returns the value itself if it's between min and max.
  60022. * Returns min if the value is lower than min.
  60023. * Returns max if the value is greater than max.
  60024. * @param value the value to clmap
  60025. * @param min the min value to clamp to (default: 0)
  60026. * @param max the max value to clamp to (default: 1)
  60027. * @returns the clamped value
  60028. */
  60029. static Clamp(value: number, min?: number, max?: number): number;
  60030. /**
  60031. * the log2 of value.
  60032. * @param value the value to compute log2 of
  60033. * @returns the log2 of value.
  60034. */
  60035. static Log2(value: number): number;
  60036. /**
  60037. * Loops the value, so that it is never larger than length and never smaller than 0.
  60038. *
  60039. * This is similar to the modulo operator but it works with floating point numbers.
  60040. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  60041. * With t = 5 and length = 2.5, the result would be 0.0.
  60042. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  60043. * @param value the value
  60044. * @param length the length
  60045. * @returns the looped value
  60046. */
  60047. static Repeat(value: number, length: number): number;
  60048. /**
  60049. * Normalize the value between 0.0 and 1.0 using min and max values
  60050. * @param value value to normalize
  60051. * @param min max to normalize between
  60052. * @param max min to normalize between
  60053. * @returns the normalized value
  60054. */
  60055. static Normalize(value: number, min: number, max: number): number;
  60056. /**
  60057. * Denormalize the value from 0.0 and 1.0 using min and max values
  60058. * @param normalized value to denormalize
  60059. * @param min max to denormalize between
  60060. * @param max min to denormalize between
  60061. * @returns the denormalized value
  60062. */
  60063. static Denormalize(normalized: number, min: number, max: number): number;
  60064. /**
  60065. * Calculates the shortest difference between two given angles given in degrees.
  60066. * @param current current angle in degrees
  60067. * @param target target angle in degrees
  60068. * @returns the delta
  60069. */
  60070. static DeltaAngle(current: number, target: number): number;
  60071. /**
  60072. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  60073. * @param tx value
  60074. * @param length length
  60075. * @returns The returned value will move back and forth between 0 and length
  60076. */
  60077. static PingPong(tx: number, length: number): number;
  60078. /**
  60079. * Interpolates between min and max with smoothing at the limits.
  60080. *
  60081. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  60082. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  60083. * @param from from
  60084. * @param to to
  60085. * @param tx value
  60086. * @returns the smooth stepped value
  60087. */
  60088. static SmoothStep(from: number, to: number, tx: number): number;
  60089. /**
  60090. * Moves a value current towards target.
  60091. *
  60092. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  60093. * Negative values of maxDelta pushes the value away from target.
  60094. * @param current current value
  60095. * @param target target value
  60096. * @param maxDelta max distance to move
  60097. * @returns resulting value
  60098. */
  60099. static MoveTowards(current: number, target: number, maxDelta: number): number;
  60100. /**
  60101. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60102. *
  60103. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  60104. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  60105. * @param current current value
  60106. * @param target target value
  60107. * @param maxDelta max distance to move
  60108. * @returns resulting angle
  60109. */
  60110. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  60111. /**
  60112. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  60113. * @param start start value
  60114. * @param end target value
  60115. * @param amount amount to lerp between
  60116. * @returns the lerped value
  60117. */
  60118. static Lerp(start: number, end: number, amount: number): number;
  60119. /**
  60120. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60121. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  60122. * @param start start value
  60123. * @param end target value
  60124. * @param amount amount to lerp between
  60125. * @returns the lerped value
  60126. */
  60127. static LerpAngle(start: number, end: number, amount: number): number;
  60128. /**
  60129. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  60130. * @param a start value
  60131. * @param b target value
  60132. * @param value value between a and b
  60133. * @returns the inverseLerp value
  60134. */
  60135. static InverseLerp(a: number, b: number, value: number): number;
  60136. /**
  60137. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  60138. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  60139. * @param value1 spline value
  60140. * @param tangent1 spline value
  60141. * @param value2 spline value
  60142. * @param tangent2 spline value
  60143. * @param amount input value
  60144. * @returns hermite result
  60145. */
  60146. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  60147. /**
  60148. * Returns a random float number between and min and max values
  60149. * @param min min value of random
  60150. * @param max max value of random
  60151. * @returns random value
  60152. */
  60153. static RandomRange(min: number, max: number): number;
  60154. /**
  60155. * This function returns percentage of a number in a given range.
  60156. *
  60157. * RangeToPercent(40,20,60) will return 0.5 (50%)
  60158. * RangeToPercent(34,0,100) will return 0.34 (34%)
  60159. * @param number to convert to percentage
  60160. * @param min min range
  60161. * @param max max range
  60162. * @returns the percentage
  60163. */
  60164. static RangeToPercent(number: number, min: number, max: number): number;
  60165. /**
  60166. * This function returns number that corresponds to the percentage in a given range.
  60167. *
  60168. * PercentToRange(0.34,0,100) will return 34.
  60169. * @param percent to convert to number
  60170. * @param min min range
  60171. * @param max max range
  60172. * @returns the number
  60173. */
  60174. static PercentToRange(percent: number, min: number, max: number): number;
  60175. /**
  60176. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  60177. * @param angle The angle to normalize in radian.
  60178. * @return The converted angle.
  60179. */
  60180. static NormalizeRadians(angle: number): number;
  60181. }
  60182. }
  60183. declare module BABYLON {
  60184. /**
  60185. * Constant used to convert a value to gamma space
  60186. * @ignorenaming
  60187. */
  60188. export const ToGammaSpace: number;
  60189. /**
  60190. * Constant used to convert a value to linear space
  60191. * @ignorenaming
  60192. */
  60193. export const ToLinearSpace = 2.2;
  60194. /**
  60195. * Constant used to define the minimal number value in Babylon.js
  60196. * @ignorenaming
  60197. */
  60198. let Epsilon: number;
  60199. /**
  60200. * Class used to hold a RBG color
  60201. */
  60202. export class Color3 {
  60203. /**
  60204. * Defines the red component (between 0 and 1, default is 0)
  60205. */
  60206. r: number;
  60207. /**
  60208. * Defines the green component (between 0 and 1, default is 0)
  60209. */
  60210. g: number;
  60211. /**
  60212. * Defines the blue component (between 0 and 1, default is 0)
  60213. */
  60214. b: number;
  60215. /**
  60216. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  60217. * @param r defines the red component (between 0 and 1, default is 0)
  60218. * @param g defines the green component (between 0 and 1, default is 0)
  60219. * @param b defines the blue component (between 0 and 1, default is 0)
  60220. */
  60221. constructor(
  60222. /**
  60223. * Defines the red component (between 0 and 1, default is 0)
  60224. */
  60225. r?: number,
  60226. /**
  60227. * Defines the green component (between 0 and 1, default is 0)
  60228. */
  60229. g?: number,
  60230. /**
  60231. * Defines the blue component (between 0 and 1, default is 0)
  60232. */
  60233. b?: number);
  60234. /**
  60235. * Creates a string with the Color3 current values
  60236. * @returns the string representation of the Color3 object
  60237. */
  60238. toString(): string;
  60239. /**
  60240. * Returns the string "Color3"
  60241. * @returns "Color3"
  60242. */
  60243. getClassName(): string;
  60244. /**
  60245. * Compute the Color3 hash code
  60246. * @returns an unique number that can be used to hash Color3 objects
  60247. */
  60248. getHashCode(): number;
  60249. /**
  60250. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  60251. * @param array defines the array where to store the r,g,b components
  60252. * @param index defines an optional index in the target array to define where to start storing values
  60253. * @returns the current Color3 object
  60254. */
  60255. toArray(array: FloatArray, index?: number): Color3;
  60256. /**
  60257. * Returns a new Color4 object from the current Color3 and the given alpha
  60258. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  60259. * @returns a new Color4 object
  60260. */
  60261. toColor4(alpha?: number): Color4;
  60262. /**
  60263. * Returns a new array populated with 3 numeric elements : red, green and blue values
  60264. * @returns the new array
  60265. */
  60266. asArray(): number[];
  60267. /**
  60268. * Returns the luminance value
  60269. * @returns a float value
  60270. */
  60271. toLuminance(): number;
  60272. /**
  60273. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  60274. * @param otherColor defines the second operand
  60275. * @returns the new Color3 object
  60276. */
  60277. multiply(otherColor: DeepImmutable<Color3>): Color3;
  60278. /**
  60279. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  60280. * @param otherColor defines the second operand
  60281. * @param result defines the Color3 object where to store the result
  60282. * @returns the current Color3
  60283. */
  60284. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60285. /**
  60286. * Determines equality between Color3 objects
  60287. * @param otherColor defines the second operand
  60288. * @returns true if the rgb values are equal to the given ones
  60289. */
  60290. equals(otherColor: DeepImmutable<Color3>): boolean;
  60291. /**
  60292. * Determines equality between the current Color3 object and a set of r,b,g values
  60293. * @param r defines the red component to check
  60294. * @param g defines the green component to check
  60295. * @param b defines the blue component to check
  60296. * @returns true if the rgb values are equal to the given ones
  60297. */
  60298. equalsFloats(r: number, g: number, b: number): boolean;
  60299. /**
  60300. * Multiplies in place each rgb value by scale
  60301. * @param scale defines the scaling factor
  60302. * @returns the updated Color3
  60303. */
  60304. scale(scale: number): Color3;
  60305. /**
  60306. * Multiplies the rgb values by scale and stores the result into "result"
  60307. * @param scale defines the scaling factor
  60308. * @param result defines the Color3 object where to store the result
  60309. * @returns the unmodified current Color3
  60310. */
  60311. scaleToRef(scale: number, result: Color3): Color3;
  60312. /**
  60313. * Scale the current Color3 values by a factor and add the result to a given Color3
  60314. * @param scale defines the scale factor
  60315. * @param result defines color to store the result into
  60316. * @returns the unmodified current Color3
  60317. */
  60318. scaleAndAddToRef(scale: number, result: Color3): Color3;
  60319. /**
  60320. * Clamps the rgb values by the min and max values and stores the result into "result"
  60321. * @param min defines minimum clamping value (default is 0)
  60322. * @param max defines maximum clamping value (default is 1)
  60323. * @param result defines color to store the result into
  60324. * @returns the original Color3
  60325. */
  60326. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  60327. /**
  60328. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  60329. * @param otherColor defines the second operand
  60330. * @returns the new Color3
  60331. */
  60332. add(otherColor: DeepImmutable<Color3>): Color3;
  60333. /**
  60334. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  60335. * @param otherColor defines the second operand
  60336. * @param result defines Color3 object to store the result into
  60337. * @returns the unmodified current Color3
  60338. */
  60339. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60340. /**
  60341. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  60342. * @param otherColor defines the second operand
  60343. * @returns the new Color3
  60344. */
  60345. subtract(otherColor: DeepImmutable<Color3>): Color3;
  60346. /**
  60347. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  60348. * @param otherColor defines the second operand
  60349. * @param result defines Color3 object to store the result into
  60350. * @returns the unmodified current Color3
  60351. */
  60352. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60353. /**
  60354. * Copy the current object
  60355. * @returns a new Color3 copied the current one
  60356. */
  60357. clone(): Color3;
  60358. /**
  60359. * Copies the rgb values from the source in the current Color3
  60360. * @param source defines the source Color3 object
  60361. * @returns the updated Color3 object
  60362. */
  60363. copyFrom(source: DeepImmutable<Color3>): Color3;
  60364. /**
  60365. * Updates the Color3 rgb values from the given floats
  60366. * @param r defines the red component to read from
  60367. * @param g defines the green component to read from
  60368. * @param b defines the blue component to read from
  60369. * @returns the current Color3 object
  60370. */
  60371. copyFromFloats(r: number, g: number, b: number): Color3;
  60372. /**
  60373. * Updates the Color3 rgb values from the given floats
  60374. * @param r defines the red component to read from
  60375. * @param g defines the green component to read from
  60376. * @param b defines the blue component to read from
  60377. * @returns the current Color3 object
  60378. */
  60379. set(r: number, g: number, b: number): Color3;
  60380. /**
  60381. * Compute the Color3 hexadecimal code as a string
  60382. * @returns a string containing the hexadecimal representation of the Color3 object
  60383. */
  60384. toHexString(): string;
  60385. /**
  60386. * Computes a new Color3 converted from the current one to linear space
  60387. * @returns a new Color3 object
  60388. */
  60389. toLinearSpace(): Color3;
  60390. /**
  60391. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  60392. * @param convertedColor defines the Color3 object where to store the linear space version
  60393. * @returns the unmodified Color3
  60394. */
  60395. toLinearSpaceToRef(convertedColor: Color3): Color3;
  60396. /**
  60397. * Computes a new Color3 converted from the current one to gamma space
  60398. * @returns a new Color3 object
  60399. */
  60400. toGammaSpace(): Color3;
  60401. /**
  60402. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  60403. * @param convertedColor defines the Color3 object where to store the gamma space version
  60404. * @returns the unmodified Color3
  60405. */
  60406. toGammaSpaceToRef(convertedColor: Color3): Color3;
  60407. private static _BlackReadOnly;
  60408. /**
  60409. * Creates a new Color3 from the string containing valid hexadecimal values
  60410. * @param hex defines a string containing valid hexadecimal values
  60411. * @returns a new Color3 object
  60412. */
  60413. static FromHexString(hex: string): Color3;
  60414. /**
  60415. * Creates a new Color3 from the starting index of the given array
  60416. * @param array defines the source array
  60417. * @param offset defines an offset in the source array
  60418. * @returns a new Color3 object
  60419. */
  60420. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  60421. /**
  60422. * Creates a new Color3 from integer values (< 256)
  60423. * @param r defines the red component to read from (value between 0 and 255)
  60424. * @param g defines the green component to read from (value between 0 and 255)
  60425. * @param b defines the blue component to read from (value between 0 and 255)
  60426. * @returns a new Color3 object
  60427. */
  60428. static FromInts(r: number, g: number, b: number): Color3;
  60429. /**
  60430. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60431. * @param start defines the start Color3 value
  60432. * @param end defines the end Color3 value
  60433. * @param amount defines the gradient value between start and end
  60434. * @returns a new Color3 object
  60435. */
  60436. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  60437. /**
  60438. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60439. * @param left defines the start value
  60440. * @param right defines the end value
  60441. * @param amount defines the gradient factor
  60442. * @param result defines the Color3 object where to store the result
  60443. */
  60444. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  60445. /**
  60446. * Returns a Color3 value containing a red color
  60447. * @returns a new Color3 object
  60448. */
  60449. static Red(): Color3;
  60450. /**
  60451. * Returns a Color3 value containing a green color
  60452. * @returns a new Color3 object
  60453. */
  60454. static Green(): Color3;
  60455. /**
  60456. * Returns a Color3 value containing a blue color
  60457. * @returns a new Color3 object
  60458. */
  60459. static Blue(): Color3;
  60460. /**
  60461. * Returns a Color3 value containing a black color
  60462. * @returns a new Color3 object
  60463. */
  60464. static Black(): Color3;
  60465. /**
  60466. * Gets a Color3 value containing a black color that must not be updated
  60467. */
  60468. static readonly BlackReadOnly: DeepImmutable<Color3>;
  60469. /**
  60470. * Returns a Color3 value containing a white color
  60471. * @returns a new Color3 object
  60472. */
  60473. static White(): Color3;
  60474. /**
  60475. * Returns a Color3 value containing a purple color
  60476. * @returns a new Color3 object
  60477. */
  60478. static Purple(): Color3;
  60479. /**
  60480. * Returns a Color3 value containing a magenta color
  60481. * @returns a new Color3 object
  60482. */
  60483. static Magenta(): Color3;
  60484. /**
  60485. * Returns a Color3 value containing a yellow color
  60486. * @returns a new Color3 object
  60487. */
  60488. static Yellow(): Color3;
  60489. /**
  60490. * Returns a Color3 value containing a gray color
  60491. * @returns a new Color3 object
  60492. */
  60493. static Gray(): Color3;
  60494. /**
  60495. * Returns a Color3 value containing a teal color
  60496. * @returns a new Color3 object
  60497. */
  60498. static Teal(): Color3;
  60499. /**
  60500. * Returns a Color3 value containing a random color
  60501. * @returns a new Color3 object
  60502. */
  60503. static Random(): Color3;
  60504. }
  60505. /**
  60506. * Class used to hold a RBGA color
  60507. */
  60508. export class Color4 {
  60509. /**
  60510. * Defines the red component (between 0 and 1, default is 0)
  60511. */
  60512. r: number;
  60513. /**
  60514. * Defines the green component (between 0 and 1, default is 0)
  60515. */
  60516. g: number;
  60517. /**
  60518. * Defines the blue component (between 0 and 1, default is 0)
  60519. */
  60520. b: number;
  60521. /**
  60522. * Defines the alpha component (between 0 and 1, default is 1)
  60523. */
  60524. a: number;
  60525. /**
  60526. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60527. * @param r defines the red component (between 0 and 1, default is 0)
  60528. * @param g defines the green component (between 0 and 1, default is 0)
  60529. * @param b defines the blue component (between 0 and 1, default is 0)
  60530. * @param a defines the alpha component (between 0 and 1, default is 1)
  60531. */
  60532. constructor(
  60533. /**
  60534. * Defines the red component (between 0 and 1, default is 0)
  60535. */
  60536. r?: number,
  60537. /**
  60538. * Defines the green component (between 0 and 1, default is 0)
  60539. */
  60540. g?: number,
  60541. /**
  60542. * Defines the blue component (between 0 and 1, default is 0)
  60543. */
  60544. b?: number,
  60545. /**
  60546. * Defines the alpha component (between 0 and 1, default is 1)
  60547. */
  60548. a?: number);
  60549. /**
  60550. * Adds in place the given Color4 values to the current Color4 object
  60551. * @param right defines the second operand
  60552. * @returns the current updated Color4 object
  60553. */
  60554. addInPlace(right: DeepImmutable<Color4>): Color4;
  60555. /**
  60556. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60557. * @returns the new array
  60558. */
  60559. asArray(): number[];
  60560. /**
  60561. * Stores from the starting index in the given array the Color4 successive values
  60562. * @param array defines the array where to store the r,g,b components
  60563. * @param index defines an optional index in the target array to define where to start storing values
  60564. * @returns the current Color4 object
  60565. */
  60566. toArray(array: number[], index?: number): Color4;
  60567. /**
  60568. * Determines equality between Color4 objects
  60569. * @param otherColor defines the second operand
  60570. * @returns true if the rgba values are equal to the given ones
  60571. */
  60572. equals(otherColor: DeepImmutable<Color4>): boolean;
  60573. /**
  60574. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60575. * @param right defines the second operand
  60576. * @returns a new Color4 object
  60577. */
  60578. add(right: DeepImmutable<Color4>): Color4;
  60579. /**
  60580. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60581. * @param right defines the second operand
  60582. * @returns a new Color4 object
  60583. */
  60584. subtract(right: DeepImmutable<Color4>): Color4;
  60585. /**
  60586. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60587. * @param right defines the second operand
  60588. * @param result defines the Color4 object where to store the result
  60589. * @returns the current Color4 object
  60590. */
  60591. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60592. /**
  60593. * Creates a new Color4 with the current Color4 values multiplied by scale
  60594. * @param scale defines the scaling factor to apply
  60595. * @returns a new Color4 object
  60596. */
  60597. scale(scale: number): Color4;
  60598. /**
  60599. * Multiplies the current Color4 values by scale and stores the result in "result"
  60600. * @param scale defines the scaling factor to apply
  60601. * @param result defines the Color4 object where to store the result
  60602. * @returns the current unmodified Color4
  60603. */
  60604. scaleToRef(scale: number, result: Color4): Color4;
  60605. /**
  60606. * Scale the current Color4 values by a factor and add the result to a given Color4
  60607. * @param scale defines the scale factor
  60608. * @param result defines the Color4 object where to store the result
  60609. * @returns the unmodified current Color4
  60610. */
  60611. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60612. /**
  60613. * Clamps the rgb values by the min and max values and stores the result into "result"
  60614. * @param min defines minimum clamping value (default is 0)
  60615. * @param max defines maximum clamping value (default is 1)
  60616. * @param result defines color to store the result into.
  60617. * @returns the cuurent Color4
  60618. */
  60619. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60620. /**
  60621. * Multipy an Color4 value by another and return a new Color4 object
  60622. * @param color defines the Color4 value to multiply by
  60623. * @returns a new Color4 object
  60624. */
  60625. multiply(color: Color4): Color4;
  60626. /**
  60627. * Multipy a Color4 value by another and push the result in a reference value
  60628. * @param color defines the Color4 value to multiply by
  60629. * @param result defines the Color4 to fill the result in
  60630. * @returns the result Color4
  60631. */
  60632. multiplyToRef(color: Color4, result: Color4): Color4;
  60633. /**
  60634. * Creates a string with the Color4 current values
  60635. * @returns the string representation of the Color4 object
  60636. */
  60637. toString(): string;
  60638. /**
  60639. * Returns the string "Color4"
  60640. * @returns "Color4"
  60641. */
  60642. getClassName(): string;
  60643. /**
  60644. * Compute the Color4 hash code
  60645. * @returns an unique number that can be used to hash Color4 objects
  60646. */
  60647. getHashCode(): number;
  60648. /**
  60649. * Creates a new Color4 copied from the current one
  60650. * @returns a new Color4 object
  60651. */
  60652. clone(): Color4;
  60653. /**
  60654. * Copies the given Color4 values into the current one
  60655. * @param source defines the source Color4 object
  60656. * @returns the current updated Color4 object
  60657. */
  60658. copyFrom(source: Color4): Color4;
  60659. /**
  60660. * Copies the given float values into the current one
  60661. * @param r defines the red component to read from
  60662. * @param g defines the green component to read from
  60663. * @param b defines the blue component to read from
  60664. * @param a defines the alpha component to read from
  60665. * @returns the current updated Color4 object
  60666. */
  60667. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60668. /**
  60669. * Copies the given float values into the current one
  60670. * @param r defines the red component to read from
  60671. * @param g defines the green component to read from
  60672. * @param b defines the blue component to read from
  60673. * @param a defines the alpha component to read from
  60674. * @returns the current updated Color4 object
  60675. */
  60676. set(r: number, g: number, b: number, a: number): Color4;
  60677. /**
  60678. * Compute the Color4 hexadecimal code as a string
  60679. * @returns a string containing the hexadecimal representation of the Color4 object
  60680. */
  60681. toHexString(): string;
  60682. /**
  60683. * Computes a new Color4 converted from the current one to linear space
  60684. * @returns a new Color4 object
  60685. */
  60686. toLinearSpace(): Color4;
  60687. /**
  60688. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60689. * @param convertedColor defines the Color4 object where to store the linear space version
  60690. * @returns the unmodified Color4
  60691. */
  60692. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60693. /**
  60694. * Computes a new Color4 converted from the current one to gamma space
  60695. * @returns a new Color4 object
  60696. */
  60697. toGammaSpace(): Color4;
  60698. /**
  60699. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60700. * @param convertedColor defines the Color4 object where to store the gamma space version
  60701. * @returns the unmodified Color4
  60702. */
  60703. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60704. /**
  60705. * Creates a new Color4 from the string containing valid hexadecimal values
  60706. * @param hex defines a string containing valid hexadecimal values
  60707. * @returns a new Color4 object
  60708. */
  60709. static FromHexString(hex: string): Color4;
  60710. /**
  60711. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60712. * @param left defines the start value
  60713. * @param right defines the end value
  60714. * @param amount defines the gradient factor
  60715. * @returns a new Color4 object
  60716. */
  60717. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60718. /**
  60719. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60720. * @param left defines the start value
  60721. * @param right defines the end value
  60722. * @param amount defines the gradient factor
  60723. * @param result defines the Color4 object where to store data
  60724. */
  60725. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60726. /**
  60727. * Creates a new Color4 from a Color3 and an alpha value
  60728. * @param color3 defines the source Color3 to read from
  60729. * @param alpha defines the alpha component (1.0 by default)
  60730. * @returns a new Color4 object
  60731. */
  60732. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60733. /**
  60734. * Creates a new Color4 from the starting index element of the given array
  60735. * @param array defines the source array to read from
  60736. * @param offset defines the offset in the source array
  60737. * @returns a new Color4 object
  60738. */
  60739. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60740. /**
  60741. * Creates a new Color3 from integer values (< 256)
  60742. * @param r defines the red component to read from (value between 0 and 255)
  60743. * @param g defines the green component to read from (value between 0 and 255)
  60744. * @param b defines the blue component to read from (value between 0 and 255)
  60745. * @param a defines the alpha component to read from (value between 0 and 255)
  60746. * @returns a new Color3 object
  60747. */
  60748. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60749. /**
  60750. * Check the content of a given array and convert it to an array containing RGBA data
  60751. * If the original array was already containing count * 4 values then it is returned directly
  60752. * @param colors defines the array to check
  60753. * @param count defines the number of RGBA data to expect
  60754. * @returns an array containing count * 4 values (RGBA)
  60755. */
  60756. static CheckColors4(colors: number[], count: number): number[];
  60757. }
  60758. /**
  60759. * Class representing a vector containing 2 coordinates
  60760. */
  60761. export class Vector2 {
  60762. /** defines the first coordinate */
  60763. x: number;
  60764. /** defines the second coordinate */
  60765. y: number;
  60766. /**
  60767. * Creates a new Vector2 from the given x and y coordinates
  60768. * @param x defines the first coordinate
  60769. * @param y defines the second coordinate
  60770. */
  60771. constructor(
  60772. /** defines the first coordinate */
  60773. x?: number,
  60774. /** defines the second coordinate */
  60775. y?: number);
  60776. /**
  60777. * Gets a string with the Vector2 coordinates
  60778. * @returns a string with the Vector2 coordinates
  60779. */
  60780. toString(): string;
  60781. /**
  60782. * Gets class name
  60783. * @returns the string "Vector2"
  60784. */
  60785. getClassName(): string;
  60786. /**
  60787. * Gets current vector hash code
  60788. * @returns the Vector2 hash code as a number
  60789. */
  60790. getHashCode(): number;
  60791. /**
  60792. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60793. * @param array defines the source array
  60794. * @param index defines the offset in source array
  60795. * @returns the current Vector2
  60796. */
  60797. toArray(array: FloatArray, index?: number): Vector2;
  60798. /**
  60799. * Copy the current vector to an array
  60800. * @returns a new array with 2 elements: the Vector2 coordinates.
  60801. */
  60802. asArray(): number[];
  60803. /**
  60804. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60805. * @param source defines the source Vector2
  60806. * @returns the current updated Vector2
  60807. */
  60808. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60809. /**
  60810. * Sets the Vector2 coordinates with the given floats
  60811. * @param x defines the first coordinate
  60812. * @param y defines the second coordinate
  60813. * @returns the current updated Vector2
  60814. */
  60815. copyFromFloats(x: number, y: number): Vector2;
  60816. /**
  60817. * Sets the Vector2 coordinates with the given floats
  60818. * @param x defines the first coordinate
  60819. * @param y defines the second coordinate
  60820. * @returns the current updated Vector2
  60821. */
  60822. set(x: number, y: number): Vector2;
  60823. /**
  60824. * Add another vector with the current one
  60825. * @param otherVector defines the other vector
  60826. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60827. */
  60828. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60829. /**
  60830. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60831. * @param otherVector defines the other vector
  60832. * @param result defines the target vector
  60833. * @returns the unmodified current Vector2
  60834. */
  60835. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60836. /**
  60837. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60838. * @param otherVector defines the other vector
  60839. * @returns the current updated Vector2
  60840. */
  60841. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60842. /**
  60843. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60844. * @param otherVector defines the other vector
  60845. * @returns a new Vector2
  60846. */
  60847. addVector3(otherVector: Vector3): Vector2;
  60848. /**
  60849. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60850. * @param otherVector defines the other vector
  60851. * @returns a new Vector2
  60852. */
  60853. subtract(otherVector: Vector2): Vector2;
  60854. /**
  60855. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60856. * @param otherVector defines the other vector
  60857. * @param result defines the target vector
  60858. * @returns the unmodified current Vector2
  60859. */
  60860. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60861. /**
  60862. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60863. * @param otherVector defines the other vector
  60864. * @returns the current updated Vector2
  60865. */
  60866. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60867. /**
  60868. * Multiplies in place the current Vector2 coordinates by the given ones
  60869. * @param otherVector defines the other vector
  60870. * @returns the current updated Vector2
  60871. */
  60872. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60873. /**
  60874. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60875. * @param otherVector defines the other vector
  60876. * @returns a new Vector2
  60877. */
  60878. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60879. /**
  60880. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60881. * @param otherVector defines the other vector
  60882. * @param result defines the target vector
  60883. * @returns the unmodified current Vector2
  60884. */
  60885. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60886. /**
  60887. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60888. * @param x defines the first coordinate
  60889. * @param y defines the second coordinate
  60890. * @returns a new Vector2
  60891. */
  60892. multiplyByFloats(x: number, y: number): Vector2;
  60893. /**
  60894. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60895. * @param otherVector defines the other vector
  60896. * @returns a new Vector2
  60897. */
  60898. divide(otherVector: Vector2): Vector2;
  60899. /**
  60900. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60901. * @param otherVector defines the other vector
  60902. * @param result defines the target vector
  60903. * @returns the unmodified current Vector2
  60904. */
  60905. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60906. /**
  60907. * Divides the current Vector2 coordinates by the given ones
  60908. * @param otherVector defines the other vector
  60909. * @returns the current updated Vector2
  60910. */
  60911. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60912. /**
  60913. * Gets a new Vector2 with current Vector2 negated coordinates
  60914. * @returns a new Vector2
  60915. */
  60916. negate(): Vector2;
  60917. /**
  60918. * Multiply the Vector2 coordinates by scale
  60919. * @param scale defines the scaling factor
  60920. * @returns the current updated Vector2
  60921. */
  60922. scaleInPlace(scale: number): Vector2;
  60923. /**
  60924. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60925. * @param scale defines the scaling factor
  60926. * @returns a new Vector2
  60927. */
  60928. scale(scale: number): Vector2;
  60929. /**
  60930. * Scale the current Vector2 values by a factor to a given Vector2
  60931. * @param scale defines the scale factor
  60932. * @param result defines the Vector2 object where to store the result
  60933. * @returns the unmodified current Vector2
  60934. */
  60935. scaleToRef(scale: number, result: Vector2): Vector2;
  60936. /**
  60937. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60938. * @param scale defines the scale factor
  60939. * @param result defines the Vector2 object where to store the result
  60940. * @returns the unmodified current Vector2
  60941. */
  60942. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60943. /**
  60944. * Gets a boolean if two vectors are equals
  60945. * @param otherVector defines the other vector
  60946. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60947. */
  60948. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60949. /**
  60950. * Gets a boolean if two vectors are equals (using an epsilon value)
  60951. * @param otherVector defines the other vector
  60952. * @param epsilon defines the minimal distance to consider equality
  60953. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60954. */
  60955. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60956. /**
  60957. * Gets a new Vector2 from current Vector2 floored values
  60958. * @returns a new Vector2
  60959. */
  60960. floor(): Vector2;
  60961. /**
  60962. * Gets a new Vector2 from current Vector2 floored values
  60963. * @returns a new Vector2
  60964. */
  60965. fract(): Vector2;
  60966. /**
  60967. * Gets the length of the vector
  60968. * @returns the vector length (float)
  60969. */
  60970. length(): number;
  60971. /**
  60972. * Gets the vector squared length
  60973. * @returns the vector squared length (float)
  60974. */
  60975. lengthSquared(): number;
  60976. /**
  60977. * Normalize the vector
  60978. * @returns the current updated Vector2
  60979. */
  60980. normalize(): Vector2;
  60981. /**
  60982. * Gets a new Vector2 copied from the Vector2
  60983. * @returns a new Vector2
  60984. */
  60985. clone(): Vector2;
  60986. /**
  60987. * Gets a new Vector2(0, 0)
  60988. * @returns a new Vector2
  60989. */
  60990. static Zero(): Vector2;
  60991. /**
  60992. * Gets a new Vector2(1, 1)
  60993. * @returns a new Vector2
  60994. */
  60995. static One(): Vector2;
  60996. /**
  60997. * Gets a new Vector2 set from the given index element of the given array
  60998. * @param array defines the data source
  60999. * @param offset defines the offset in the data source
  61000. * @returns a new Vector2
  61001. */
  61002. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  61003. /**
  61004. * Sets "result" from the given index element of the given array
  61005. * @param array defines the data source
  61006. * @param offset defines the offset in the data source
  61007. * @param result defines the target vector
  61008. */
  61009. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  61010. /**
  61011. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  61012. * @param value1 defines 1st point of control
  61013. * @param value2 defines 2nd point of control
  61014. * @param value3 defines 3rd point of control
  61015. * @param value4 defines 4th point of control
  61016. * @param amount defines the interpolation factor
  61017. * @returns a new Vector2
  61018. */
  61019. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  61020. /**
  61021. * 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".
  61022. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  61023. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  61024. * @param value defines the value to clamp
  61025. * @param min defines the lower limit
  61026. * @param max defines the upper limit
  61027. * @returns a new Vector2
  61028. */
  61029. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  61030. /**
  61031. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  61032. * @param value1 defines the 1st control point
  61033. * @param tangent1 defines the outgoing tangent
  61034. * @param value2 defines the 2nd control point
  61035. * @param tangent2 defines the incoming tangent
  61036. * @param amount defines the interpolation factor
  61037. * @returns a new Vector2
  61038. */
  61039. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  61040. /**
  61041. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  61042. * @param start defines the start vector
  61043. * @param end defines the end vector
  61044. * @param amount defines the interpolation factor
  61045. * @returns a new Vector2
  61046. */
  61047. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  61048. /**
  61049. * Gets the dot product of the vector "left" and the vector "right"
  61050. * @param left defines first vector
  61051. * @param right defines second vector
  61052. * @returns the dot product (float)
  61053. */
  61054. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  61055. /**
  61056. * Returns a new Vector2 equal to the normalized given vector
  61057. * @param vector defines the vector to normalize
  61058. * @returns a new Vector2
  61059. */
  61060. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  61061. /**
  61062. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  61063. * @param left defines 1st vector
  61064. * @param right defines 2nd vector
  61065. * @returns a new Vector2
  61066. */
  61067. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61068. /**
  61069. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  61070. * @param left defines 1st vector
  61071. * @param right defines 2nd vector
  61072. * @returns a new Vector2
  61073. */
  61074. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61075. /**
  61076. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  61077. * @param vector defines the vector to transform
  61078. * @param transformation defines the matrix to apply
  61079. * @returns a new Vector2
  61080. */
  61081. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  61082. /**
  61083. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  61084. * @param vector defines the vector to transform
  61085. * @param transformation defines the matrix to apply
  61086. * @param result defines the target vector
  61087. */
  61088. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  61089. /**
  61090. * Determines if a given vector is included in a triangle
  61091. * @param p defines the vector to test
  61092. * @param p0 defines 1st triangle point
  61093. * @param p1 defines 2nd triangle point
  61094. * @param p2 defines 3rd triangle point
  61095. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  61096. */
  61097. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  61098. /**
  61099. * Gets the distance between the vectors "value1" and "value2"
  61100. * @param value1 defines first vector
  61101. * @param value2 defines second vector
  61102. * @returns the distance between vectors
  61103. */
  61104. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61105. /**
  61106. * Returns the squared distance between the vectors "value1" and "value2"
  61107. * @param value1 defines first vector
  61108. * @param value2 defines second vector
  61109. * @returns the squared distance between vectors
  61110. */
  61111. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61112. /**
  61113. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  61114. * @param value1 defines first vector
  61115. * @param value2 defines second vector
  61116. * @returns a new Vector2
  61117. */
  61118. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  61119. /**
  61120. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  61121. * @param p defines the middle point
  61122. * @param segA defines one point of the segment
  61123. * @param segB defines the other point of the segment
  61124. * @returns the shortest distance
  61125. */
  61126. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  61127. }
  61128. /**
  61129. * Classed used to store (x,y,z) vector representation
  61130. * A Vector3 is the main object used in 3D geometry
  61131. * It can represent etiher the coordinates of a point the space, either a direction
  61132. * Reminder: js uses a left handed forward facing system
  61133. */
  61134. export class Vector3 {
  61135. /**
  61136. * Defines the first coordinates (on X axis)
  61137. */
  61138. x: number;
  61139. /**
  61140. * Defines the second coordinates (on Y axis)
  61141. */
  61142. y: number;
  61143. /**
  61144. * Defines the third coordinates (on Z axis)
  61145. */
  61146. z: number;
  61147. private static _UpReadOnly;
  61148. /**
  61149. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  61150. * @param x defines the first coordinates (on X axis)
  61151. * @param y defines the second coordinates (on Y axis)
  61152. * @param z defines the third coordinates (on Z axis)
  61153. */
  61154. constructor(
  61155. /**
  61156. * Defines the first coordinates (on X axis)
  61157. */
  61158. x?: number,
  61159. /**
  61160. * Defines the second coordinates (on Y axis)
  61161. */
  61162. y?: number,
  61163. /**
  61164. * Defines the third coordinates (on Z axis)
  61165. */
  61166. z?: number);
  61167. /**
  61168. * Creates a string representation of the Vector3
  61169. * @returns a string with the Vector3 coordinates.
  61170. */
  61171. toString(): string;
  61172. /**
  61173. * Gets the class name
  61174. * @returns the string "Vector3"
  61175. */
  61176. getClassName(): string;
  61177. /**
  61178. * Creates the Vector3 hash code
  61179. * @returns a number which tends to be unique between Vector3 instances
  61180. */
  61181. getHashCode(): number;
  61182. /**
  61183. * Creates an array containing three elements : the coordinates of the Vector3
  61184. * @returns a new array of numbers
  61185. */
  61186. asArray(): number[];
  61187. /**
  61188. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  61189. * @param array defines the destination array
  61190. * @param index defines the offset in the destination array
  61191. * @returns the current Vector3
  61192. */
  61193. toArray(array: FloatArray, index?: number): Vector3;
  61194. /**
  61195. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  61196. * @returns a new Quaternion object, computed from the Vector3 coordinates
  61197. */
  61198. toQuaternion(): Quaternion;
  61199. /**
  61200. * Adds the given vector to the current Vector3
  61201. * @param otherVector defines the second operand
  61202. * @returns the current updated Vector3
  61203. */
  61204. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61205. /**
  61206. * Adds the given coordinates to the current Vector3
  61207. * @param x defines the x coordinate of the operand
  61208. * @param y defines the y coordinate of the operand
  61209. * @param z defines the z coordinate of the operand
  61210. * @returns the current updated Vector3
  61211. */
  61212. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61213. /**
  61214. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  61215. * @param otherVector defines the second operand
  61216. * @returns the resulting Vector3
  61217. */
  61218. add(otherVector: DeepImmutable<Vector3>): Vector3;
  61219. /**
  61220. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  61221. * @param otherVector defines the second operand
  61222. * @param result defines the Vector3 object where to store the result
  61223. * @returns the current Vector3
  61224. */
  61225. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61226. /**
  61227. * Subtract the given vector from the current Vector3
  61228. * @param otherVector defines the second operand
  61229. * @returns the current updated Vector3
  61230. */
  61231. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61232. /**
  61233. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  61234. * @param otherVector defines the second operand
  61235. * @returns the resulting Vector3
  61236. */
  61237. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  61238. /**
  61239. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  61240. * @param otherVector defines the second operand
  61241. * @param result defines the Vector3 object where to store the result
  61242. * @returns the current Vector3
  61243. */
  61244. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61245. /**
  61246. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  61247. * @param x defines the x coordinate of the operand
  61248. * @param y defines the y coordinate of the operand
  61249. * @param z defines the z coordinate of the operand
  61250. * @returns the resulting Vector3
  61251. */
  61252. subtractFromFloats(x: number, y: number, z: number): Vector3;
  61253. /**
  61254. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  61255. * @param x defines the x coordinate of the operand
  61256. * @param y defines the y coordinate of the operand
  61257. * @param z defines the z coordinate of the operand
  61258. * @param result defines the Vector3 object where to store the result
  61259. * @returns the current Vector3
  61260. */
  61261. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  61262. /**
  61263. * Gets a new Vector3 set with the current Vector3 negated coordinates
  61264. * @returns a new Vector3
  61265. */
  61266. negate(): Vector3;
  61267. /**
  61268. * Multiplies the Vector3 coordinates by the float "scale"
  61269. * @param scale defines the multiplier factor
  61270. * @returns the current updated Vector3
  61271. */
  61272. scaleInPlace(scale: number): Vector3;
  61273. /**
  61274. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  61275. * @param scale defines the multiplier factor
  61276. * @returns a new Vector3
  61277. */
  61278. scale(scale: number): Vector3;
  61279. /**
  61280. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  61281. * @param scale defines the multiplier factor
  61282. * @param result defines the Vector3 object where to store the result
  61283. * @returns the current Vector3
  61284. */
  61285. scaleToRef(scale: number, result: Vector3): Vector3;
  61286. /**
  61287. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  61288. * @param scale defines the scale factor
  61289. * @param result defines the Vector3 object where to store the result
  61290. * @returns the unmodified current Vector3
  61291. */
  61292. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  61293. /**
  61294. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  61295. * @param otherVector defines the second operand
  61296. * @returns true if both vectors are equals
  61297. */
  61298. equals(otherVector: DeepImmutable<Vector3>): boolean;
  61299. /**
  61300. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  61301. * @param otherVector defines the second operand
  61302. * @param epsilon defines the minimal distance to define values as equals
  61303. * @returns true if both vectors are distant less than epsilon
  61304. */
  61305. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  61306. /**
  61307. * Returns true if the current Vector3 coordinates equals the given floats
  61308. * @param x defines the x coordinate of the operand
  61309. * @param y defines the y coordinate of the operand
  61310. * @param z defines the z coordinate of the operand
  61311. * @returns true if both vectors are equals
  61312. */
  61313. equalsToFloats(x: number, y: number, z: number): boolean;
  61314. /**
  61315. * Multiplies the current Vector3 coordinates by the given ones
  61316. * @param otherVector defines the second operand
  61317. * @returns the current updated Vector3
  61318. */
  61319. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61320. /**
  61321. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  61322. * @param otherVector defines the second operand
  61323. * @returns the new Vector3
  61324. */
  61325. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  61326. /**
  61327. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  61328. * @param otherVector defines the second operand
  61329. * @param result defines the Vector3 object where to store the result
  61330. * @returns the current Vector3
  61331. */
  61332. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61333. /**
  61334. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  61335. * @param x defines the x coordinate of the operand
  61336. * @param y defines the y coordinate of the operand
  61337. * @param z defines the z coordinate of the operand
  61338. * @returns the new Vector3
  61339. */
  61340. multiplyByFloats(x: number, y: number, z: number): Vector3;
  61341. /**
  61342. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  61343. * @param otherVector defines the second operand
  61344. * @returns the new Vector3
  61345. */
  61346. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  61347. /**
  61348. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  61349. * @param otherVector defines the second operand
  61350. * @param result defines the Vector3 object where to store the result
  61351. * @returns the current Vector3
  61352. */
  61353. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61354. /**
  61355. * Divides the current Vector3 coordinates by the given ones.
  61356. * @param otherVector defines the second operand
  61357. * @returns the current updated Vector3
  61358. */
  61359. divideInPlace(otherVector: Vector3): Vector3;
  61360. /**
  61361. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  61362. * @param other defines the second operand
  61363. * @returns the current updated Vector3
  61364. */
  61365. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61366. /**
  61367. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  61368. * @param other defines the second operand
  61369. * @returns the current updated Vector3
  61370. */
  61371. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61372. /**
  61373. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  61374. * @param x defines the x coordinate of the operand
  61375. * @param y defines the y coordinate of the operand
  61376. * @param z defines the z coordinate of the operand
  61377. * @returns the current updated Vector3
  61378. */
  61379. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61380. /**
  61381. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  61382. * @param x defines the x coordinate of the operand
  61383. * @param y defines the y coordinate of the operand
  61384. * @param z defines the z coordinate of the operand
  61385. * @returns the current updated Vector3
  61386. */
  61387. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61388. /**
  61389. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  61390. * Check if is non uniform within a certain amount of decimal places to account for this
  61391. * @param epsilon the amount the values can differ
  61392. * @returns if the the vector is non uniform to a certain number of decimal places
  61393. */
  61394. isNonUniformWithinEpsilon(epsilon: number): boolean;
  61395. /**
  61396. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  61397. */
  61398. readonly isNonUniform: boolean;
  61399. /**
  61400. * Gets a new Vector3 from current Vector3 floored values
  61401. * @returns a new Vector3
  61402. */
  61403. floor(): Vector3;
  61404. /**
  61405. * Gets a new Vector3 from current Vector3 floored values
  61406. * @returns a new Vector3
  61407. */
  61408. fract(): Vector3;
  61409. /**
  61410. * Gets the length of the Vector3
  61411. * @returns the length of the Vecto3
  61412. */
  61413. length(): number;
  61414. /**
  61415. * Gets the squared length of the Vector3
  61416. * @returns squared length of the Vector3
  61417. */
  61418. lengthSquared(): number;
  61419. /**
  61420. * Normalize the current Vector3.
  61421. * Please note that this is an in place operation.
  61422. * @returns the current updated Vector3
  61423. */
  61424. normalize(): Vector3;
  61425. /**
  61426. * Reorders the x y z properties of the vector in place
  61427. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  61428. * @returns the current updated vector
  61429. */
  61430. reorderInPlace(order: string): this;
  61431. /**
  61432. * Rotates the vector around 0,0,0 by a quaternion
  61433. * @param quaternion the rotation quaternion
  61434. * @param result vector to store the result
  61435. * @returns the resulting vector
  61436. */
  61437. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  61438. /**
  61439. * Rotates a vector around a given point
  61440. * @param quaternion the rotation quaternion
  61441. * @param point the point to rotate around
  61442. * @param result vector to store the result
  61443. * @returns the resulting vector
  61444. */
  61445. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  61446. /**
  61447. * Normalize the current Vector3 with the given input length.
  61448. * Please note that this is an in place operation.
  61449. * @param len the length of the vector
  61450. * @returns the current updated Vector3
  61451. */
  61452. normalizeFromLength(len: number): Vector3;
  61453. /**
  61454. * Normalize the current Vector3 to a new vector
  61455. * @returns the new Vector3
  61456. */
  61457. normalizeToNew(): Vector3;
  61458. /**
  61459. * Normalize the current Vector3 to the reference
  61460. * @param reference define the Vector3 to update
  61461. * @returns the updated Vector3
  61462. */
  61463. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  61464. /**
  61465. * Creates a new Vector3 copied from the current Vector3
  61466. * @returns the new Vector3
  61467. */
  61468. clone(): Vector3;
  61469. /**
  61470. * Copies the given vector coordinates to the current Vector3 ones
  61471. * @param source defines the source Vector3
  61472. * @returns the current updated Vector3
  61473. */
  61474. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  61475. /**
  61476. * Copies the given floats to the current Vector3 coordinates
  61477. * @param x defines the x coordinate of the operand
  61478. * @param y defines the y coordinate of the operand
  61479. * @param z defines the z coordinate of the operand
  61480. * @returns the current updated Vector3
  61481. */
  61482. copyFromFloats(x: number, y: number, z: number): Vector3;
  61483. /**
  61484. * Copies the given floats to the current Vector3 coordinates
  61485. * @param x defines the x coordinate of the operand
  61486. * @param y defines the y coordinate of the operand
  61487. * @param z defines the z coordinate of the operand
  61488. * @returns the current updated Vector3
  61489. */
  61490. set(x: number, y: number, z: number): Vector3;
  61491. /**
  61492. * Copies the given float to the current Vector3 coordinates
  61493. * @param v defines the x, y and z coordinates of the operand
  61494. * @returns the current updated Vector3
  61495. */
  61496. setAll(v: number): Vector3;
  61497. /**
  61498. * Get the clip factor between two vectors
  61499. * @param vector0 defines the first operand
  61500. * @param vector1 defines the second operand
  61501. * @param axis defines the axis to use
  61502. * @param size defines the size along the axis
  61503. * @returns the clip factor
  61504. */
  61505. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  61506. /**
  61507. * Get angle between two vectors
  61508. * @param vector0 angle between vector0 and vector1
  61509. * @param vector1 angle between vector0 and vector1
  61510. * @param normal direction of the normal
  61511. * @return the angle between vector0 and vector1
  61512. */
  61513. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61514. /**
  61515. * Returns a new Vector3 set from the index "offset" of the given array
  61516. * @param array defines the source array
  61517. * @param offset defines the offset in the source array
  61518. * @returns the new Vector3
  61519. */
  61520. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61521. /**
  61522. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61523. * This function is deprecated. Use FromArray instead
  61524. * @param array defines the source array
  61525. * @param offset defines the offset in the source array
  61526. * @returns the new Vector3
  61527. */
  61528. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61529. /**
  61530. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61531. * @param array defines the source array
  61532. * @param offset defines the offset in the source array
  61533. * @param result defines the Vector3 where to store the result
  61534. */
  61535. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61536. /**
  61537. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61538. * This function is deprecated. Use FromArrayToRef instead.
  61539. * @param array defines the source array
  61540. * @param offset defines the offset in the source array
  61541. * @param result defines the Vector3 where to store the result
  61542. */
  61543. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61544. /**
  61545. * Sets the given vector "result" with the given floats.
  61546. * @param x defines the x coordinate of the source
  61547. * @param y defines the y coordinate of the source
  61548. * @param z defines the z coordinate of the source
  61549. * @param result defines the Vector3 where to store the result
  61550. */
  61551. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61552. /**
  61553. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61554. * @returns a new empty Vector3
  61555. */
  61556. static Zero(): Vector3;
  61557. /**
  61558. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61559. * @returns a new unit Vector3
  61560. */
  61561. static One(): Vector3;
  61562. /**
  61563. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61564. * @returns a new up Vector3
  61565. */
  61566. static Up(): Vector3;
  61567. /**
  61568. * Gets a up Vector3 that must not be updated
  61569. */
  61570. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61571. /**
  61572. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61573. * @returns a new down Vector3
  61574. */
  61575. static Down(): Vector3;
  61576. /**
  61577. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61578. * @returns a new forward Vector3
  61579. */
  61580. static Forward(): Vector3;
  61581. /**
  61582. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61583. * @returns a new forward Vector3
  61584. */
  61585. static Backward(): Vector3;
  61586. /**
  61587. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61588. * @returns a new right Vector3
  61589. */
  61590. static Right(): Vector3;
  61591. /**
  61592. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61593. * @returns a new left Vector3
  61594. */
  61595. static Left(): Vector3;
  61596. /**
  61597. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61598. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61599. * @param vector defines the Vector3 to transform
  61600. * @param transformation defines the transformation matrix
  61601. * @returns the transformed Vector3
  61602. */
  61603. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61604. /**
  61605. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61606. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61607. * @param vector defines the Vector3 to transform
  61608. * @param transformation defines the transformation matrix
  61609. * @param result defines the Vector3 where to store the result
  61610. */
  61611. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61612. /**
  61613. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61614. * This method computes tranformed coordinates only, not transformed direction vectors
  61615. * @param x define the x coordinate of the source vector
  61616. * @param y define the y coordinate of the source vector
  61617. * @param z define the z coordinate of the source vector
  61618. * @param transformation defines the transformation matrix
  61619. * @param result defines the Vector3 where to store the result
  61620. */
  61621. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61622. /**
  61623. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61624. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61625. * @param vector defines the Vector3 to transform
  61626. * @param transformation defines the transformation matrix
  61627. * @returns the new Vector3
  61628. */
  61629. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61630. /**
  61631. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61632. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61633. * @param vector defines the Vector3 to transform
  61634. * @param transformation defines the transformation matrix
  61635. * @param result defines the Vector3 where to store the result
  61636. */
  61637. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61638. /**
  61639. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61640. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61641. * @param x define the x coordinate of the source vector
  61642. * @param y define the y coordinate of the source vector
  61643. * @param z define the z coordinate of the source vector
  61644. * @param transformation defines the transformation matrix
  61645. * @param result defines the Vector3 where to store the result
  61646. */
  61647. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61648. /**
  61649. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61650. * @param value1 defines the first control point
  61651. * @param value2 defines the second control point
  61652. * @param value3 defines the third control point
  61653. * @param value4 defines the fourth control point
  61654. * @param amount defines the amount on the spline to use
  61655. * @returns the new Vector3
  61656. */
  61657. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61658. /**
  61659. * 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"
  61660. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61661. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61662. * @param value defines the current value
  61663. * @param min defines the lower range value
  61664. * @param max defines the upper range value
  61665. * @returns the new Vector3
  61666. */
  61667. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61668. /**
  61669. * 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"
  61670. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61671. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61672. * @param value defines the current value
  61673. * @param min defines the lower range value
  61674. * @param max defines the upper range value
  61675. * @param result defines the Vector3 where to store the result
  61676. */
  61677. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61678. /**
  61679. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61680. * @param value1 defines the first control point
  61681. * @param tangent1 defines the first tangent vector
  61682. * @param value2 defines the second control point
  61683. * @param tangent2 defines the second tangent vector
  61684. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61685. * @returns the new Vector3
  61686. */
  61687. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61688. /**
  61689. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61690. * @param start defines the start value
  61691. * @param end defines the end value
  61692. * @param amount max defines amount between both (between 0 and 1)
  61693. * @returns the new Vector3
  61694. */
  61695. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61696. /**
  61697. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61698. * @param start defines the start value
  61699. * @param end defines the end value
  61700. * @param amount max defines amount between both (between 0 and 1)
  61701. * @param result defines the Vector3 where to store the result
  61702. */
  61703. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61704. /**
  61705. * Returns the dot product (float) between the vectors "left" and "right"
  61706. * @param left defines the left operand
  61707. * @param right defines the right operand
  61708. * @returns the dot product
  61709. */
  61710. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61711. /**
  61712. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61713. * The cross product is then orthogonal to both "left" and "right"
  61714. * @param left defines the left operand
  61715. * @param right defines the right operand
  61716. * @returns the cross product
  61717. */
  61718. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61719. /**
  61720. * Sets the given vector "result" with the cross product of "left" and "right"
  61721. * The cross product is then orthogonal to both "left" and "right"
  61722. * @param left defines the left operand
  61723. * @param right defines the right operand
  61724. * @param result defines the Vector3 where to store the result
  61725. */
  61726. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61727. /**
  61728. * Returns a new Vector3 as the normalization of the given vector
  61729. * @param vector defines the Vector3 to normalize
  61730. * @returns the new Vector3
  61731. */
  61732. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61733. /**
  61734. * Sets the given vector "result" with the normalization of the given first vector
  61735. * @param vector defines the Vector3 to normalize
  61736. * @param result defines the Vector3 where to store the result
  61737. */
  61738. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61739. /**
  61740. * Project a Vector3 onto screen space
  61741. * @param vector defines the Vector3 to project
  61742. * @param world defines the world matrix to use
  61743. * @param transform defines the transform (view x projection) matrix to use
  61744. * @param viewport defines the screen viewport to use
  61745. * @returns the new Vector3
  61746. */
  61747. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61748. /** @hidden */
  61749. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61750. /**
  61751. * Unproject from screen space to object space
  61752. * @param source defines the screen space Vector3 to use
  61753. * @param viewportWidth defines the current width of the viewport
  61754. * @param viewportHeight defines the current height of the viewport
  61755. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61756. * @param transform defines the transform (view x projection) matrix to use
  61757. * @returns the new Vector3
  61758. */
  61759. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61760. /**
  61761. * Unproject from screen space to object space
  61762. * @param source defines the screen space Vector3 to use
  61763. * @param viewportWidth defines the current width of the viewport
  61764. * @param viewportHeight defines the current height of the viewport
  61765. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61766. * @param view defines the view matrix to use
  61767. * @param projection defines the projection matrix to use
  61768. * @returns the new Vector3
  61769. */
  61770. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61771. /**
  61772. * Unproject from screen space to object space
  61773. * @param source defines the screen space Vector3 to use
  61774. * @param viewportWidth defines the current width of the viewport
  61775. * @param viewportHeight defines the current height of the viewport
  61776. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61777. * @param view defines the view matrix to use
  61778. * @param projection defines the projection matrix to use
  61779. * @param result defines the Vector3 where to store the result
  61780. */
  61781. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61782. /**
  61783. * Unproject from screen space to object space
  61784. * @param sourceX defines the screen space x coordinate to use
  61785. * @param sourceY defines the screen space y coordinate to use
  61786. * @param sourceZ defines the screen space z coordinate to use
  61787. * @param viewportWidth defines the current width of the viewport
  61788. * @param viewportHeight defines the current height of the viewport
  61789. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61790. * @param view defines the view matrix to use
  61791. * @param projection defines the projection matrix to use
  61792. * @param result defines the Vector3 where to store the result
  61793. */
  61794. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61795. /**
  61796. * Gets the minimal coordinate values between two Vector3
  61797. * @param left defines the first operand
  61798. * @param right defines the second operand
  61799. * @returns the new Vector3
  61800. */
  61801. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61802. /**
  61803. * Gets the maximal coordinate values between two Vector3
  61804. * @param left defines the first operand
  61805. * @param right defines the second operand
  61806. * @returns the new Vector3
  61807. */
  61808. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61809. /**
  61810. * Returns the distance between the vectors "value1" and "value2"
  61811. * @param value1 defines the first operand
  61812. * @param value2 defines the second operand
  61813. * @returns the distance
  61814. */
  61815. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61816. /**
  61817. * Returns the squared distance between the vectors "value1" and "value2"
  61818. * @param value1 defines the first operand
  61819. * @param value2 defines the second operand
  61820. * @returns the squared distance
  61821. */
  61822. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61823. /**
  61824. * Returns a new Vector3 located at the center between "value1" and "value2"
  61825. * @param value1 defines the first operand
  61826. * @param value2 defines the second operand
  61827. * @returns the new Vector3
  61828. */
  61829. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61830. /**
  61831. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61832. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61833. * to something in order to rotate it from its local system to the given target system
  61834. * Note: axis1, axis2 and axis3 are normalized during this operation
  61835. * @param axis1 defines the first axis
  61836. * @param axis2 defines the second axis
  61837. * @param axis3 defines the third axis
  61838. * @returns a new Vector3
  61839. */
  61840. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61841. /**
  61842. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61843. * @param axis1 defines the first axis
  61844. * @param axis2 defines the second axis
  61845. * @param axis3 defines the third axis
  61846. * @param ref defines the Vector3 where to store the result
  61847. */
  61848. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61849. }
  61850. /**
  61851. * Vector4 class created for EulerAngle class conversion to Quaternion
  61852. */
  61853. export class Vector4 {
  61854. /** x value of the vector */
  61855. x: number;
  61856. /** y value of the vector */
  61857. y: number;
  61858. /** z value of the vector */
  61859. z: number;
  61860. /** w value of the vector */
  61861. w: number;
  61862. /**
  61863. * Creates a Vector4 object from the given floats.
  61864. * @param x x value of the vector
  61865. * @param y y value of the vector
  61866. * @param z z value of the vector
  61867. * @param w w value of the vector
  61868. */
  61869. constructor(
  61870. /** x value of the vector */
  61871. x: number,
  61872. /** y value of the vector */
  61873. y: number,
  61874. /** z value of the vector */
  61875. z: number,
  61876. /** w value of the vector */
  61877. w: number);
  61878. /**
  61879. * Returns the string with the Vector4 coordinates.
  61880. * @returns a string containing all the vector values
  61881. */
  61882. toString(): string;
  61883. /**
  61884. * Returns the string "Vector4".
  61885. * @returns "Vector4"
  61886. */
  61887. getClassName(): string;
  61888. /**
  61889. * Returns the Vector4 hash code.
  61890. * @returns a unique hash code
  61891. */
  61892. getHashCode(): number;
  61893. /**
  61894. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61895. * @returns the resulting array
  61896. */
  61897. asArray(): number[];
  61898. /**
  61899. * Populates the given array from the given index with the Vector4 coordinates.
  61900. * @param array array to populate
  61901. * @param index index of the array to start at (default: 0)
  61902. * @returns the Vector4.
  61903. */
  61904. toArray(array: FloatArray, index?: number): Vector4;
  61905. /**
  61906. * Adds the given vector to the current Vector4.
  61907. * @param otherVector the vector to add
  61908. * @returns the updated Vector4.
  61909. */
  61910. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61911. /**
  61912. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61913. * @param otherVector the vector to add
  61914. * @returns the resulting vector
  61915. */
  61916. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61917. /**
  61918. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61919. * @param otherVector the vector to add
  61920. * @param result the vector to store the result
  61921. * @returns the current Vector4.
  61922. */
  61923. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61924. /**
  61925. * Subtract in place the given vector from the current Vector4.
  61926. * @param otherVector the vector to subtract
  61927. * @returns the updated Vector4.
  61928. */
  61929. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61930. /**
  61931. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61932. * @param otherVector the vector to add
  61933. * @returns the new vector with the result
  61934. */
  61935. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61936. /**
  61937. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61938. * @param otherVector the vector to subtract
  61939. * @param result the vector to store the result
  61940. * @returns the current Vector4.
  61941. */
  61942. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61943. /**
  61944. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61945. */
  61946. /**
  61947. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61948. * @param x value to subtract
  61949. * @param y value to subtract
  61950. * @param z value to subtract
  61951. * @param w value to subtract
  61952. * @returns new vector containing the result
  61953. */
  61954. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61955. /**
  61956. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61957. * @param x value to subtract
  61958. * @param y value to subtract
  61959. * @param z value to subtract
  61960. * @param w value to subtract
  61961. * @param result the vector to store the result in
  61962. * @returns the current Vector4.
  61963. */
  61964. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61965. /**
  61966. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61967. * @returns a new vector with the negated values
  61968. */
  61969. negate(): Vector4;
  61970. /**
  61971. * Multiplies the current Vector4 coordinates by scale (float).
  61972. * @param scale the number to scale with
  61973. * @returns the updated Vector4.
  61974. */
  61975. scaleInPlace(scale: number): Vector4;
  61976. /**
  61977. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61978. * @param scale the number to scale with
  61979. * @returns a new vector with the result
  61980. */
  61981. scale(scale: number): Vector4;
  61982. /**
  61983. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61984. * @param scale the number to scale with
  61985. * @param result a vector to store the result in
  61986. * @returns the current Vector4.
  61987. */
  61988. scaleToRef(scale: number, result: Vector4): Vector4;
  61989. /**
  61990. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61991. * @param scale defines the scale factor
  61992. * @param result defines the Vector4 object where to store the result
  61993. * @returns the unmodified current Vector4
  61994. */
  61995. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61996. /**
  61997. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61998. * @param otherVector the vector to compare against
  61999. * @returns true if they are equal
  62000. */
  62001. equals(otherVector: DeepImmutable<Vector4>): boolean;
  62002. /**
  62003. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  62004. * @param otherVector vector to compare against
  62005. * @param epsilon (Default: very small number)
  62006. * @returns true if they are equal
  62007. */
  62008. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  62009. /**
  62010. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  62011. * @param x x value to compare against
  62012. * @param y y value to compare against
  62013. * @param z z value to compare against
  62014. * @param w w value to compare against
  62015. * @returns true if equal
  62016. */
  62017. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  62018. /**
  62019. * Multiplies in place the current Vector4 by the given one.
  62020. * @param otherVector vector to multiple with
  62021. * @returns the updated Vector4.
  62022. */
  62023. multiplyInPlace(otherVector: Vector4): Vector4;
  62024. /**
  62025. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  62026. * @param otherVector vector to multiple with
  62027. * @returns resulting new vector
  62028. */
  62029. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  62030. /**
  62031. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  62032. * @param otherVector vector to multiple with
  62033. * @param result vector to store the result
  62034. * @returns the current Vector4.
  62035. */
  62036. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62037. /**
  62038. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  62039. * @param x x value multiply with
  62040. * @param y y value multiply with
  62041. * @param z z value multiply with
  62042. * @param w w value multiply with
  62043. * @returns resulting new vector
  62044. */
  62045. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  62046. /**
  62047. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  62048. * @param otherVector vector to devide with
  62049. * @returns resulting new vector
  62050. */
  62051. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  62052. /**
  62053. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  62054. * @param otherVector vector to devide with
  62055. * @param result vector to store the result
  62056. * @returns the current Vector4.
  62057. */
  62058. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62059. /**
  62060. * Divides the current Vector3 coordinates by the given ones.
  62061. * @param otherVector vector to devide with
  62062. * @returns the updated Vector3.
  62063. */
  62064. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  62065. /**
  62066. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  62067. * @param other defines the second operand
  62068. * @returns the current updated Vector4
  62069. */
  62070. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62071. /**
  62072. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  62073. * @param other defines the second operand
  62074. * @returns the current updated Vector4
  62075. */
  62076. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62077. /**
  62078. * Gets a new Vector4 from current Vector4 floored values
  62079. * @returns a new Vector4
  62080. */
  62081. floor(): Vector4;
  62082. /**
  62083. * Gets a new Vector4 from current Vector3 floored values
  62084. * @returns a new Vector4
  62085. */
  62086. fract(): Vector4;
  62087. /**
  62088. * Returns the Vector4 length (float).
  62089. * @returns the length
  62090. */
  62091. length(): number;
  62092. /**
  62093. * Returns the Vector4 squared length (float).
  62094. * @returns the length squared
  62095. */
  62096. lengthSquared(): number;
  62097. /**
  62098. * Normalizes in place the Vector4.
  62099. * @returns the updated Vector4.
  62100. */
  62101. normalize(): Vector4;
  62102. /**
  62103. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  62104. * @returns this converted to a new vector3
  62105. */
  62106. toVector3(): Vector3;
  62107. /**
  62108. * Returns a new Vector4 copied from the current one.
  62109. * @returns the new cloned vector
  62110. */
  62111. clone(): Vector4;
  62112. /**
  62113. * Updates the current Vector4 with the given one coordinates.
  62114. * @param source the source vector to copy from
  62115. * @returns the updated Vector4.
  62116. */
  62117. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  62118. /**
  62119. * Updates the current Vector4 coordinates with the given floats.
  62120. * @param x float to copy from
  62121. * @param y float to copy from
  62122. * @param z float to copy from
  62123. * @param w float to copy from
  62124. * @returns the updated Vector4.
  62125. */
  62126. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  62127. /**
  62128. * Updates the current Vector4 coordinates with the given floats.
  62129. * @param x float to set from
  62130. * @param y float to set from
  62131. * @param z float to set from
  62132. * @param w float to set from
  62133. * @returns the updated Vector4.
  62134. */
  62135. set(x: number, y: number, z: number, w: number): Vector4;
  62136. /**
  62137. * Copies the given float to the current Vector3 coordinates
  62138. * @param v defines the x, y, z and w coordinates of the operand
  62139. * @returns the current updated Vector3
  62140. */
  62141. setAll(v: number): Vector4;
  62142. /**
  62143. * Returns a new Vector4 set from the starting index of the given array.
  62144. * @param array the array to pull values from
  62145. * @param offset the offset into the array to start at
  62146. * @returns the new vector
  62147. */
  62148. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  62149. /**
  62150. * Updates the given vector "result" from the starting index of the given array.
  62151. * @param array the array to pull values from
  62152. * @param offset the offset into the array to start at
  62153. * @param result the vector to store the result in
  62154. */
  62155. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  62156. /**
  62157. * Updates the given vector "result" from the starting index of the given Float32Array.
  62158. * @param array the array to pull values from
  62159. * @param offset the offset into the array to start at
  62160. * @param result the vector to store the result in
  62161. */
  62162. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  62163. /**
  62164. * Updates the given vector "result" coordinates from the given floats.
  62165. * @param x float to set from
  62166. * @param y float to set from
  62167. * @param z float to set from
  62168. * @param w float to set from
  62169. * @param result the vector to the floats in
  62170. */
  62171. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  62172. /**
  62173. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  62174. * @returns the new vector
  62175. */
  62176. static Zero(): Vector4;
  62177. /**
  62178. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  62179. * @returns the new vector
  62180. */
  62181. static One(): Vector4;
  62182. /**
  62183. * Returns a new normalized Vector4 from the given one.
  62184. * @param vector the vector to normalize
  62185. * @returns the vector
  62186. */
  62187. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  62188. /**
  62189. * Updates the given vector "result" from the normalization of the given one.
  62190. * @param vector the vector to normalize
  62191. * @param result the vector to store the result in
  62192. */
  62193. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  62194. /**
  62195. * Returns a vector with the minimum values from the left and right vectors
  62196. * @param left left vector to minimize
  62197. * @param right right vector to minimize
  62198. * @returns a new vector with the minimum of the left and right vector values
  62199. */
  62200. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62201. /**
  62202. * Returns a vector with the maximum values from the left and right vectors
  62203. * @param left left vector to maximize
  62204. * @param right right vector to maximize
  62205. * @returns a new vector with the maximum of the left and right vector values
  62206. */
  62207. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62208. /**
  62209. * Returns the distance (float) between the vectors "value1" and "value2".
  62210. * @param value1 value to calulate the distance between
  62211. * @param value2 value to calulate the distance between
  62212. * @return the distance between the two vectors
  62213. */
  62214. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62215. /**
  62216. * Returns the squared distance (float) between the vectors "value1" and "value2".
  62217. * @param value1 value to calulate the distance between
  62218. * @param value2 value to calulate the distance between
  62219. * @return the distance between the two vectors squared
  62220. */
  62221. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62222. /**
  62223. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  62224. * @param value1 value to calulate the center between
  62225. * @param value2 value to calulate the center between
  62226. * @return the center between the two vectors
  62227. */
  62228. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  62229. /**
  62230. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  62231. * This methods computes transformed normalized direction vectors only.
  62232. * @param vector the vector to transform
  62233. * @param transformation the transformation matrix to apply
  62234. * @returns the new vector
  62235. */
  62236. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  62237. /**
  62238. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  62239. * This methods computes transformed normalized direction vectors only.
  62240. * @param vector the vector to transform
  62241. * @param transformation the transformation matrix to apply
  62242. * @param result the vector to store the result in
  62243. */
  62244. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62245. /**
  62246. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  62247. * This methods computes transformed normalized direction vectors only.
  62248. * @param x value to transform
  62249. * @param y value to transform
  62250. * @param z value to transform
  62251. * @param w value to transform
  62252. * @param transformation the transformation matrix to apply
  62253. * @param result the vector to store the results in
  62254. */
  62255. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62256. /**
  62257. * Creates a new Vector4 from a Vector3
  62258. * @param source defines the source data
  62259. * @param w defines the 4th component (default is 0)
  62260. * @returns a new Vector4
  62261. */
  62262. static FromVector3(source: Vector3, w?: number): Vector4;
  62263. }
  62264. /**
  62265. * Interface for the size containing width and height
  62266. */
  62267. export interface ISize {
  62268. /**
  62269. * Width
  62270. */
  62271. width: number;
  62272. /**
  62273. * Heighht
  62274. */
  62275. height: number;
  62276. }
  62277. /**
  62278. * Size containing widht and height
  62279. */
  62280. export class Size implements ISize {
  62281. /**
  62282. * Width
  62283. */
  62284. width: number;
  62285. /**
  62286. * Height
  62287. */
  62288. height: number;
  62289. /**
  62290. * Creates a Size object from the given width and height (floats).
  62291. * @param width width of the new size
  62292. * @param height height of the new size
  62293. */
  62294. constructor(width: number, height: number);
  62295. /**
  62296. * Returns a string with the Size width and height
  62297. * @returns a string with the Size width and height
  62298. */
  62299. toString(): string;
  62300. /**
  62301. * "Size"
  62302. * @returns the string "Size"
  62303. */
  62304. getClassName(): string;
  62305. /**
  62306. * Returns the Size hash code.
  62307. * @returns a hash code for a unique width and height
  62308. */
  62309. getHashCode(): number;
  62310. /**
  62311. * Updates the current size from the given one.
  62312. * @param src the given size
  62313. */
  62314. copyFrom(src: Size): void;
  62315. /**
  62316. * Updates in place the current Size from the given floats.
  62317. * @param width width of the new size
  62318. * @param height height of the new size
  62319. * @returns the updated Size.
  62320. */
  62321. copyFromFloats(width: number, height: number): Size;
  62322. /**
  62323. * Updates in place the current Size from the given floats.
  62324. * @param width width to set
  62325. * @param height height to set
  62326. * @returns the updated Size.
  62327. */
  62328. set(width: number, height: number): Size;
  62329. /**
  62330. * Multiplies the width and height by numbers
  62331. * @param w factor to multiple the width by
  62332. * @param h factor to multiple the height by
  62333. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  62334. */
  62335. multiplyByFloats(w: number, h: number): Size;
  62336. /**
  62337. * Clones the size
  62338. * @returns a new Size copied from the given one.
  62339. */
  62340. clone(): Size;
  62341. /**
  62342. * True if the current Size and the given one width and height are strictly equal.
  62343. * @param other the other size to compare against
  62344. * @returns True if the current Size and the given one width and height are strictly equal.
  62345. */
  62346. equals(other: Size): boolean;
  62347. /**
  62348. * The surface of the Size : width * height (float).
  62349. */
  62350. readonly surface: number;
  62351. /**
  62352. * Create a new size of zero
  62353. * @returns a new Size set to (0.0, 0.0)
  62354. */
  62355. static Zero(): Size;
  62356. /**
  62357. * Sums the width and height of two sizes
  62358. * @param otherSize size to add to this size
  62359. * @returns a new Size set as the addition result of the current Size and the given one.
  62360. */
  62361. add(otherSize: Size): Size;
  62362. /**
  62363. * Subtracts the width and height of two
  62364. * @param otherSize size to subtract to this size
  62365. * @returns a new Size set as the subtraction result of the given one from the current Size.
  62366. */
  62367. subtract(otherSize: Size): Size;
  62368. /**
  62369. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  62370. * @param start starting size to lerp between
  62371. * @param end end size to lerp between
  62372. * @param amount amount to lerp between the start and end values
  62373. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  62374. */
  62375. static Lerp(start: Size, end: Size, amount: number): Size;
  62376. }
  62377. /**
  62378. * Class used to store quaternion data
  62379. * @see https://en.wikipedia.org/wiki/Quaternion
  62380. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  62381. */
  62382. export class Quaternion {
  62383. /** defines the first component (0 by default) */
  62384. x: number;
  62385. /** defines the second component (0 by default) */
  62386. y: number;
  62387. /** defines the third component (0 by default) */
  62388. z: number;
  62389. /** defines the fourth component (1.0 by default) */
  62390. w: number;
  62391. /**
  62392. * Creates a new Quaternion from the given floats
  62393. * @param x defines the first component (0 by default)
  62394. * @param y defines the second component (0 by default)
  62395. * @param z defines the third component (0 by default)
  62396. * @param w defines the fourth component (1.0 by default)
  62397. */
  62398. constructor(
  62399. /** defines the first component (0 by default) */
  62400. x?: number,
  62401. /** defines the second component (0 by default) */
  62402. y?: number,
  62403. /** defines the third component (0 by default) */
  62404. z?: number,
  62405. /** defines the fourth component (1.0 by default) */
  62406. w?: number);
  62407. /**
  62408. * Gets a string representation for the current quaternion
  62409. * @returns a string with the Quaternion coordinates
  62410. */
  62411. toString(): string;
  62412. /**
  62413. * Gets the class name of the quaternion
  62414. * @returns the string "Quaternion"
  62415. */
  62416. getClassName(): string;
  62417. /**
  62418. * Gets a hash code for this quaternion
  62419. * @returns the quaternion hash code
  62420. */
  62421. getHashCode(): number;
  62422. /**
  62423. * Copy the quaternion to an array
  62424. * @returns a new array populated with 4 elements from the quaternion coordinates
  62425. */
  62426. asArray(): number[];
  62427. /**
  62428. * Check if two quaternions are equals
  62429. * @param otherQuaternion defines the second operand
  62430. * @return true if the current quaternion and the given one coordinates are strictly equals
  62431. */
  62432. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  62433. /**
  62434. * Clone the current quaternion
  62435. * @returns a new quaternion copied from the current one
  62436. */
  62437. clone(): Quaternion;
  62438. /**
  62439. * Copy a quaternion to the current one
  62440. * @param other defines the other quaternion
  62441. * @returns the updated current quaternion
  62442. */
  62443. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  62444. /**
  62445. * Updates the current quaternion with the given float coordinates
  62446. * @param x defines the x coordinate
  62447. * @param y defines the y coordinate
  62448. * @param z defines the z coordinate
  62449. * @param w defines the w coordinate
  62450. * @returns the updated current quaternion
  62451. */
  62452. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  62453. /**
  62454. * Updates the current quaternion from the given float coordinates
  62455. * @param x defines the x coordinate
  62456. * @param y defines the y coordinate
  62457. * @param z defines the z coordinate
  62458. * @param w defines the w coordinate
  62459. * @returns the updated current quaternion
  62460. */
  62461. set(x: number, y: number, z: number, w: number): Quaternion;
  62462. /**
  62463. * Adds two quaternions
  62464. * @param other defines the second operand
  62465. * @returns a new quaternion as the addition result of the given one and the current quaternion
  62466. */
  62467. add(other: DeepImmutable<Quaternion>): Quaternion;
  62468. /**
  62469. * Add a quaternion to the current one
  62470. * @param other defines the quaternion to add
  62471. * @returns the current quaternion
  62472. */
  62473. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  62474. /**
  62475. * Subtract two quaternions
  62476. * @param other defines the second operand
  62477. * @returns a new quaternion as the subtraction result of the given one from the current one
  62478. */
  62479. subtract(other: Quaternion): Quaternion;
  62480. /**
  62481. * Multiplies the current quaternion by a scale factor
  62482. * @param value defines the scale factor
  62483. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  62484. */
  62485. scale(value: number): Quaternion;
  62486. /**
  62487. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  62488. * @param scale defines the scale factor
  62489. * @param result defines the Quaternion object where to store the result
  62490. * @returns the unmodified current quaternion
  62491. */
  62492. scaleToRef(scale: number, result: Quaternion): Quaternion;
  62493. /**
  62494. * Multiplies in place the current quaternion by a scale factor
  62495. * @param value defines the scale factor
  62496. * @returns the current modified quaternion
  62497. */
  62498. scaleInPlace(value: number): Quaternion;
  62499. /**
  62500. * Scale the current quaternion values by a factor and add the result to a given quaternion
  62501. * @param scale defines the scale factor
  62502. * @param result defines the Quaternion object where to store the result
  62503. * @returns the unmodified current quaternion
  62504. */
  62505. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  62506. /**
  62507. * Multiplies two quaternions
  62508. * @param q1 defines the second operand
  62509. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  62510. */
  62511. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62512. /**
  62513. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62514. * @param q1 defines the second operand
  62515. * @param result defines the target quaternion
  62516. * @returns the current quaternion
  62517. */
  62518. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62519. /**
  62520. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62521. * @param q1 defines the second operand
  62522. * @returns the currentupdated quaternion
  62523. */
  62524. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62525. /**
  62526. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62527. * @param ref defines the target quaternion
  62528. * @returns the current quaternion
  62529. */
  62530. conjugateToRef(ref: Quaternion): Quaternion;
  62531. /**
  62532. * Conjugates in place (1-q) the current quaternion
  62533. * @returns the current updated quaternion
  62534. */
  62535. conjugateInPlace(): Quaternion;
  62536. /**
  62537. * Conjugates in place (1-q) the current quaternion
  62538. * @returns a new quaternion
  62539. */
  62540. conjugate(): Quaternion;
  62541. /**
  62542. * Gets length of current quaternion
  62543. * @returns the quaternion length (float)
  62544. */
  62545. length(): number;
  62546. /**
  62547. * Normalize in place the current quaternion
  62548. * @returns the current updated quaternion
  62549. */
  62550. normalize(): Quaternion;
  62551. /**
  62552. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62553. * @param order is a reserved parameter and is ignore for now
  62554. * @returns a new Vector3 containing the Euler angles
  62555. */
  62556. toEulerAngles(order?: string): Vector3;
  62557. /**
  62558. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62559. * @param result defines the vector which will be filled with the Euler angles
  62560. * @param order is a reserved parameter and is ignore for now
  62561. * @returns the current unchanged quaternion
  62562. */
  62563. toEulerAnglesToRef(result: Vector3): Quaternion;
  62564. /**
  62565. * Updates the given rotation matrix with the current quaternion values
  62566. * @param result defines the target matrix
  62567. * @returns the current unchanged quaternion
  62568. */
  62569. toRotationMatrix(result: Matrix): Quaternion;
  62570. /**
  62571. * Updates the current quaternion from the given rotation matrix values
  62572. * @param matrix defines the source matrix
  62573. * @returns the current updated quaternion
  62574. */
  62575. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62576. /**
  62577. * Creates a new quaternion from a rotation matrix
  62578. * @param matrix defines the source matrix
  62579. * @returns a new quaternion created from the given rotation matrix values
  62580. */
  62581. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62582. /**
  62583. * Updates the given quaternion with the given rotation matrix values
  62584. * @param matrix defines the source matrix
  62585. * @param result defines the target quaternion
  62586. */
  62587. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62588. /**
  62589. * Returns the dot product (float) between the quaternions "left" and "right"
  62590. * @param left defines the left operand
  62591. * @param right defines the right operand
  62592. * @returns the dot product
  62593. */
  62594. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62595. /**
  62596. * Checks if the two quaternions are close to each other
  62597. * @param quat0 defines the first quaternion to check
  62598. * @param quat1 defines the second quaternion to check
  62599. * @returns true if the two quaternions are close to each other
  62600. */
  62601. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62602. /**
  62603. * Creates an empty quaternion
  62604. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62605. */
  62606. static Zero(): Quaternion;
  62607. /**
  62608. * Inverse a given quaternion
  62609. * @param q defines the source quaternion
  62610. * @returns a new quaternion as the inverted current quaternion
  62611. */
  62612. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62613. /**
  62614. * Inverse a given quaternion
  62615. * @param q defines the source quaternion
  62616. * @param result the quaternion the result will be stored in
  62617. * @returns the result quaternion
  62618. */
  62619. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62620. /**
  62621. * Creates an identity quaternion
  62622. * @returns the identity quaternion
  62623. */
  62624. static Identity(): Quaternion;
  62625. /**
  62626. * Gets a boolean indicating if the given quaternion is identity
  62627. * @param quaternion defines the quaternion to check
  62628. * @returns true if the quaternion is identity
  62629. */
  62630. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62631. /**
  62632. * Creates a quaternion from a rotation around an axis
  62633. * @param axis defines the axis to use
  62634. * @param angle defines the angle to use
  62635. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62636. */
  62637. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62638. /**
  62639. * Creates a rotation around an axis and stores it into the given quaternion
  62640. * @param axis defines the axis to use
  62641. * @param angle defines the angle to use
  62642. * @param result defines the target quaternion
  62643. * @returns the target quaternion
  62644. */
  62645. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62646. /**
  62647. * Creates a new quaternion from data stored into an array
  62648. * @param array defines the data source
  62649. * @param offset defines the offset in the source array where the data starts
  62650. * @returns a new quaternion
  62651. */
  62652. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62653. /**
  62654. * Create a quaternion from Euler rotation angles
  62655. * @param x Pitch
  62656. * @param y Yaw
  62657. * @param z Roll
  62658. * @returns the new Quaternion
  62659. */
  62660. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62661. /**
  62662. * Updates a quaternion from Euler rotation angles
  62663. * @param x Pitch
  62664. * @param y Yaw
  62665. * @param z Roll
  62666. * @param result the quaternion to store the result
  62667. * @returns the updated quaternion
  62668. */
  62669. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62670. /**
  62671. * Create a quaternion from Euler rotation vector
  62672. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62673. * @returns the new Quaternion
  62674. */
  62675. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62676. /**
  62677. * Updates a quaternion from Euler rotation vector
  62678. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62679. * @param result the quaternion to store the result
  62680. * @returns the updated quaternion
  62681. */
  62682. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62683. /**
  62684. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62685. * @param yaw defines the rotation around Y axis
  62686. * @param pitch defines the rotation around X axis
  62687. * @param roll defines the rotation around Z axis
  62688. * @returns the new quaternion
  62689. */
  62690. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62691. /**
  62692. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62693. * @param yaw defines the rotation around Y axis
  62694. * @param pitch defines the rotation around X axis
  62695. * @param roll defines the rotation around Z axis
  62696. * @param result defines the target quaternion
  62697. */
  62698. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62699. /**
  62700. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62701. * @param alpha defines the rotation around first axis
  62702. * @param beta defines the rotation around second axis
  62703. * @param gamma defines the rotation around third axis
  62704. * @returns the new quaternion
  62705. */
  62706. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62707. /**
  62708. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62709. * @param alpha defines the rotation around first axis
  62710. * @param beta defines the rotation around second axis
  62711. * @param gamma defines the rotation around third axis
  62712. * @param result defines the target quaternion
  62713. */
  62714. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62715. /**
  62716. * 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)
  62717. * @param axis1 defines the first axis
  62718. * @param axis2 defines the second axis
  62719. * @param axis3 defines the third axis
  62720. * @returns the new quaternion
  62721. */
  62722. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62723. /**
  62724. * 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
  62725. * @param axis1 defines the first axis
  62726. * @param axis2 defines the second axis
  62727. * @param axis3 defines the third axis
  62728. * @param ref defines the target quaternion
  62729. */
  62730. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62731. /**
  62732. * Interpolates between two quaternions
  62733. * @param left defines first quaternion
  62734. * @param right defines second quaternion
  62735. * @param amount defines the gradient to use
  62736. * @returns the new interpolated quaternion
  62737. */
  62738. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62739. /**
  62740. * Interpolates between two quaternions and stores it into a target quaternion
  62741. * @param left defines first quaternion
  62742. * @param right defines second quaternion
  62743. * @param amount defines the gradient to use
  62744. * @param result defines the target quaternion
  62745. */
  62746. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62747. /**
  62748. * Interpolate between two quaternions using Hermite interpolation
  62749. * @param value1 defines first quaternion
  62750. * @param tangent1 defines the incoming tangent
  62751. * @param value2 defines second quaternion
  62752. * @param tangent2 defines the outgoing tangent
  62753. * @param amount defines the target quaternion
  62754. * @returns the new interpolated quaternion
  62755. */
  62756. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62757. }
  62758. /**
  62759. * Class used to store matrix data (4x4)
  62760. */
  62761. export class Matrix {
  62762. private static _updateFlagSeed;
  62763. private static _identityReadOnly;
  62764. private _isIdentity;
  62765. private _isIdentityDirty;
  62766. private _isIdentity3x2;
  62767. private _isIdentity3x2Dirty;
  62768. /**
  62769. * Gets the update flag of the matrix which is an unique number for the matrix.
  62770. * It will be incremented every time the matrix data change.
  62771. * You can use it to speed the comparison between two versions of the same matrix.
  62772. */
  62773. updateFlag: number;
  62774. private readonly _m;
  62775. /**
  62776. * Gets the internal data of the matrix
  62777. */
  62778. readonly m: DeepImmutable<Float32Array>;
  62779. /** @hidden */
  62780. _markAsUpdated(): void;
  62781. /** @hidden */
  62782. private _updateIdentityStatus;
  62783. /**
  62784. * Creates an empty matrix (filled with zeros)
  62785. */
  62786. constructor();
  62787. /**
  62788. * Check if the current matrix is identity
  62789. * @returns true is the matrix is the identity matrix
  62790. */
  62791. isIdentity(): boolean;
  62792. /**
  62793. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62794. * @returns true is the matrix is the identity matrix
  62795. */
  62796. isIdentityAs3x2(): boolean;
  62797. /**
  62798. * Gets the determinant of the matrix
  62799. * @returns the matrix determinant
  62800. */
  62801. determinant(): number;
  62802. /**
  62803. * Returns the matrix as a Float32Array
  62804. * @returns the matrix underlying array
  62805. */
  62806. toArray(): DeepImmutable<Float32Array>;
  62807. /**
  62808. * Returns the matrix as a Float32Array
  62809. * @returns the matrix underlying array.
  62810. */
  62811. asArray(): DeepImmutable<Float32Array>;
  62812. /**
  62813. * Inverts the current matrix in place
  62814. * @returns the current inverted matrix
  62815. */
  62816. invert(): Matrix;
  62817. /**
  62818. * Sets all the matrix elements to zero
  62819. * @returns the current matrix
  62820. */
  62821. reset(): Matrix;
  62822. /**
  62823. * Adds the current matrix with a second one
  62824. * @param other defines the matrix to add
  62825. * @returns a new matrix as the addition of the current matrix and the given one
  62826. */
  62827. add(other: DeepImmutable<Matrix>): Matrix;
  62828. /**
  62829. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62830. * @param other defines the matrix to add
  62831. * @param result defines the target matrix
  62832. * @returns the current matrix
  62833. */
  62834. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62835. /**
  62836. * Adds in place the given matrix to the current matrix
  62837. * @param other defines the second operand
  62838. * @returns the current updated matrix
  62839. */
  62840. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62841. /**
  62842. * Sets the given matrix to the current inverted Matrix
  62843. * @param other defines the target matrix
  62844. * @returns the unmodified current matrix
  62845. */
  62846. invertToRef(other: Matrix): Matrix;
  62847. /**
  62848. * add a value at the specified position in the current Matrix
  62849. * @param index the index of the value within the matrix. between 0 and 15.
  62850. * @param value the value to be added
  62851. * @returns the current updated matrix
  62852. */
  62853. addAtIndex(index: number, value: number): Matrix;
  62854. /**
  62855. * mutiply the specified position in the current Matrix by a value
  62856. * @param index the index of the value within the matrix. between 0 and 15.
  62857. * @param value the value to be added
  62858. * @returns the current updated matrix
  62859. */
  62860. multiplyAtIndex(index: number, value: number): Matrix;
  62861. /**
  62862. * Inserts the translation vector (using 3 floats) in the current matrix
  62863. * @param x defines the 1st component of the translation
  62864. * @param y defines the 2nd component of the translation
  62865. * @param z defines the 3rd component of the translation
  62866. * @returns the current updated matrix
  62867. */
  62868. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62869. /**
  62870. * Adds the translation vector (using 3 floats) in the current matrix
  62871. * @param x defines the 1st component of the translation
  62872. * @param y defines the 2nd component of the translation
  62873. * @param z defines the 3rd component of the translation
  62874. * @returns the current updated matrix
  62875. */
  62876. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62877. /**
  62878. * Inserts the translation vector in the current matrix
  62879. * @param vector3 defines the translation to insert
  62880. * @returns the current updated matrix
  62881. */
  62882. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62883. /**
  62884. * Gets the translation value of the current matrix
  62885. * @returns a new Vector3 as the extracted translation from the matrix
  62886. */
  62887. getTranslation(): Vector3;
  62888. /**
  62889. * Fill a Vector3 with the extracted translation from the matrix
  62890. * @param result defines the Vector3 where to store the translation
  62891. * @returns the current matrix
  62892. */
  62893. getTranslationToRef(result: Vector3): Matrix;
  62894. /**
  62895. * Remove rotation and scaling part from the matrix
  62896. * @returns the updated matrix
  62897. */
  62898. removeRotationAndScaling(): Matrix;
  62899. /**
  62900. * Multiply two matrices
  62901. * @param other defines the second operand
  62902. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62903. */
  62904. multiply(other: DeepImmutable<Matrix>): Matrix;
  62905. /**
  62906. * Copy the current matrix from the given one
  62907. * @param other defines the source matrix
  62908. * @returns the current updated matrix
  62909. */
  62910. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62911. /**
  62912. * Populates the given array from the starting index with the current matrix values
  62913. * @param array defines the target array
  62914. * @param offset defines the offset in the target array where to start storing values
  62915. * @returns the current matrix
  62916. */
  62917. copyToArray(array: Float32Array, offset?: number): Matrix;
  62918. /**
  62919. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62920. * @param other defines the second operand
  62921. * @param result defines the matrix where to store the multiplication
  62922. * @returns the current matrix
  62923. */
  62924. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62925. /**
  62926. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62927. * @param other defines the second operand
  62928. * @param result defines the array where to store the multiplication
  62929. * @param offset defines the offset in the target array where to start storing values
  62930. * @returns the current matrix
  62931. */
  62932. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62933. /**
  62934. * Check equality between this matrix and a second one
  62935. * @param value defines the second matrix to compare
  62936. * @returns true is the current matrix and the given one values are strictly equal
  62937. */
  62938. equals(value: DeepImmutable<Matrix>): boolean;
  62939. /**
  62940. * Clone the current matrix
  62941. * @returns a new matrix from the current matrix
  62942. */
  62943. clone(): Matrix;
  62944. /**
  62945. * Returns the name of the current matrix class
  62946. * @returns the string "Matrix"
  62947. */
  62948. getClassName(): string;
  62949. /**
  62950. * Gets the hash code of the current matrix
  62951. * @returns the hash code
  62952. */
  62953. getHashCode(): number;
  62954. /**
  62955. * Decomposes the current Matrix into a translation, rotation and scaling components
  62956. * @param scale defines the scale vector3 given as a reference to update
  62957. * @param rotation defines the rotation quaternion given as a reference to update
  62958. * @param translation defines the translation vector3 given as a reference to update
  62959. * @returns true if operation was successful
  62960. */
  62961. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62962. /**
  62963. * Gets specific row of the matrix
  62964. * @param index defines the number of the row to get
  62965. * @returns the index-th row of the current matrix as a new Vector4
  62966. */
  62967. getRow(index: number): Nullable<Vector4>;
  62968. /**
  62969. * Sets the index-th row of the current matrix to the vector4 values
  62970. * @param index defines the number of the row to set
  62971. * @param row defines the target vector4
  62972. * @returns the updated current matrix
  62973. */
  62974. setRow(index: number, row: Vector4): Matrix;
  62975. /**
  62976. * Compute the transpose of the matrix
  62977. * @returns the new transposed matrix
  62978. */
  62979. transpose(): Matrix;
  62980. /**
  62981. * Compute the transpose of the matrix and store it in a given matrix
  62982. * @param result defines the target matrix
  62983. * @returns the current matrix
  62984. */
  62985. transposeToRef(result: Matrix): Matrix;
  62986. /**
  62987. * Sets the index-th row of the current matrix with the given 4 x float values
  62988. * @param index defines the row index
  62989. * @param x defines the x component to set
  62990. * @param y defines the y component to set
  62991. * @param z defines the z component to set
  62992. * @param w defines the w component to set
  62993. * @returns the updated current matrix
  62994. */
  62995. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62996. /**
  62997. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62998. * @param scale defines the scale factor
  62999. * @returns a new matrix
  63000. */
  63001. scale(scale: number): Matrix;
  63002. /**
  63003. * Scale the current matrix values by a factor to a given result matrix
  63004. * @param scale defines the scale factor
  63005. * @param result defines the matrix to store the result
  63006. * @returns the current matrix
  63007. */
  63008. scaleToRef(scale: number, result: Matrix): Matrix;
  63009. /**
  63010. * Scale the current matrix values by a factor and add the result to a given matrix
  63011. * @param scale defines the scale factor
  63012. * @param result defines the Matrix to store the result
  63013. * @returns the current matrix
  63014. */
  63015. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  63016. /**
  63017. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  63018. * @param ref matrix to store the result
  63019. */
  63020. toNormalMatrix(ref: Matrix): void;
  63021. /**
  63022. * Gets only rotation part of the current matrix
  63023. * @returns a new matrix sets to the extracted rotation matrix from the current one
  63024. */
  63025. getRotationMatrix(): Matrix;
  63026. /**
  63027. * Extracts the rotation matrix from the current one and sets it as the given "result"
  63028. * @param result defines the target matrix to store data to
  63029. * @returns the current matrix
  63030. */
  63031. getRotationMatrixToRef(result: Matrix): Matrix;
  63032. /**
  63033. * Toggles model matrix from being right handed to left handed in place and vice versa
  63034. */
  63035. toggleModelMatrixHandInPlace(): void;
  63036. /**
  63037. * Toggles projection matrix from being right handed to left handed in place and vice versa
  63038. */
  63039. toggleProjectionMatrixHandInPlace(): void;
  63040. /**
  63041. * Creates a matrix from an array
  63042. * @param array defines the source array
  63043. * @param offset defines an offset in the source array
  63044. * @returns a new Matrix set from the starting index of the given array
  63045. */
  63046. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  63047. /**
  63048. * Copy the content of an array into a given matrix
  63049. * @param array defines the source array
  63050. * @param offset defines an offset in the source array
  63051. * @param result defines the target matrix
  63052. */
  63053. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  63054. /**
  63055. * Stores an array into a matrix after having multiplied each component by a given factor
  63056. * @param array defines the source array
  63057. * @param offset defines the offset in the source array
  63058. * @param scale defines the scaling factor
  63059. * @param result defines the target matrix
  63060. */
  63061. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  63062. /**
  63063. * Gets an identity matrix that must not be updated
  63064. */
  63065. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  63066. /**
  63067. * Stores a list of values (16) inside a given matrix
  63068. * @param initialM11 defines 1st value of 1st row
  63069. * @param initialM12 defines 2nd value of 1st row
  63070. * @param initialM13 defines 3rd value of 1st row
  63071. * @param initialM14 defines 4th value of 1st row
  63072. * @param initialM21 defines 1st value of 2nd row
  63073. * @param initialM22 defines 2nd value of 2nd row
  63074. * @param initialM23 defines 3rd value of 2nd row
  63075. * @param initialM24 defines 4th value of 2nd row
  63076. * @param initialM31 defines 1st value of 3rd row
  63077. * @param initialM32 defines 2nd value of 3rd row
  63078. * @param initialM33 defines 3rd value of 3rd row
  63079. * @param initialM34 defines 4th value of 3rd row
  63080. * @param initialM41 defines 1st value of 4th row
  63081. * @param initialM42 defines 2nd value of 4th row
  63082. * @param initialM43 defines 3rd value of 4th row
  63083. * @param initialM44 defines 4th value of 4th row
  63084. * @param result defines the target matrix
  63085. */
  63086. 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;
  63087. /**
  63088. * Creates new matrix from a list of values (16)
  63089. * @param initialM11 defines 1st value of 1st row
  63090. * @param initialM12 defines 2nd value of 1st row
  63091. * @param initialM13 defines 3rd value of 1st row
  63092. * @param initialM14 defines 4th value of 1st row
  63093. * @param initialM21 defines 1st value of 2nd row
  63094. * @param initialM22 defines 2nd value of 2nd row
  63095. * @param initialM23 defines 3rd value of 2nd row
  63096. * @param initialM24 defines 4th value of 2nd row
  63097. * @param initialM31 defines 1st value of 3rd row
  63098. * @param initialM32 defines 2nd value of 3rd row
  63099. * @param initialM33 defines 3rd value of 3rd row
  63100. * @param initialM34 defines 4th value of 3rd row
  63101. * @param initialM41 defines 1st value of 4th row
  63102. * @param initialM42 defines 2nd value of 4th row
  63103. * @param initialM43 defines 3rd value of 4th row
  63104. * @param initialM44 defines 4th value of 4th row
  63105. * @returns the new matrix
  63106. */
  63107. 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;
  63108. /**
  63109. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63110. * @param scale defines the scale vector3
  63111. * @param rotation defines the rotation quaternion
  63112. * @param translation defines the translation vector3
  63113. * @returns a new matrix
  63114. */
  63115. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  63116. /**
  63117. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63118. * @param scale defines the scale vector3
  63119. * @param rotation defines the rotation quaternion
  63120. * @param translation defines the translation vector3
  63121. * @param result defines the target matrix
  63122. */
  63123. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  63124. /**
  63125. * Creates a new identity matrix
  63126. * @returns a new identity matrix
  63127. */
  63128. static Identity(): Matrix;
  63129. /**
  63130. * Creates a new identity matrix and stores the result in a given matrix
  63131. * @param result defines the target matrix
  63132. */
  63133. static IdentityToRef(result: Matrix): void;
  63134. /**
  63135. * Creates a new zero matrix
  63136. * @returns a new zero matrix
  63137. */
  63138. static Zero(): Matrix;
  63139. /**
  63140. * Creates a new rotation matrix for "angle" radians around the X axis
  63141. * @param angle defines the angle (in radians) to use
  63142. * @return the new matrix
  63143. */
  63144. static RotationX(angle: number): Matrix;
  63145. /**
  63146. * Creates a new matrix as the invert of a given matrix
  63147. * @param source defines the source matrix
  63148. * @returns the new matrix
  63149. */
  63150. static Invert(source: DeepImmutable<Matrix>): Matrix;
  63151. /**
  63152. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  63153. * @param angle defines the angle (in radians) to use
  63154. * @param result defines the target matrix
  63155. */
  63156. static RotationXToRef(angle: number, result: Matrix): void;
  63157. /**
  63158. * Creates a new rotation matrix for "angle" radians around the Y axis
  63159. * @param angle defines the angle (in radians) to use
  63160. * @return the new matrix
  63161. */
  63162. static RotationY(angle: number): Matrix;
  63163. /**
  63164. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  63165. * @param angle defines the angle (in radians) to use
  63166. * @param result defines the target matrix
  63167. */
  63168. static RotationYToRef(angle: number, result: Matrix): void;
  63169. /**
  63170. * Creates a new rotation matrix for "angle" radians around the Z axis
  63171. * @param angle defines the angle (in radians) to use
  63172. * @return the new matrix
  63173. */
  63174. static RotationZ(angle: number): Matrix;
  63175. /**
  63176. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  63177. * @param angle defines the angle (in radians) to use
  63178. * @param result defines the target matrix
  63179. */
  63180. static RotationZToRef(angle: number, result: Matrix): void;
  63181. /**
  63182. * Creates a new rotation matrix for "angle" radians around the given axis
  63183. * @param axis defines the axis to use
  63184. * @param angle defines the angle (in radians) to use
  63185. * @return the new matrix
  63186. */
  63187. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  63188. /**
  63189. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  63190. * @param axis defines the axis to use
  63191. * @param angle defines the angle (in radians) to use
  63192. * @param result defines the target matrix
  63193. */
  63194. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  63195. /**
  63196. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  63197. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  63198. * @param from defines the vector to align
  63199. * @param to defines the vector to align to
  63200. * @param result defines the target matrix
  63201. */
  63202. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  63203. /**
  63204. * Creates a rotation matrix
  63205. * @param yaw defines the yaw angle in radians (Y axis)
  63206. * @param pitch defines the pitch angle in radians (X axis)
  63207. * @param roll defines the roll angle in radians (X axis)
  63208. * @returns the new rotation matrix
  63209. */
  63210. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  63211. /**
  63212. * Creates a rotation matrix and stores it in a given matrix
  63213. * @param yaw defines the yaw angle in radians (Y axis)
  63214. * @param pitch defines the pitch angle in radians (X axis)
  63215. * @param roll defines the roll angle in radians (X axis)
  63216. * @param result defines the target matrix
  63217. */
  63218. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  63219. /**
  63220. * Creates a scaling matrix
  63221. * @param x defines the scale factor on X axis
  63222. * @param y defines the scale factor on Y axis
  63223. * @param z defines the scale factor on Z axis
  63224. * @returns the new matrix
  63225. */
  63226. static Scaling(x: number, y: number, z: number): Matrix;
  63227. /**
  63228. * Creates a scaling matrix and stores it in a given matrix
  63229. * @param x defines the scale factor on X axis
  63230. * @param y defines the scale factor on Y axis
  63231. * @param z defines the scale factor on Z axis
  63232. * @param result defines the target matrix
  63233. */
  63234. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  63235. /**
  63236. * Creates a translation matrix
  63237. * @param x defines the translation on X axis
  63238. * @param y defines the translation on Y axis
  63239. * @param z defines the translationon Z axis
  63240. * @returns the new matrix
  63241. */
  63242. static Translation(x: number, y: number, z: number): Matrix;
  63243. /**
  63244. * Creates a translation matrix and stores it in a given matrix
  63245. * @param x defines the translation on X axis
  63246. * @param y defines the translation on Y axis
  63247. * @param z defines the translationon Z axis
  63248. * @param result defines the target matrix
  63249. */
  63250. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  63251. /**
  63252. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63253. * @param startValue defines the start value
  63254. * @param endValue defines the end value
  63255. * @param gradient defines the gradient factor
  63256. * @returns the new matrix
  63257. */
  63258. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63259. /**
  63260. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63261. * @param startValue defines the start value
  63262. * @param endValue defines the end value
  63263. * @param gradient defines the gradient factor
  63264. * @param result defines the Matrix object where to store data
  63265. */
  63266. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63267. /**
  63268. * Builds a new matrix whose values are computed by:
  63269. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63270. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63271. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63272. * @param startValue defines the first matrix
  63273. * @param endValue defines the second matrix
  63274. * @param gradient defines the gradient between the two matrices
  63275. * @returns the new matrix
  63276. */
  63277. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63278. /**
  63279. * Update a matrix to values which are computed by:
  63280. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63281. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63282. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63283. * @param startValue defines the first matrix
  63284. * @param endValue defines the second matrix
  63285. * @param gradient defines the gradient between the two matrices
  63286. * @param result defines the target matrix
  63287. */
  63288. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63289. /**
  63290. * 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"
  63291. * This function works in left handed mode
  63292. * @param eye defines the final position of the entity
  63293. * @param target defines where the entity should look at
  63294. * @param up defines the up vector for the entity
  63295. * @returns the new matrix
  63296. */
  63297. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63298. /**
  63299. * 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".
  63300. * This function works in left handed mode
  63301. * @param eye defines the final position of the entity
  63302. * @param target defines where the entity should look at
  63303. * @param up defines the up vector for the entity
  63304. * @param result defines the target matrix
  63305. */
  63306. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63307. /**
  63308. * 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"
  63309. * This function works in right handed mode
  63310. * @param eye defines the final position of the entity
  63311. * @param target defines where the entity should look at
  63312. * @param up defines the up vector for the entity
  63313. * @returns the new matrix
  63314. */
  63315. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63316. /**
  63317. * 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".
  63318. * This function works in right handed mode
  63319. * @param eye defines the final position of the entity
  63320. * @param target defines where the entity should look at
  63321. * @param up defines the up vector for the entity
  63322. * @param result defines the target matrix
  63323. */
  63324. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63325. /**
  63326. * Create a left-handed orthographic projection matrix
  63327. * @param width defines the viewport width
  63328. * @param height defines the viewport height
  63329. * @param znear defines the near clip plane
  63330. * @param zfar defines the far clip plane
  63331. * @returns a new matrix as a left-handed orthographic projection matrix
  63332. */
  63333. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63334. /**
  63335. * Store a left-handed orthographic projection to a given matrix
  63336. * @param width defines the viewport width
  63337. * @param height defines the viewport height
  63338. * @param znear defines the near clip plane
  63339. * @param zfar defines the far clip plane
  63340. * @param result defines the target matrix
  63341. */
  63342. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  63343. /**
  63344. * Create a left-handed orthographic projection matrix
  63345. * @param left defines the viewport left coordinate
  63346. * @param right defines the viewport right coordinate
  63347. * @param bottom defines the viewport bottom coordinate
  63348. * @param top defines the viewport top coordinate
  63349. * @param znear defines the near clip plane
  63350. * @param zfar defines the far clip plane
  63351. * @returns a new matrix as a left-handed orthographic projection matrix
  63352. */
  63353. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63354. /**
  63355. * Stores a left-handed orthographic projection into a given matrix
  63356. * @param left defines the viewport left coordinate
  63357. * @param right defines the viewport right coordinate
  63358. * @param bottom defines the viewport bottom coordinate
  63359. * @param top defines the viewport top coordinate
  63360. * @param znear defines the near clip plane
  63361. * @param zfar defines the far clip plane
  63362. * @param result defines the target matrix
  63363. */
  63364. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63365. /**
  63366. * Creates a right-handed orthographic projection matrix
  63367. * @param left defines the viewport left coordinate
  63368. * @param right defines the viewport right coordinate
  63369. * @param bottom defines the viewport bottom coordinate
  63370. * @param top defines the viewport top coordinate
  63371. * @param znear defines the near clip plane
  63372. * @param zfar defines the far clip plane
  63373. * @returns a new matrix as a right-handed orthographic projection matrix
  63374. */
  63375. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63376. /**
  63377. * Stores a right-handed orthographic projection into a given matrix
  63378. * @param left defines the viewport left coordinate
  63379. * @param right defines the viewport right coordinate
  63380. * @param bottom defines the viewport bottom coordinate
  63381. * @param top defines the viewport top coordinate
  63382. * @param znear defines the near clip plane
  63383. * @param zfar defines the far clip plane
  63384. * @param result defines the target matrix
  63385. */
  63386. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63387. /**
  63388. * Creates a left-handed perspective projection matrix
  63389. * @param width defines the viewport width
  63390. * @param height defines the viewport height
  63391. * @param znear defines the near clip plane
  63392. * @param zfar defines the far clip plane
  63393. * @returns a new matrix as a left-handed perspective projection matrix
  63394. */
  63395. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63396. /**
  63397. * Creates a left-handed perspective projection matrix
  63398. * @param fov defines the horizontal field of view
  63399. * @param aspect defines the aspect ratio
  63400. * @param znear defines the near clip plane
  63401. * @param zfar defines the far clip plane
  63402. * @returns a new matrix as a left-handed perspective projection matrix
  63403. */
  63404. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63405. /**
  63406. * Stores a left-handed perspective projection into a given matrix
  63407. * @param fov defines the horizontal field of view
  63408. * @param aspect defines the aspect ratio
  63409. * @param znear defines the near clip plane
  63410. * @param zfar defines the far clip plane
  63411. * @param result defines the target matrix
  63412. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63413. */
  63414. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63415. /**
  63416. * Creates a right-handed perspective projection matrix
  63417. * @param fov defines the horizontal field of view
  63418. * @param aspect defines the aspect ratio
  63419. * @param znear defines the near clip plane
  63420. * @param zfar defines the far clip plane
  63421. * @returns a new matrix as a right-handed perspective projection matrix
  63422. */
  63423. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63424. /**
  63425. * Stores a right-handed perspective projection into a given matrix
  63426. * @param fov defines the horizontal field of view
  63427. * @param aspect defines the aspect ratio
  63428. * @param znear defines the near clip plane
  63429. * @param zfar defines the far clip plane
  63430. * @param result defines the target matrix
  63431. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63432. */
  63433. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63434. /**
  63435. * Stores a perspective projection for WebVR info a given matrix
  63436. * @param fov defines the field of view
  63437. * @param znear defines the near clip plane
  63438. * @param zfar defines the far clip plane
  63439. * @param result defines the target matrix
  63440. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  63441. */
  63442. static PerspectiveFovWebVRToRef(fov: {
  63443. upDegrees: number;
  63444. downDegrees: number;
  63445. leftDegrees: number;
  63446. rightDegrees: number;
  63447. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  63448. /**
  63449. * Computes a complete transformation matrix
  63450. * @param viewport defines the viewport to use
  63451. * @param world defines the world matrix
  63452. * @param view defines the view matrix
  63453. * @param projection defines the projection matrix
  63454. * @param zmin defines the near clip plane
  63455. * @param zmax defines the far clip plane
  63456. * @returns the transformation matrix
  63457. */
  63458. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  63459. /**
  63460. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  63461. * @param matrix defines the matrix to use
  63462. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  63463. */
  63464. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  63465. /**
  63466. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  63467. * @param matrix defines the matrix to use
  63468. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  63469. */
  63470. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  63471. /**
  63472. * Compute the transpose of a given matrix
  63473. * @param matrix defines the matrix to transpose
  63474. * @returns the new matrix
  63475. */
  63476. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  63477. /**
  63478. * Compute the transpose of a matrix and store it in a target matrix
  63479. * @param matrix defines the matrix to transpose
  63480. * @param result defines the target matrix
  63481. */
  63482. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  63483. /**
  63484. * Computes a reflection matrix from a plane
  63485. * @param plane defines the reflection plane
  63486. * @returns a new matrix
  63487. */
  63488. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  63489. /**
  63490. * Computes a reflection matrix from a plane
  63491. * @param plane defines the reflection plane
  63492. * @param result defines the target matrix
  63493. */
  63494. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  63495. /**
  63496. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  63497. * @param xaxis defines the value of the 1st axis
  63498. * @param yaxis defines the value of the 2nd axis
  63499. * @param zaxis defines the value of the 3rd axis
  63500. * @param result defines the target matrix
  63501. */
  63502. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  63503. /**
  63504. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  63505. * @param quat defines the quaternion to use
  63506. * @param result defines the target matrix
  63507. */
  63508. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  63509. }
  63510. /**
  63511. * Represens a plane by the equation ax + by + cz + d = 0
  63512. */
  63513. export class Plane {
  63514. /**
  63515. * Normal of the plane (a,b,c)
  63516. */
  63517. normal: Vector3;
  63518. /**
  63519. * d component of the plane
  63520. */
  63521. d: number;
  63522. /**
  63523. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63524. * @param a a component of the plane
  63525. * @param b b component of the plane
  63526. * @param c c component of the plane
  63527. * @param d d component of the plane
  63528. */
  63529. constructor(a: number, b: number, c: number, d: number);
  63530. /**
  63531. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63532. */
  63533. asArray(): number[];
  63534. /**
  63535. * @returns a new plane copied from the current Plane.
  63536. */
  63537. clone(): Plane;
  63538. /**
  63539. * @returns the string "Plane".
  63540. */
  63541. getClassName(): string;
  63542. /**
  63543. * @returns the Plane hash code.
  63544. */
  63545. getHashCode(): number;
  63546. /**
  63547. * Normalize the current Plane in place.
  63548. * @returns the updated Plane.
  63549. */
  63550. normalize(): Plane;
  63551. /**
  63552. * Applies a transformation the plane and returns the result
  63553. * @param transformation the transformation matrix to be applied to the plane
  63554. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63555. */
  63556. transform(transformation: DeepImmutable<Matrix>): Plane;
  63557. /**
  63558. * Calcualtte the dot product between the point and the plane normal
  63559. * @param point point to calculate the dot product with
  63560. * @returns the dot product (float) of the point coordinates and the plane normal.
  63561. */
  63562. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63563. /**
  63564. * Updates the current Plane from the plane defined by the three given points.
  63565. * @param point1 one of the points used to contruct the plane
  63566. * @param point2 one of the points used to contruct the plane
  63567. * @param point3 one of the points used to contruct the plane
  63568. * @returns the updated Plane.
  63569. */
  63570. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63571. /**
  63572. * Checks if the plane is facing a given direction
  63573. * @param direction the direction to check if the plane is facing
  63574. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63575. * @returns True is the vector "direction" is the same side than the plane normal.
  63576. */
  63577. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63578. /**
  63579. * Calculates the distance to a point
  63580. * @param point point to calculate distance to
  63581. * @returns the signed distance (float) from the given point to the Plane.
  63582. */
  63583. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63584. /**
  63585. * Creates a plane from an array
  63586. * @param array the array to create a plane from
  63587. * @returns a new Plane from the given array.
  63588. */
  63589. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63590. /**
  63591. * Creates a plane from three points
  63592. * @param point1 point used to create the plane
  63593. * @param point2 point used to create the plane
  63594. * @param point3 point used to create the plane
  63595. * @returns a new Plane defined by the three given points.
  63596. */
  63597. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63598. /**
  63599. * Creates a plane from an origin point and a normal
  63600. * @param origin origin of the plane to be constructed
  63601. * @param normal normal of the plane to be constructed
  63602. * @returns a new Plane the normal vector to this plane at the given origin point.
  63603. * Note : the vector "normal" is updated because normalized.
  63604. */
  63605. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63606. /**
  63607. * Calculates the distance from a plane and a point
  63608. * @param origin origin of the plane to be constructed
  63609. * @param normal normal of the plane to be constructed
  63610. * @param point point to calculate distance to
  63611. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63612. */
  63613. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63614. }
  63615. /**
  63616. * Class used to represent a viewport on screen
  63617. */
  63618. export class Viewport {
  63619. /** viewport left coordinate */
  63620. x: number;
  63621. /** viewport top coordinate */
  63622. y: number;
  63623. /**viewport width */
  63624. width: number;
  63625. /** viewport height */
  63626. height: number;
  63627. /**
  63628. * Creates a Viewport object located at (x, y) and sized (width, height)
  63629. * @param x defines viewport left coordinate
  63630. * @param y defines viewport top coordinate
  63631. * @param width defines the viewport width
  63632. * @param height defines the viewport height
  63633. */
  63634. constructor(
  63635. /** viewport left coordinate */
  63636. x: number,
  63637. /** viewport top coordinate */
  63638. y: number,
  63639. /**viewport width */
  63640. width: number,
  63641. /** viewport height */
  63642. height: number);
  63643. /**
  63644. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63645. * @param renderWidth defines the rendering width
  63646. * @param renderHeight defines the rendering height
  63647. * @returns a new Viewport
  63648. */
  63649. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63650. /**
  63651. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63652. * @param renderWidth defines the rendering width
  63653. * @param renderHeight defines the rendering height
  63654. * @param ref defines the target viewport
  63655. * @returns the current viewport
  63656. */
  63657. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63658. /**
  63659. * Returns a new Viewport copied from the current one
  63660. * @returns a new Viewport
  63661. */
  63662. clone(): Viewport;
  63663. }
  63664. /**
  63665. * Reprasents a camera frustum
  63666. */
  63667. export class Frustum {
  63668. /**
  63669. * Gets the planes representing the frustum
  63670. * @param transform matrix to be applied to the returned planes
  63671. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63672. */
  63673. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63674. /**
  63675. * Gets the near frustum plane transformed by the transform matrix
  63676. * @param transform transformation matrix to be applied to the resulting frustum plane
  63677. * @param frustumPlane the resuling frustum plane
  63678. */
  63679. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63680. /**
  63681. * Gets the far frustum plane transformed by the transform matrix
  63682. * @param transform transformation matrix to be applied to the resulting frustum plane
  63683. * @param frustumPlane the resuling frustum plane
  63684. */
  63685. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63686. /**
  63687. * Gets the left frustum plane transformed by the transform matrix
  63688. * @param transform transformation matrix to be applied to the resulting frustum plane
  63689. * @param frustumPlane the resuling frustum plane
  63690. */
  63691. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63692. /**
  63693. * Gets the right frustum plane transformed by the transform matrix
  63694. * @param transform transformation matrix to be applied to the resulting frustum plane
  63695. * @param frustumPlane the resuling frustum plane
  63696. */
  63697. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63698. /**
  63699. * Gets the top frustum plane transformed by the transform matrix
  63700. * @param transform transformation matrix to be applied to the resulting frustum plane
  63701. * @param frustumPlane the resuling frustum plane
  63702. */
  63703. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63704. /**
  63705. * Gets the bottom frustum plane transformed by the transform matrix
  63706. * @param transform transformation matrix to be applied to the resulting frustum plane
  63707. * @param frustumPlane the resuling frustum plane
  63708. */
  63709. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63710. /**
  63711. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63712. * @param transform transformation matrix to be applied to the resulting frustum planes
  63713. * @param frustumPlanes the resuling frustum planes
  63714. */
  63715. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63716. }
  63717. /** Defines supported spaces */
  63718. export enum Space {
  63719. /** Local (object) space */
  63720. LOCAL = 0,
  63721. /** World space */
  63722. WORLD = 1,
  63723. /** Bone space */
  63724. BONE = 2
  63725. }
  63726. /** Defines the 3 main axes */
  63727. export class Axis {
  63728. /** X axis */
  63729. static X: Vector3;
  63730. /** Y axis */
  63731. static Y: Vector3;
  63732. /** Z axis */
  63733. static Z: Vector3;
  63734. }
  63735. /** Class used to represent a Bezier curve */
  63736. export class BezierCurve {
  63737. /**
  63738. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63739. * @param t defines the time
  63740. * @param x1 defines the left coordinate on X axis
  63741. * @param y1 defines the left coordinate on Y axis
  63742. * @param x2 defines the right coordinate on X axis
  63743. * @param y2 defines the right coordinate on Y axis
  63744. * @returns the interpolated value
  63745. */
  63746. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63747. }
  63748. /**
  63749. * Defines potential orientation for back face culling
  63750. */
  63751. export enum Orientation {
  63752. /**
  63753. * Clockwise
  63754. */
  63755. CW = 0,
  63756. /** Counter clockwise */
  63757. CCW = 1
  63758. }
  63759. /**
  63760. * Defines angle representation
  63761. */
  63762. export class Angle {
  63763. private _radians;
  63764. /**
  63765. * Creates an Angle object of "radians" radians (float).
  63766. * @param radians the angle in radians
  63767. */
  63768. constructor(radians: number);
  63769. /**
  63770. * Get value in degrees
  63771. * @returns the Angle value in degrees (float)
  63772. */
  63773. degrees(): number;
  63774. /**
  63775. * Get value in radians
  63776. * @returns the Angle value in radians (float)
  63777. */
  63778. radians(): number;
  63779. /**
  63780. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63781. * @param a defines first vector
  63782. * @param b defines second vector
  63783. * @returns a new Angle
  63784. */
  63785. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63786. /**
  63787. * Gets a new Angle object from the given float in radians
  63788. * @param radians defines the angle value in radians
  63789. * @returns a new Angle
  63790. */
  63791. static FromRadians(radians: number): Angle;
  63792. /**
  63793. * Gets a new Angle object from the given float in degrees
  63794. * @param degrees defines the angle value in degrees
  63795. * @returns a new Angle
  63796. */
  63797. static FromDegrees(degrees: number): Angle;
  63798. }
  63799. /**
  63800. * This represents an arc in a 2d space.
  63801. */
  63802. export class Arc2 {
  63803. /** Defines the start point of the arc */
  63804. startPoint: Vector2;
  63805. /** Defines the mid point of the arc */
  63806. midPoint: Vector2;
  63807. /** Defines the end point of the arc */
  63808. endPoint: Vector2;
  63809. /**
  63810. * Defines the center point of the arc.
  63811. */
  63812. centerPoint: Vector2;
  63813. /**
  63814. * Defines the radius of the arc.
  63815. */
  63816. radius: number;
  63817. /**
  63818. * Defines the angle of the arc (from mid point to end point).
  63819. */
  63820. angle: Angle;
  63821. /**
  63822. * Defines the start angle of the arc (from start point to middle point).
  63823. */
  63824. startAngle: Angle;
  63825. /**
  63826. * Defines the orientation of the arc (clock wise/counter clock wise).
  63827. */
  63828. orientation: Orientation;
  63829. /**
  63830. * Creates an Arc object from the three given points : start, middle and end.
  63831. * @param startPoint Defines the start point of the arc
  63832. * @param midPoint Defines the midlle point of the arc
  63833. * @param endPoint Defines the end point of the arc
  63834. */
  63835. constructor(
  63836. /** Defines the start point of the arc */
  63837. startPoint: Vector2,
  63838. /** Defines the mid point of the arc */
  63839. midPoint: Vector2,
  63840. /** Defines the end point of the arc */
  63841. endPoint: Vector2);
  63842. }
  63843. /**
  63844. * Represents a 2D path made up of multiple 2D points
  63845. */
  63846. export class Path2 {
  63847. private _points;
  63848. private _length;
  63849. /**
  63850. * If the path start and end point are the same
  63851. */
  63852. closed: boolean;
  63853. /**
  63854. * Creates a Path2 object from the starting 2D coordinates x and y.
  63855. * @param x the starting points x value
  63856. * @param y the starting points y value
  63857. */
  63858. constructor(x: number, y: number);
  63859. /**
  63860. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63861. * @param x the added points x value
  63862. * @param y the added points y value
  63863. * @returns the updated Path2.
  63864. */
  63865. addLineTo(x: number, y: number): Path2;
  63866. /**
  63867. * 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.
  63868. * @param midX middle point x value
  63869. * @param midY middle point y value
  63870. * @param endX end point x value
  63871. * @param endY end point y value
  63872. * @param numberOfSegments (default: 36)
  63873. * @returns the updated Path2.
  63874. */
  63875. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63876. /**
  63877. * Closes the Path2.
  63878. * @returns the Path2.
  63879. */
  63880. close(): Path2;
  63881. /**
  63882. * Gets the sum of the distance between each sequential point in the path
  63883. * @returns the Path2 total length (float).
  63884. */
  63885. length(): number;
  63886. /**
  63887. * Gets the points which construct the path
  63888. * @returns the Path2 internal array of points.
  63889. */
  63890. getPoints(): Vector2[];
  63891. /**
  63892. * Retreives the point at the distance aways from the starting point
  63893. * @param normalizedLengthPosition the length along the path to retreive the point from
  63894. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63895. */
  63896. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63897. /**
  63898. * Creates a new path starting from an x and y position
  63899. * @param x starting x value
  63900. * @param y starting y value
  63901. * @returns a new Path2 starting at the coordinates (x, y).
  63902. */
  63903. static StartingAt(x: number, y: number): Path2;
  63904. }
  63905. /**
  63906. * Represents a 3D path made up of multiple 3D points
  63907. */
  63908. export class Path3D {
  63909. /**
  63910. * an array of Vector3, the curve axis of the Path3D
  63911. */
  63912. path: Vector3[];
  63913. private _curve;
  63914. private _distances;
  63915. private _tangents;
  63916. private _normals;
  63917. private _binormals;
  63918. private _raw;
  63919. /**
  63920. * new Path3D(path, normal, raw)
  63921. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63922. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63923. * @param path an array of Vector3, the curve axis of the Path3D
  63924. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63925. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63926. */
  63927. constructor(
  63928. /**
  63929. * an array of Vector3, the curve axis of the Path3D
  63930. */
  63931. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63932. /**
  63933. * Returns the Path3D array of successive Vector3 designing its curve.
  63934. * @returns the Path3D array of successive Vector3 designing its curve.
  63935. */
  63936. getCurve(): Vector3[];
  63937. /**
  63938. * Returns an array populated with tangent vectors on each Path3D curve point.
  63939. * @returns an array populated with tangent vectors on each Path3D curve point.
  63940. */
  63941. getTangents(): Vector3[];
  63942. /**
  63943. * Returns an array populated with normal vectors on each Path3D curve point.
  63944. * @returns an array populated with normal vectors on each Path3D curve point.
  63945. */
  63946. getNormals(): Vector3[];
  63947. /**
  63948. * Returns an array populated with binormal vectors on each Path3D curve point.
  63949. * @returns an array populated with binormal vectors on each Path3D curve point.
  63950. */
  63951. getBinormals(): Vector3[];
  63952. /**
  63953. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63954. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63955. */
  63956. getDistances(): number[];
  63957. /**
  63958. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63959. * @param path path which all values are copied into the curves points
  63960. * @param firstNormal which should be projected onto the curve
  63961. * @returns the same object updated.
  63962. */
  63963. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63964. private _compute;
  63965. private _getFirstNonNullVector;
  63966. private _getLastNonNullVector;
  63967. private _normalVector;
  63968. }
  63969. /**
  63970. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63971. * A Curve3 is designed from a series of successive Vector3.
  63972. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63973. */
  63974. export class Curve3 {
  63975. private _points;
  63976. private _length;
  63977. /**
  63978. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63979. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63980. * @param v1 (Vector3) the control point
  63981. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63982. * @param nbPoints (integer) the wanted number of points in the curve
  63983. * @returns the created Curve3
  63984. */
  63985. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63986. /**
  63987. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63988. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63989. * @param v1 (Vector3) the first control point
  63990. * @param v2 (Vector3) the second control point
  63991. * @param v3 (Vector3) the end point of the Cubic Bezier
  63992. * @param nbPoints (integer) the wanted number of points in the curve
  63993. * @returns the created Curve3
  63994. */
  63995. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63996. /**
  63997. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63998. * @param p1 (Vector3) the origin point of the Hermite Spline
  63999. * @param t1 (Vector3) the tangent vector at the origin point
  64000. * @param p2 (Vector3) the end point of the Hermite Spline
  64001. * @param t2 (Vector3) the tangent vector at the end point
  64002. * @param nbPoints (integer) the wanted number of points in the curve
  64003. * @returns the created Curve3
  64004. */
  64005. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  64006. /**
  64007. * Returns a Curve3 object along a CatmullRom Spline curve :
  64008. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  64009. * @param nbPoints (integer) the wanted number of points between each curve control points
  64010. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  64011. * @returns the created Curve3
  64012. */
  64013. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  64014. /**
  64015. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  64016. * A Curve3 is designed from a series of successive Vector3.
  64017. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  64018. * @param points points which make up the curve
  64019. */
  64020. constructor(points: Vector3[]);
  64021. /**
  64022. * @returns the Curve3 stored array of successive Vector3
  64023. */
  64024. getPoints(): Vector3[];
  64025. /**
  64026. * @returns the computed length (float) of the curve.
  64027. */
  64028. length(): number;
  64029. /**
  64030. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  64031. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  64032. * curveA and curveB keep unchanged.
  64033. * @param curve the curve to continue from this curve
  64034. * @returns the newly constructed curve
  64035. */
  64036. continue(curve: DeepImmutable<Curve3>): Curve3;
  64037. private _computeLength;
  64038. }
  64039. /**
  64040. * Contains position and normal vectors for a vertex
  64041. */
  64042. export class PositionNormalVertex {
  64043. /** the position of the vertex (defaut: 0,0,0) */
  64044. position: Vector3;
  64045. /** the normal of the vertex (defaut: 0,1,0) */
  64046. normal: Vector3;
  64047. /**
  64048. * Creates a PositionNormalVertex
  64049. * @param position the position of the vertex (defaut: 0,0,0)
  64050. * @param normal the normal of the vertex (defaut: 0,1,0)
  64051. */
  64052. constructor(
  64053. /** the position of the vertex (defaut: 0,0,0) */
  64054. position?: Vector3,
  64055. /** the normal of the vertex (defaut: 0,1,0) */
  64056. normal?: Vector3);
  64057. /**
  64058. * Clones the PositionNormalVertex
  64059. * @returns the cloned PositionNormalVertex
  64060. */
  64061. clone(): PositionNormalVertex;
  64062. }
  64063. /**
  64064. * Contains position, normal and uv vectors for a vertex
  64065. */
  64066. export class PositionNormalTextureVertex {
  64067. /** the position of the vertex (defaut: 0,0,0) */
  64068. position: Vector3;
  64069. /** the normal of the vertex (defaut: 0,1,0) */
  64070. normal: Vector3;
  64071. /** the uv of the vertex (default: 0,0) */
  64072. uv: Vector2;
  64073. /**
  64074. * Creates a PositionNormalTextureVertex
  64075. * @param position the position of the vertex (defaut: 0,0,0)
  64076. * @param normal the normal of the vertex (defaut: 0,1,0)
  64077. * @param uv the uv of the vertex (default: 0,0)
  64078. */
  64079. constructor(
  64080. /** the position of the vertex (defaut: 0,0,0) */
  64081. position?: Vector3,
  64082. /** the normal of the vertex (defaut: 0,1,0) */
  64083. normal?: Vector3,
  64084. /** the uv of the vertex (default: 0,0) */
  64085. uv?: Vector2);
  64086. /**
  64087. * Clones the PositionNormalTextureVertex
  64088. * @returns the cloned PositionNormalTextureVertex
  64089. */
  64090. clone(): PositionNormalTextureVertex;
  64091. }
  64092. /**
  64093. * @hidden
  64094. */
  64095. export class Tmp {
  64096. static Color3: Color3[];
  64097. static Color4: Color4[];
  64098. static Vector2: Vector2[];
  64099. static Vector3: Vector3[];
  64100. static Vector4: Vector4[];
  64101. static Quaternion: Quaternion[];
  64102. static Matrix: Matrix[];
  64103. }
  64104. }
  64105. declare module BABYLON {
  64106. /**
  64107. * Class used to enable access to offline support
  64108. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64109. */
  64110. export interface IOfflineProvider {
  64111. /**
  64112. * Gets a boolean indicating if scene must be saved in the database
  64113. */
  64114. enableSceneOffline: boolean;
  64115. /**
  64116. * Gets a boolean indicating if textures must be saved in the database
  64117. */
  64118. enableTexturesOffline: boolean;
  64119. /**
  64120. * Open the offline support and make it available
  64121. * @param successCallback defines the callback to call on success
  64122. * @param errorCallback defines the callback to call on error
  64123. */
  64124. open(successCallback: () => void, errorCallback: () => void): void;
  64125. /**
  64126. * Loads an image from the offline support
  64127. * @param url defines the url to load from
  64128. * @param image defines the target DOM image
  64129. */
  64130. loadImage(url: string, image: HTMLImageElement): void;
  64131. /**
  64132. * Loads a file from offline support
  64133. * @param url defines the URL to load from
  64134. * @param sceneLoaded defines a callback to call on success
  64135. * @param progressCallBack defines a callback to call when progress changed
  64136. * @param errorCallback defines a callback to call on error
  64137. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64138. */
  64139. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64140. }
  64141. }
  64142. declare module BABYLON {
  64143. /**
  64144. * A class serves as a medium between the observable and its observers
  64145. */
  64146. export class EventState {
  64147. /**
  64148. * Create a new EventState
  64149. * @param mask defines the mask associated with this state
  64150. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64151. * @param target defines the original target of the state
  64152. * @param currentTarget defines the current target of the state
  64153. */
  64154. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64155. /**
  64156. * Initialize the current event state
  64157. * @param mask defines the mask associated with this state
  64158. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64159. * @param target defines the original target of the state
  64160. * @param currentTarget defines the current target of the state
  64161. * @returns the current event state
  64162. */
  64163. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64164. /**
  64165. * An Observer can set this property to true to prevent subsequent observers of being notified
  64166. */
  64167. skipNextObservers: boolean;
  64168. /**
  64169. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64170. */
  64171. mask: number;
  64172. /**
  64173. * The object that originally notified the event
  64174. */
  64175. target?: any;
  64176. /**
  64177. * The current object in the bubbling phase
  64178. */
  64179. currentTarget?: any;
  64180. /**
  64181. * This will be populated with the return value of the last function that was executed.
  64182. * If it is the first function in the callback chain it will be the event data.
  64183. */
  64184. lastReturnValue?: any;
  64185. }
  64186. /**
  64187. * Represent an Observer registered to a given Observable object.
  64188. */
  64189. export class Observer<T> {
  64190. /**
  64191. * Defines the callback to call when the observer is notified
  64192. */
  64193. callback: (eventData: T, eventState: EventState) => void;
  64194. /**
  64195. * Defines the mask of the observer (used to filter notifications)
  64196. */
  64197. mask: number;
  64198. /**
  64199. * Defines the current scope used to restore the JS context
  64200. */
  64201. scope: any;
  64202. /** @hidden */
  64203. _willBeUnregistered: boolean;
  64204. /**
  64205. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64206. */
  64207. unregisterOnNextCall: boolean;
  64208. /**
  64209. * Creates a new observer
  64210. * @param callback defines the callback to call when the observer is notified
  64211. * @param mask defines the mask of the observer (used to filter notifications)
  64212. * @param scope defines the current scope used to restore the JS context
  64213. */
  64214. constructor(
  64215. /**
  64216. * Defines the callback to call when the observer is notified
  64217. */
  64218. callback: (eventData: T, eventState: EventState) => void,
  64219. /**
  64220. * Defines the mask of the observer (used to filter notifications)
  64221. */
  64222. mask: number,
  64223. /**
  64224. * Defines the current scope used to restore the JS context
  64225. */
  64226. scope?: any);
  64227. }
  64228. /**
  64229. * Represent a list of observers registered to multiple Observables object.
  64230. */
  64231. export class MultiObserver<T> {
  64232. private _observers;
  64233. private _observables;
  64234. /**
  64235. * Release associated resources
  64236. */
  64237. dispose(): void;
  64238. /**
  64239. * Raise a callback when one of the observable will notify
  64240. * @param observables defines a list of observables to watch
  64241. * @param callback defines the callback to call on notification
  64242. * @param mask defines the mask used to filter notifications
  64243. * @param scope defines the current scope used to restore the JS context
  64244. * @returns the new MultiObserver
  64245. */
  64246. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64247. }
  64248. /**
  64249. * The Observable class is a simple implementation of the Observable pattern.
  64250. *
  64251. * 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.
  64252. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64253. * 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).
  64254. * 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.
  64255. */
  64256. export class Observable<T> {
  64257. private _observers;
  64258. private _eventState;
  64259. private _onObserverAdded;
  64260. /**
  64261. * Creates a new observable
  64262. * @param onObserverAdded defines a callback to call when a new observer is added
  64263. */
  64264. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64265. /**
  64266. * Create a new Observer with the specified callback
  64267. * @param callback the callback that will be executed for that Observer
  64268. * @param mask the mask used to filter observers
  64269. * @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.
  64270. * @param scope optional scope for the callback to be called from
  64271. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64272. * @returns the new observer created for the callback
  64273. */
  64274. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64275. /**
  64276. * Create a new Observer with the specified callback and unregisters after the next notification
  64277. * @param callback the callback that will be executed for that Observer
  64278. * @returns the new observer created for the callback
  64279. */
  64280. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64281. /**
  64282. * Remove an Observer from the Observable object
  64283. * @param observer the instance of the Observer to remove
  64284. * @returns false if it doesn't belong to this Observable
  64285. */
  64286. remove(observer: Nullable<Observer<T>>): boolean;
  64287. /**
  64288. * Remove a callback from the Observable object
  64289. * @param callback the callback to remove
  64290. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64291. * @returns false if it doesn't belong to this Observable
  64292. */
  64293. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64294. private _deferUnregister;
  64295. private _remove;
  64296. /**
  64297. * Moves the observable to the top of the observer list making it get called first when notified
  64298. * @param observer the observer to move
  64299. */
  64300. makeObserverTopPriority(observer: Observer<T>): void;
  64301. /**
  64302. * Moves the observable to the bottom of the observer list making it get called last when notified
  64303. * @param observer the observer to move
  64304. */
  64305. makeObserverBottomPriority(observer: Observer<T>): void;
  64306. /**
  64307. * Notify all Observers by calling their respective callback with the given data
  64308. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64309. * @param eventData defines the data to send to all observers
  64310. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64311. * @param target defines the original target of the state
  64312. * @param currentTarget defines the current target of the state
  64313. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64314. */
  64315. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64316. /**
  64317. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64318. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64319. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64320. * and it is crucial that all callbacks will be executed.
  64321. * The order of the callbacks is kept, callbacks are not executed parallel.
  64322. *
  64323. * @param eventData The data to be sent to each callback
  64324. * @param mask is used to filter observers defaults to -1
  64325. * @param target defines the callback target (see EventState)
  64326. * @param currentTarget defines he current object in the bubbling phase
  64327. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64328. */
  64329. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64330. /**
  64331. * Notify a specific observer
  64332. * @param observer defines the observer to notify
  64333. * @param eventData defines the data to be sent to each callback
  64334. * @param mask is used to filter observers defaults to -1
  64335. */
  64336. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64337. /**
  64338. * Gets a boolean indicating if the observable has at least one observer
  64339. * @returns true is the Observable has at least one Observer registered
  64340. */
  64341. hasObservers(): boolean;
  64342. /**
  64343. * Clear the list of observers
  64344. */
  64345. clear(): void;
  64346. /**
  64347. * Clone the current observable
  64348. * @returns a new observable
  64349. */
  64350. clone(): Observable<T>;
  64351. /**
  64352. * Does this observable handles observer registered with a given mask
  64353. * @param mask defines the mask to be tested
  64354. * @return whether or not one observer registered with the given mask is handeled
  64355. **/
  64356. hasSpecificMask(mask?: number): boolean;
  64357. }
  64358. }
  64359. declare module BABYLON {
  64360. /**
  64361. * Class used to help managing file picking and drag'n'drop
  64362. * File Storage
  64363. */
  64364. export class FilesInputStore {
  64365. /**
  64366. * List of files ready to be loaded
  64367. */
  64368. static FilesToLoad: {
  64369. [key: string]: File;
  64370. };
  64371. }
  64372. }
  64373. declare module BABYLON {
  64374. /** Defines the cross module used constants to avoid circular dependncies */
  64375. export class Constants {
  64376. /** Defines that alpha blending is disabled */
  64377. static readonly ALPHA_DISABLE: number;
  64378. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  64379. static readonly ALPHA_ADD: number;
  64380. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  64381. static readonly ALPHA_COMBINE: number;
  64382. /** Defines that alpha blending to DEST - SRC * DEST */
  64383. static readonly ALPHA_SUBTRACT: number;
  64384. /** Defines that alpha blending to SRC * DEST */
  64385. static readonly ALPHA_MULTIPLY: number;
  64386. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  64387. static readonly ALPHA_MAXIMIZED: number;
  64388. /** Defines that alpha blending to SRC + DEST */
  64389. static readonly ALPHA_ONEONE: number;
  64390. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  64391. static readonly ALPHA_PREMULTIPLIED: number;
  64392. /**
  64393. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  64394. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  64395. */
  64396. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  64397. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  64398. static readonly ALPHA_INTERPOLATE: number;
  64399. /**
  64400. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  64401. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  64402. */
  64403. static readonly ALPHA_SCREENMODE: number;
  64404. /** Defines that the ressource is not delayed*/
  64405. static readonly DELAYLOADSTATE_NONE: number;
  64406. /** Defines that the ressource was successfully delay loaded */
  64407. static readonly DELAYLOADSTATE_LOADED: number;
  64408. /** Defines that the ressource is currently delay loading */
  64409. static readonly DELAYLOADSTATE_LOADING: number;
  64410. /** Defines that the ressource is delayed and has not started loading */
  64411. static readonly DELAYLOADSTATE_NOTLOADED: number;
  64412. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  64413. static readonly NEVER: number;
  64414. /** 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 */
  64415. static readonly ALWAYS: number;
  64416. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  64417. static readonly LESS: number;
  64418. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  64419. static readonly EQUAL: number;
  64420. /** 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 */
  64421. static readonly LEQUAL: number;
  64422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  64423. static readonly GREATER: number;
  64424. /** 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 */
  64425. static readonly GEQUAL: number;
  64426. /** 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 */
  64427. static readonly NOTEQUAL: number;
  64428. /** Passed to stencilOperation to specify that stencil value must be kept */
  64429. static readonly KEEP: number;
  64430. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64431. static readonly REPLACE: number;
  64432. /** Passed to stencilOperation to specify that stencil value must be incremented */
  64433. static readonly INCR: number;
  64434. /** Passed to stencilOperation to specify that stencil value must be decremented */
  64435. static readonly DECR: number;
  64436. /** Passed to stencilOperation to specify that stencil value must be inverted */
  64437. static readonly INVERT: number;
  64438. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  64439. static readonly INCR_WRAP: number;
  64440. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  64441. static readonly DECR_WRAP: number;
  64442. /** Texture is not repeating outside of 0..1 UVs */
  64443. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  64444. /** Texture is repeating outside of 0..1 UVs */
  64445. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  64446. /** Texture is repeating and mirrored */
  64447. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  64448. /** ALPHA */
  64449. static readonly TEXTUREFORMAT_ALPHA: number;
  64450. /** LUMINANCE */
  64451. static readonly TEXTUREFORMAT_LUMINANCE: number;
  64452. /** LUMINANCE_ALPHA */
  64453. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  64454. /** RGB */
  64455. static readonly TEXTUREFORMAT_RGB: number;
  64456. /** RGBA */
  64457. static readonly TEXTUREFORMAT_RGBA: number;
  64458. /** RED */
  64459. static readonly TEXTUREFORMAT_RED: number;
  64460. /** RED (2nd reference) */
  64461. static readonly TEXTUREFORMAT_R: number;
  64462. /** RG */
  64463. static readonly TEXTUREFORMAT_RG: number;
  64464. /** RED_INTEGER */
  64465. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  64466. /** RED_INTEGER (2nd reference) */
  64467. static readonly TEXTUREFORMAT_R_INTEGER: number;
  64468. /** RG_INTEGER */
  64469. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  64470. /** RGB_INTEGER */
  64471. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  64472. /** RGBA_INTEGER */
  64473. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  64474. /** UNSIGNED_BYTE */
  64475. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  64476. /** UNSIGNED_BYTE (2nd reference) */
  64477. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  64478. /** FLOAT */
  64479. static readonly TEXTURETYPE_FLOAT: number;
  64480. /** HALF_FLOAT */
  64481. static readonly TEXTURETYPE_HALF_FLOAT: number;
  64482. /** BYTE */
  64483. static readonly TEXTURETYPE_BYTE: number;
  64484. /** SHORT */
  64485. static readonly TEXTURETYPE_SHORT: number;
  64486. /** UNSIGNED_SHORT */
  64487. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  64488. /** INT */
  64489. static readonly TEXTURETYPE_INT: number;
  64490. /** UNSIGNED_INT */
  64491. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  64492. /** UNSIGNED_SHORT_4_4_4_4 */
  64493. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  64494. /** UNSIGNED_SHORT_5_5_5_1 */
  64495. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  64496. /** UNSIGNED_SHORT_5_6_5 */
  64497. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  64498. /** UNSIGNED_INT_2_10_10_10_REV */
  64499. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  64500. /** UNSIGNED_INT_24_8 */
  64501. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  64502. /** UNSIGNED_INT_10F_11F_11F_REV */
  64503. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  64504. /** UNSIGNED_INT_5_9_9_9_REV */
  64505. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  64506. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  64507. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64508. /** nearest is mag = nearest and min = nearest and mip = linear */
  64509. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  64510. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64511. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64512. /** Trilinear is mag = linear and min = linear and mip = linear */
  64513. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64514. /** nearest is mag = nearest and min = nearest and mip = linear */
  64515. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64516. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64517. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64518. /** Trilinear is mag = linear and min = linear and mip = linear */
  64519. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64520. /** mag = nearest and min = nearest and mip = nearest */
  64521. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64522. /** mag = nearest and min = linear and mip = nearest */
  64523. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64524. /** mag = nearest and min = linear and mip = linear */
  64525. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64526. /** mag = nearest and min = linear and mip = none */
  64527. static readonly TEXTURE_NEAREST_LINEAR: number;
  64528. /** mag = nearest and min = nearest and mip = none */
  64529. static readonly TEXTURE_NEAREST_NEAREST: number;
  64530. /** mag = linear and min = nearest and mip = nearest */
  64531. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64532. /** mag = linear and min = nearest and mip = linear */
  64533. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64534. /** mag = linear and min = linear and mip = none */
  64535. static readonly TEXTURE_LINEAR_LINEAR: number;
  64536. /** mag = linear and min = nearest and mip = none */
  64537. static readonly TEXTURE_LINEAR_NEAREST: number;
  64538. /** Explicit coordinates mode */
  64539. static readonly TEXTURE_EXPLICIT_MODE: number;
  64540. /** Spherical coordinates mode */
  64541. static readonly TEXTURE_SPHERICAL_MODE: number;
  64542. /** Planar coordinates mode */
  64543. static readonly TEXTURE_PLANAR_MODE: number;
  64544. /** Cubic coordinates mode */
  64545. static readonly TEXTURE_CUBIC_MODE: number;
  64546. /** Projection coordinates mode */
  64547. static readonly TEXTURE_PROJECTION_MODE: number;
  64548. /** Skybox coordinates mode */
  64549. static readonly TEXTURE_SKYBOX_MODE: number;
  64550. /** Inverse Cubic coordinates mode */
  64551. static readonly TEXTURE_INVCUBIC_MODE: number;
  64552. /** Equirectangular coordinates mode */
  64553. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64554. /** Equirectangular Fixed coordinates mode */
  64555. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64556. /** Equirectangular Fixed Mirrored coordinates mode */
  64557. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64558. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64559. static readonly SCALEMODE_FLOOR: number;
  64560. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64561. static readonly SCALEMODE_NEAREST: number;
  64562. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64563. static readonly SCALEMODE_CEILING: number;
  64564. /**
  64565. * The dirty texture flag value
  64566. */
  64567. static readonly MATERIAL_TextureDirtyFlag: number;
  64568. /**
  64569. * The dirty light flag value
  64570. */
  64571. static readonly MATERIAL_LightDirtyFlag: number;
  64572. /**
  64573. * The dirty fresnel flag value
  64574. */
  64575. static readonly MATERIAL_FresnelDirtyFlag: number;
  64576. /**
  64577. * The dirty attribute flag value
  64578. */
  64579. static readonly MATERIAL_AttributesDirtyFlag: number;
  64580. /**
  64581. * The dirty misc flag value
  64582. */
  64583. static readonly MATERIAL_MiscDirtyFlag: number;
  64584. /**
  64585. * The all dirty flag value
  64586. */
  64587. static readonly MATERIAL_AllDirtyFlag: number;
  64588. /**
  64589. * Returns the triangle fill mode
  64590. */
  64591. static readonly MATERIAL_TriangleFillMode: number;
  64592. /**
  64593. * Returns the wireframe mode
  64594. */
  64595. static readonly MATERIAL_WireFrameFillMode: number;
  64596. /**
  64597. * Returns the point fill mode
  64598. */
  64599. static readonly MATERIAL_PointFillMode: number;
  64600. /**
  64601. * Returns the point list draw mode
  64602. */
  64603. static readonly MATERIAL_PointListDrawMode: number;
  64604. /**
  64605. * Returns the line list draw mode
  64606. */
  64607. static readonly MATERIAL_LineListDrawMode: number;
  64608. /**
  64609. * Returns the line loop draw mode
  64610. */
  64611. static readonly MATERIAL_LineLoopDrawMode: number;
  64612. /**
  64613. * Returns the line strip draw mode
  64614. */
  64615. static readonly MATERIAL_LineStripDrawMode: number;
  64616. /**
  64617. * Returns the triangle strip draw mode
  64618. */
  64619. static readonly MATERIAL_TriangleStripDrawMode: number;
  64620. /**
  64621. * Returns the triangle fan draw mode
  64622. */
  64623. static readonly MATERIAL_TriangleFanDrawMode: number;
  64624. /**
  64625. * Stores the clock-wise side orientation
  64626. */
  64627. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64628. /**
  64629. * Stores the counter clock-wise side orientation
  64630. */
  64631. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64632. /**
  64633. * Nothing
  64634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64635. */
  64636. static readonly ACTION_NothingTrigger: number;
  64637. /**
  64638. * On pick
  64639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64640. */
  64641. static readonly ACTION_OnPickTrigger: number;
  64642. /**
  64643. * On left pick
  64644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64645. */
  64646. static readonly ACTION_OnLeftPickTrigger: number;
  64647. /**
  64648. * On right pick
  64649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64650. */
  64651. static readonly ACTION_OnRightPickTrigger: number;
  64652. /**
  64653. * On center pick
  64654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64655. */
  64656. static readonly ACTION_OnCenterPickTrigger: number;
  64657. /**
  64658. * On pick down
  64659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64660. */
  64661. static readonly ACTION_OnPickDownTrigger: number;
  64662. /**
  64663. * On double pick
  64664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64665. */
  64666. static readonly ACTION_OnDoublePickTrigger: number;
  64667. /**
  64668. * On pick up
  64669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64670. */
  64671. static readonly ACTION_OnPickUpTrigger: number;
  64672. /**
  64673. * On pick out.
  64674. * This trigger will only be raised if you also declared a OnPickDown
  64675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64676. */
  64677. static readonly ACTION_OnPickOutTrigger: number;
  64678. /**
  64679. * On long press
  64680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64681. */
  64682. static readonly ACTION_OnLongPressTrigger: number;
  64683. /**
  64684. * On pointer over
  64685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64686. */
  64687. static readonly ACTION_OnPointerOverTrigger: number;
  64688. /**
  64689. * On pointer out
  64690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64691. */
  64692. static readonly ACTION_OnPointerOutTrigger: number;
  64693. /**
  64694. * On every frame
  64695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64696. */
  64697. static readonly ACTION_OnEveryFrameTrigger: number;
  64698. /**
  64699. * On intersection enter
  64700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64701. */
  64702. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64703. /**
  64704. * On intersection exit
  64705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64706. */
  64707. static readonly ACTION_OnIntersectionExitTrigger: number;
  64708. /**
  64709. * On key down
  64710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64711. */
  64712. static readonly ACTION_OnKeyDownTrigger: number;
  64713. /**
  64714. * On key up
  64715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64716. */
  64717. static readonly ACTION_OnKeyUpTrigger: number;
  64718. /**
  64719. * Billboard mode will only apply to Y axis
  64720. */
  64721. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64722. /**
  64723. * Billboard mode will apply to all axes
  64724. */
  64725. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64726. /**
  64727. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64728. */
  64729. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64730. /**
  64731. * Gets or sets base Assets URL
  64732. */
  64733. static readonly PARTICLES_BaseAssetsUrl: string;
  64734. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64735. * Test order :
  64736. * Is the bounding sphere outside the frustum ?
  64737. * If not, are the bounding box vertices outside the frustum ?
  64738. * It not, then the cullable object is in the frustum.
  64739. */
  64740. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64741. /** Culling strategy : Bounding Sphere Only.
  64742. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64743. * It's also less accurate than the standard because some not visible objects can still be selected.
  64744. * Test : is the bounding sphere outside the frustum ?
  64745. * If not, then the cullable object is in the frustum.
  64746. */
  64747. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64748. /** Culling strategy : Optimistic Inclusion.
  64749. * This in an inclusion test first, then the standard exclusion test.
  64750. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64751. * 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.
  64752. * Anyway, it's as accurate as the standard strategy.
  64753. * Test :
  64754. * Is the cullable object bounding sphere center in the frustum ?
  64755. * If not, apply the default culling strategy.
  64756. */
  64757. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64758. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64759. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64760. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64761. * 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.
  64762. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64763. * Test :
  64764. * Is the cullable object bounding sphere center in the frustum ?
  64765. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64766. */
  64767. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64768. /**
  64769. * No logging while loading
  64770. */
  64771. static readonly SCENELOADER_NO_LOGGING: number;
  64772. /**
  64773. * Minimal logging while loading
  64774. */
  64775. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64776. /**
  64777. * Summary logging while loading
  64778. */
  64779. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64780. /**
  64781. * Detailled logging while loading
  64782. */
  64783. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64784. }
  64785. }
  64786. declare module BABYLON {
  64787. /**
  64788. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64789. * Babylon.js
  64790. */
  64791. export class DomManagement {
  64792. /**
  64793. * Checks if the window object exists
  64794. * @returns true if the window object exists
  64795. */
  64796. static IsWindowObjectExist(): boolean;
  64797. /**
  64798. * Extracts text content from a DOM element hierarchy
  64799. * @param element defines the root element
  64800. * @returns a string
  64801. */
  64802. static GetDOMTextContent(element: HTMLElement): string;
  64803. }
  64804. }
  64805. declare module BABYLON {
  64806. /**
  64807. * Logger used througouht the application to allow configuration of
  64808. * the log level required for the messages.
  64809. */
  64810. export class Logger {
  64811. /**
  64812. * No log
  64813. */
  64814. static readonly NoneLogLevel: number;
  64815. /**
  64816. * Only message logs
  64817. */
  64818. static readonly MessageLogLevel: number;
  64819. /**
  64820. * Only warning logs
  64821. */
  64822. static readonly WarningLogLevel: number;
  64823. /**
  64824. * Only error logs
  64825. */
  64826. static readonly ErrorLogLevel: number;
  64827. /**
  64828. * All logs
  64829. */
  64830. static readonly AllLogLevel: number;
  64831. private static _LogCache;
  64832. /**
  64833. * Gets a value indicating the number of loading errors
  64834. * @ignorenaming
  64835. */
  64836. static errorsCount: number;
  64837. /**
  64838. * Callback called when a new log is added
  64839. */
  64840. static OnNewCacheEntry: (entry: string) => void;
  64841. private static _AddLogEntry;
  64842. private static _FormatMessage;
  64843. private static _LogDisabled;
  64844. private static _LogEnabled;
  64845. private static _WarnDisabled;
  64846. private static _WarnEnabled;
  64847. private static _ErrorDisabled;
  64848. private static _ErrorEnabled;
  64849. /**
  64850. * Log a message to the console
  64851. */
  64852. static Log: (message: string) => void;
  64853. /**
  64854. * Write a warning message to the console
  64855. */
  64856. static Warn: (message: string) => void;
  64857. /**
  64858. * Write an error message to the console
  64859. */
  64860. static Error: (message: string) => void;
  64861. /**
  64862. * Gets current log cache (list of logs)
  64863. */
  64864. static readonly LogCache: string;
  64865. /**
  64866. * Clears the log cache
  64867. */
  64868. static ClearLogCache(): void;
  64869. /**
  64870. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64871. */
  64872. static LogLevels: number;
  64873. }
  64874. }
  64875. declare module BABYLON {
  64876. /** @hidden */
  64877. export class _TypeStore {
  64878. /** @hidden */
  64879. static RegisteredTypes: {
  64880. [key: string]: Object;
  64881. };
  64882. /** @hidden */
  64883. static GetClass(fqdn: string): any;
  64884. }
  64885. }
  64886. declare module BABYLON {
  64887. /**
  64888. * Class containing a set of static utilities functions for deep copy.
  64889. */
  64890. export class DeepCopier {
  64891. /**
  64892. * Tries to copy an object by duplicating every property
  64893. * @param source defines the source object
  64894. * @param destination defines the target object
  64895. * @param doNotCopyList defines a list of properties to avoid
  64896. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64897. */
  64898. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64899. }
  64900. }
  64901. declare module BABYLON {
  64902. /**
  64903. * Class containing a set of static utilities functions for precision date
  64904. */
  64905. export class PrecisionDate {
  64906. /**
  64907. * Gets either window.performance.now() if supported or Date.now() else
  64908. */
  64909. static readonly Now: number;
  64910. }
  64911. }
  64912. declare module BABYLON {
  64913. /** @hidden */
  64914. export class _DevTools {
  64915. static WarnImport(name: string): string;
  64916. }
  64917. }
  64918. declare module BABYLON {
  64919. /**
  64920. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64921. */
  64922. export class WebRequest {
  64923. private _xhr;
  64924. /**
  64925. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64926. * i.e. when loading files, where the server/service expects an Authorization header
  64927. */
  64928. static CustomRequestHeaders: {
  64929. [key: string]: string;
  64930. };
  64931. /**
  64932. * Add callback functions in this array to update all the requests before they get sent to the network
  64933. */
  64934. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64935. private _injectCustomRequestHeaders;
  64936. /**
  64937. * Gets or sets a function to be called when loading progress changes
  64938. */
  64939. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64940. /**
  64941. * Returns client's state
  64942. */
  64943. readonly readyState: number;
  64944. /**
  64945. * Returns client's status
  64946. */
  64947. readonly status: number;
  64948. /**
  64949. * Returns client's status as a text
  64950. */
  64951. readonly statusText: string;
  64952. /**
  64953. * Returns client's response
  64954. */
  64955. readonly response: any;
  64956. /**
  64957. * Returns client's response url
  64958. */
  64959. readonly responseURL: string;
  64960. /**
  64961. * Returns client's response as text
  64962. */
  64963. readonly responseText: string;
  64964. /**
  64965. * Gets or sets the expected response type
  64966. */
  64967. responseType: XMLHttpRequestResponseType;
  64968. /** @hidden */
  64969. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64970. /** @hidden */
  64971. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64972. /**
  64973. * Cancels any network activity
  64974. */
  64975. abort(): void;
  64976. /**
  64977. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64978. * @param body defines an optional request body
  64979. */
  64980. send(body?: Document | BodyInit | null): void;
  64981. /**
  64982. * Sets the request method, request URL
  64983. * @param method defines the method to use (GET, POST, etc..)
  64984. * @param url defines the url to connect with
  64985. */
  64986. open(method: string, url: string): void;
  64987. }
  64988. }
  64989. declare module BABYLON {
  64990. /**
  64991. * Class used to evalaute queries containing `and` and `or` operators
  64992. */
  64993. export class AndOrNotEvaluator {
  64994. /**
  64995. * Evaluate a query
  64996. * @param query defines the query to evaluate
  64997. * @param evaluateCallback defines the callback used to filter result
  64998. * @returns true if the query matches
  64999. */
  65000. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  65001. private static _HandleParenthesisContent;
  65002. private static _SimplifyNegation;
  65003. }
  65004. }
  65005. declare module BABYLON {
  65006. /**
  65007. * Class used to store custom tags
  65008. */
  65009. export class Tags {
  65010. /**
  65011. * Adds support for tags on the given object
  65012. * @param obj defines the object to use
  65013. */
  65014. static EnableFor(obj: any): void;
  65015. /**
  65016. * Removes tags support
  65017. * @param obj defines the object to use
  65018. */
  65019. static DisableFor(obj: any): void;
  65020. /**
  65021. * Gets a boolean indicating if the given object has tags
  65022. * @param obj defines the object to use
  65023. * @returns a boolean
  65024. */
  65025. static HasTags(obj: any): boolean;
  65026. /**
  65027. * Gets the tags available on a given object
  65028. * @param obj defines the object to use
  65029. * @param asString defines if the tags must be returned as a string instead of an array of strings
  65030. * @returns the tags
  65031. */
  65032. static GetTags(obj: any, asString?: boolean): any;
  65033. /**
  65034. * Adds tags to an object
  65035. * @param obj defines the object to use
  65036. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  65037. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  65038. */
  65039. static AddTagsTo(obj: any, tagsString: string): void;
  65040. /**
  65041. * @hidden
  65042. */
  65043. static _AddTagTo(obj: any, tag: string): void;
  65044. /**
  65045. * Removes specific tags from a specific object
  65046. * @param obj defines the object to use
  65047. * @param tagsString defines the tags to remove
  65048. */
  65049. static RemoveTagsFrom(obj: any, tagsString: string): void;
  65050. /**
  65051. * @hidden
  65052. */
  65053. static _RemoveTagFrom(obj: any, tag: string): void;
  65054. /**
  65055. * Defines if tags hosted on an object match a given query
  65056. * @param obj defines the object to use
  65057. * @param tagsQuery defines the tag query
  65058. * @returns a boolean
  65059. */
  65060. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  65061. }
  65062. }
  65063. declare module BABYLON {
  65064. /**
  65065. * Manages the defines for the Material
  65066. */
  65067. export class MaterialDefines {
  65068. private _keys;
  65069. private _isDirty;
  65070. /** @hidden */
  65071. _renderId: number;
  65072. /** @hidden */
  65073. _areLightsDirty: boolean;
  65074. /** @hidden */
  65075. _areAttributesDirty: boolean;
  65076. /** @hidden */
  65077. _areTexturesDirty: boolean;
  65078. /** @hidden */
  65079. _areFresnelDirty: boolean;
  65080. /** @hidden */
  65081. _areMiscDirty: boolean;
  65082. /** @hidden */
  65083. _areImageProcessingDirty: boolean;
  65084. /** @hidden */
  65085. _normals: boolean;
  65086. /** @hidden */
  65087. _uvs: boolean;
  65088. /** @hidden */
  65089. _needNormals: boolean;
  65090. /** @hidden */
  65091. _needUVs: boolean;
  65092. /**
  65093. * Specifies if the material needs to be re-calculated
  65094. */
  65095. readonly isDirty: boolean;
  65096. /**
  65097. * Marks the material to indicate that it has been re-calculated
  65098. */
  65099. markAsProcessed(): void;
  65100. /**
  65101. * Marks the material to indicate that it needs to be re-calculated
  65102. */
  65103. markAsUnprocessed(): void;
  65104. /**
  65105. * Marks the material to indicate all of its defines need to be re-calculated
  65106. */
  65107. markAllAsDirty(): void;
  65108. /**
  65109. * Marks the material to indicate that image processing needs to be re-calculated
  65110. */
  65111. markAsImageProcessingDirty(): void;
  65112. /**
  65113. * Marks the material to indicate the lights need to be re-calculated
  65114. */
  65115. markAsLightDirty(): void;
  65116. /**
  65117. * Marks the attribute state as changed
  65118. */
  65119. markAsAttributesDirty(): void;
  65120. /**
  65121. * Marks the texture state as changed
  65122. */
  65123. markAsTexturesDirty(): void;
  65124. /**
  65125. * Marks the fresnel state as changed
  65126. */
  65127. markAsFresnelDirty(): void;
  65128. /**
  65129. * Marks the misc state as changed
  65130. */
  65131. markAsMiscDirty(): void;
  65132. /**
  65133. * Rebuilds the material defines
  65134. */
  65135. rebuild(): void;
  65136. /**
  65137. * Specifies if two material defines are equal
  65138. * @param other - A material define instance to compare to
  65139. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  65140. */
  65141. isEqual(other: MaterialDefines): boolean;
  65142. /**
  65143. * Clones this instance's defines to another instance
  65144. * @param other - material defines to clone values to
  65145. */
  65146. cloneTo(other: MaterialDefines): void;
  65147. /**
  65148. * Resets the material define values
  65149. */
  65150. reset(): void;
  65151. /**
  65152. * Converts the material define values to a string
  65153. * @returns - String of material define information
  65154. */
  65155. toString(): string;
  65156. }
  65157. }
  65158. declare module BABYLON {
  65159. /**
  65160. * Class used to store and describe the pipeline context associated with an effect
  65161. */
  65162. export interface IPipelineContext {
  65163. /**
  65164. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  65165. */
  65166. isAsync: boolean;
  65167. /**
  65168. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  65169. */
  65170. isReady: boolean;
  65171. /** @hidden */
  65172. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  65173. }
  65174. }
  65175. declare module BABYLON {
  65176. /**
  65177. * Class used to store gfx data (like WebGLBuffer)
  65178. */
  65179. export class DataBuffer {
  65180. /**
  65181. * Gets or sets the number of objects referencing this buffer
  65182. */
  65183. references: number;
  65184. /** Gets or sets the size of the underlying buffer */
  65185. capacity: number;
  65186. /**
  65187. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65188. */
  65189. is32Bits: boolean;
  65190. /**
  65191. * Gets the underlying buffer
  65192. */
  65193. readonly underlyingResource: any;
  65194. }
  65195. }
  65196. declare module BABYLON {
  65197. /**
  65198. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65199. */
  65200. export class PerformanceMonitor {
  65201. private _enabled;
  65202. private _rollingFrameTime;
  65203. private _lastFrameTimeMs;
  65204. /**
  65205. * constructor
  65206. * @param frameSampleSize The number of samples required to saturate the sliding window
  65207. */
  65208. constructor(frameSampleSize?: number);
  65209. /**
  65210. * Samples current frame
  65211. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65212. */
  65213. sampleFrame(timeMs?: number): void;
  65214. /**
  65215. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65216. */
  65217. readonly averageFrameTime: number;
  65218. /**
  65219. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65220. */
  65221. readonly averageFrameTimeVariance: number;
  65222. /**
  65223. * Returns the frame time of the most recent frame
  65224. */
  65225. readonly instantaneousFrameTime: number;
  65226. /**
  65227. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65228. */
  65229. readonly averageFPS: number;
  65230. /**
  65231. * Returns the average framerate in frames per second using the most recent frame time
  65232. */
  65233. readonly instantaneousFPS: number;
  65234. /**
  65235. * Returns true if enough samples have been taken to completely fill the sliding window
  65236. */
  65237. readonly isSaturated: boolean;
  65238. /**
  65239. * Enables contributions to the sliding window sample set
  65240. */
  65241. enable(): void;
  65242. /**
  65243. * Disables contributions to the sliding window sample set
  65244. * Samples will not be interpolated over the disabled period
  65245. */
  65246. disable(): void;
  65247. /**
  65248. * Returns true if sampling is enabled
  65249. */
  65250. readonly isEnabled: boolean;
  65251. /**
  65252. * Resets performance monitor
  65253. */
  65254. reset(): void;
  65255. }
  65256. /**
  65257. * RollingAverage
  65258. *
  65259. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65260. */
  65261. export class RollingAverage {
  65262. /**
  65263. * Current average
  65264. */
  65265. average: number;
  65266. /**
  65267. * Current variance
  65268. */
  65269. variance: number;
  65270. protected _samples: Array<number>;
  65271. protected _sampleCount: number;
  65272. protected _pos: number;
  65273. protected _m2: number;
  65274. /**
  65275. * constructor
  65276. * @param length The number of samples required to saturate the sliding window
  65277. */
  65278. constructor(length: number);
  65279. /**
  65280. * Adds a sample to the sample set
  65281. * @param v The sample value
  65282. */
  65283. add(v: number): void;
  65284. /**
  65285. * Returns previously added values or null if outside of history or outside the sliding window domain
  65286. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65287. * @return Value previously recorded with add() or null if outside of range
  65288. */
  65289. history(i: number): number;
  65290. /**
  65291. * Returns true if enough samples have been taken to completely fill the sliding window
  65292. * @return true if sample-set saturated
  65293. */
  65294. isSaturated(): boolean;
  65295. /**
  65296. * Resets the rolling average (equivalent to 0 samples taken so far)
  65297. */
  65298. reset(): void;
  65299. /**
  65300. * Wraps a value around the sample range boundaries
  65301. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65302. * @return Wrapped position in sample range
  65303. */
  65304. protected _wrapPosition(i: number): number;
  65305. }
  65306. }
  65307. declare module BABYLON {
  65308. /**
  65309. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65310. * The underlying implementation relies on an associative array to ensure the best performances.
  65311. * The value can be anything including 'null' but except 'undefined'
  65312. */
  65313. export class StringDictionary<T> {
  65314. /**
  65315. * This will clear this dictionary and copy the content from the 'source' one.
  65316. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65317. * @param source the dictionary to take the content from and copy to this dictionary
  65318. */
  65319. copyFrom(source: StringDictionary<T>): void;
  65320. /**
  65321. * Get a value based from its key
  65322. * @param key the given key to get the matching value from
  65323. * @return the value if found, otherwise undefined is returned
  65324. */
  65325. get(key: string): T | undefined;
  65326. /**
  65327. * Get a value from its key or add it if it doesn't exist.
  65328. * This method will ensure you that a given key/data will be present in the dictionary.
  65329. * @param key the given key to get the matching value from
  65330. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65331. * The factory will only be invoked if there's no data for the given key.
  65332. * @return the value corresponding to the key.
  65333. */
  65334. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65335. /**
  65336. * Get a value from its key if present in the dictionary otherwise add it
  65337. * @param key the key to get the value from
  65338. * @param val if there's no such key/value pair in the dictionary add it with this value
  65339. * @return the value corresponding to the key
  65340. */
  65341. getOrAdd(key: string, val: T): T;
  65342. /**
  65343. * Check if there's a given key in the dictionary
  65344. * @param key the key to check for
  65345. * @return true if the key is present, false otherwise
  65346. */
  65347. contains(key: string): boolean;
  65348. /**
  65349. * Add a new key and its corresponding value
  65350. * @param key the key to add
  65351. * @param value the value corresponding to the key
  65352. * @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
  65353. */
  65354. add(key: string, value: T): boolean;
  65355. /**
  65356. * Update a specific value associated to a key
  65357. * @param key defines the key to use
  65358. * @param value defines the value to store
  65359. * @returns true if the value was updated (or false if the key was not found)
  65360. */
  65361. set(key: string, value: T): boolean;
  65362. /**
  65363. * Get the element of the given key and remove it from the dictionary
  65364. * @param key defines the key to search
  65365. * @returns the value associated with the key or null if not found
  65366. */
  65367. getAndRemove(key: string): Nullable<T>;
  65368. /**
  65369. * Remove a key/value from the dictionary.
  65370. * @param key the key to remove
  65371. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65372. */
  65373. remove(key: string): boolean;
  65374. /**
  65375. * Clear the whole content of the dictionary
  65376. */
  65377. clear(): void;
  65378. /**
  65379. * Gets the current count
  65380. */
  65381. readonly count: number;
  65382. /**
  65383. * Execute a callback on each key/val of the dictionary.
  65384. * Note that you can remove any element in this dictionary in the callback implementation
  65385. * @param callback the callback to execute on a given key/value pair
  65386. */
  65387. forEach(callback: (key: string, val: T) => void): void;
  65388. /**
  65389. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65390. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65391. * Note that you can remove any element in this dictionary in the callback implementation
  65392. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65393. * @returns the first item
  65394. */
  65395. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65396. private _count;
  65397. private _data;
  65398. }
  65399. }
  65400. declare module BABYLON {
  65401. /**
  65402. * Helper class that provides a small promise polyfill
  65403. */
  65404. export class PromisePolyfill {
  65405. /**
  65406. * Static function used to check if the polyfill is required
  65407. * If this is the case then the function will inject the polyfill to window.Promise
  65408. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  65409. */
  65410. static Apply(force?: boolean): void;
  65411. }
  65412. }
  65413. declare module BABYLON {
  65414. /**
  65415. * Class used to store data that will be store in GPU memory
  65416. */
  65417. export class Buffer {
  65418. private _engine;
  65419. private _buffer;
  65420. /** @hidden */
  65421. _data: Nullable<DataArray>;
  65422. private _updatable;
  65423. private _instanced;
  65424. /**
  65425. * Gets the byte stride.
  65426. */
  65427. readonly byteStride: number;
  65428. /**
  65429. * Constructor
  65430. * @param engine the engine
  65431. * @param data the data to use for this buffer
  65432. * @param updatable whether the data is updatable
  65433. * @param stride the stride (optional)
  65434. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65435. * @param instanced whether the buffer is instanced (optional)
  65436. * @param useBytes set to true if the stride in in bytes (optional)
  65437. */
  65438. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65439. /**
  65440. * Create a new VertexBuffer based on the current buffer
  65441. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65442. * @param offset defines offset in the buffer (0 by default)
  65443. * @param size defines the size in floats of attributes (position is 3 for instance)
  65444. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65445. * @param instanced defines if the vertex buffer contains indexed data
  65446. * @param useBytes defines if the offset and stride are in bytes
  65447. * @returns the new vertex buffer
  65448. */
  65449. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65450. /**
  65451. * Gets a boolean indicating if the Buffer is updatable?
  65452. * @returns true if the buffer is updatable
  65453. */
  65454. isUpdatable(): boolean;
  65455. /**
  65456. * Gets current buffer's data
  65457. * @returns a DataArray or null
  65458. */
  65459. getData(): Nullable<DataArray>;
  65460. /**
  65461. * Gets underlying native buffer
  65462. * @returns underlying native buffer
  65463. */
  65464. getBuffer(): Nullable<DataBuffer>;
  65465. /**
  65466. * Gets the stride in float32 units (i.e. byte stride / 4).
  65467. * May not be an integer if the byte stride is not divisible by 4.
  65468. * DEPRECATED. Use byteStride instead.
  65469. * @returns the stride in float32 units
  65470. */
  65471. getStrideSize(): number;
  65472. /**
  65473. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65474. * @param data defines the data to store
  65475. */
  65476. create(data?: Nullable<DataArray>): void;
  65477. /** @hidden */
  65478. _rebuild(): void;
  65479. /**
  65480. * Update current buffer data
  65481. * @param data defines the data to store
  65482. */
  65483. update(data: DataArray): void;
  65484. /**
  65485. * Updates the data directly.
  65486. * @param data the new data
  65487. * @param offset the new offset
  65488. * @param vertexCount the vertex count (optional)
  65489. * @param useBytes set to true if the offset is in bytes
  65490. */
  65491. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65492. /**
  65493. * Release all resources
  65494. */
  65495. dispose(): void;
  65496. }
  65497. /**
  65498. * Specialized buffer used to store vertex data
  65499. */
  65500. export class VertexBuffer {
  65501. /** @hidden */
  65502. _buffer: Buffer;
  65503. private _kind;
  65504. private _size;
  65505. private _ownsBuffer;
  65506. private _instanced;
  65507. private _instanceDivisor;
  65508. /**
  65509. * The byte type.
  65510. */
  65511. static readonly BYTE: number;
  65512. /**
  65513. * The unsigned byte type.
  65514. */
  65515. static readonly UNSIGNED_BYTE: number;
  65516. /**
  65517. * The short type.
  65518. */
  65519. static readonly SHORT: number;
  65520. /**
  65521. * The unsigned short type.
  65522. */
  65523. static readonly UNSIGNED_SHORT: number;
  65524. /**
  65525. * The integer type.
  65526. */
  65527. static readonly INT: number;
  65528. /**
  65529. * The unsigned integer type.
  65530. */
  65531. static readonly UNSIGNED_INT: number;
  65532. /**
  65533. * The float type.
  65534. */
  65535. static readonly FLOAT: number;
  65536. /**
  65537. * Gets or sets the instance divisor when in instanced mode
  65538. */
  65539. instanceDivisor: number;
  65540. /**
  65541. * Gets the byte stride.
  65542. */
  65543. readonly byteStride: number;
  65544. /**
  65545. * Gets the byte offset.
  65546. */
  65547. readonly byteOffset: number;
  65548. /**
  65549. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65550. */
  65551. readonly normalized: boolean;
  65552. /**
  65553. * Gets the data type of each component in the array.
  65554. */
  65555. readonly type: number;
  65556. /**
  65557. * Constructor
  65558. * @param engine the engine
  65559. * @param data the data to use for this vertex buffer
  65560. * @param kind the vertex buffer kind
  65561. * @param updatable whether the data is updatable
  65562. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65563. * @param stride the stride (optional)
  65564. * @param instanced whether the buffer is instanced (optional)
  65565. * @param offset the offset of the data (optional)
  65566. * @param size the number of components (optional)
  65567. * @param type the type of the component (optional)
  65568. * @param normalized whether the data contains normalized data (optional)
  65569. * @param useBytes set to true if stride and offset are in bytes (optional)
  65570. */
  65571. 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);
  65572. /** @hidden */
  65573. _rebuild(): void;
  65574. /**
  65575. * Returns the kind of the VertexBuffer (string)
  65576. * @returns a string
  65577. */
  65578. getKind(): string;
  65579. /**
  65580. * Gets a boolean indicating if the VertexBuffer is updatable?
  65581. * @returns true if the buffer is updatable
  65582. */
  65583. isUpdatable(): boolean;
  65584. /**
  65585. * Gets current buffer's data
  65586. * @returns a DataArray or null
  65587. */
  65588. getData(): Nullable<DataArray>;
  65589. /**
  65590. * Gets underlying native buffer
  65591. * @returns underlying native buffer
  65592. */
  65593. getBuffer(): Nullable<DataBuffer>;
  65594. /**
  65595. * Gets the stride in float32 units (i.e. byte stride / 4).
  65596. * May not be an integer if the byte stride is not divisible by 4.
  65597. * DEPRECATED. Use byteStride instead.
  65598. * @returns the stride in float32 units
  65599. */
  65600. getStrideSize(): number;
  65601. /**
  65602. * Returns the offset as a multiple of the type byte length.
  65603. * DEPRECATED. Use byteOffset instead.
  65604. * @returns the offset in bytes
  65605. */
  65606. getOffset(): number;
  65607. /**
  65608. * Returns the number of components per vertex attribute (integer)
  65609. * @returns the size in float
  65610. */
  65611. getSize(): number;
  65612. /**
  65613. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65614. * @returns true if this buffer is instanced
  65615. */
  65616. getIsInstanced(): boolean;
  65617. /**
  65618. * Returns the instancing divisor, zero for non-instanced (integer).
  65619. * @returns a number
  65620. */
  65621. getInstanceDivisor(): number;
  65622. /**
  65623. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65624. * @param data defines the data to store
  65625. */
  65626. create(data?: DataArray): void;
  65627. /**
  65628. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65629. * This function will create a new buffer if the current one is not updatable
  65630. * @param data defines the data to store
  65631. */
  65632. update(data: DataArray): void;
  65633. /**
  65634. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65635. * Returns the directly updated WebGLBuffer.
  65636. * @param data the new data
  65637. * @param offset the new offset
  65638. * @param useBytes set to true if the offset is in bytes
  65639. */
  65640. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65641. /**
  65642. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65643. */
  65644. dispose(): void;
  65645. /**
  65646. * Enumerates each value of this vertex buffer as numbers.
  65647. * @param count the number of values to enumerate
  65648. * @param callback the callback function called for each value
  65649. */
  65650. forEach(count: number, callback: (value: number, index: number) => void): void;
  65651. /**
  65652. * Positions
  65653. */
  65654. static readonly PositionKind: string;
  65655. /**
  65656. * Normals
  65657. */
  65658. static readonly NormalKind: string;
  65659. /**
  65660. * Tangents
  65661. */
  65662. static readonly TangentKind: string;
  65663. /**
  65664. * Texture coordinates
  65665. */
  65666. static readonly UVKind: string;
  65667. /**
  65668. * Texture coordinates 2
  65669. */
  65670. static readonly UV2Kind: string;
  65671. /**
  65672. * Texture coordinates 3
  65673. */
  65674. static readonly UV3Kind: string;
  65675. /**
  65676. * Texture coordinates 4
  65677. */
  65678. static readonly UV4Kind: string;
  65679. /**
  65680. * Texture coordinates 5
  65681. */
  65682. static readonly UV5Kind: string;
  65683. /**
  65684. * Texture coordinates 6
  65685. */
  65686. static readonly UV6Kind: string;
  65687. /**
  65688. * Colors
  65689. */
  65690. static readonly ColorKind: string;
  65691. /**
  65692. * Matrix indices (for bones)
  65693. */
  65694. static readonly MatricesIndicesKind: string;
  65695. /**
  65696. * Matrix weights (for bones)
  65697. */
  65698. static readonly MatricesWeightsKind: string;
  65699. /**
  65700. * Additional matrix indices (for bones)
  65701. */
  65702. static readonly MatricesIndicesExtraKind: string;
  65703. /**
  65704. * Additional matrix weights (for bones)
  65705. */
  65706. static readonly MatricesWeightsExtraKind: string;
  65707. /**
  65708. * Deduces the stride given a kind.
  65709. * @param kind The kind string to deduce
  65710. * @returns The deduced stride
  65711. */
  65712. static DeduceStride(kind: string): number;
  65713. /**
  65714. * Gets the byte length of the given type.
  65715. * @param type the type
  65716. * @returns the number of bytes
  65717. */
  65718. static GetTypeByteLength(type: number): number;
  65719. /**
  65720. * Enumerates each value of the given parameters as numbers.
  65721. * @param data the data to enumerate
  65722. * @param byteOffset the byte offset of the data
  65723. * @param byteStride the byte stride of the data
  65724. * @param componentCount the number of components per element
  65725. * @param componentType the type of the component
  65726. * @param count the total number of components
  65727. * @param normalized whether the data is normalized
  65728. * @param callback the callback function called for each value
  65729. */
  65730. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65731. private static _GetFloatValue;
  65732. }
  65733. }
  65734. declare module BABYLON {
  65735. /**
  65736. * Class representing spherical harmonics coefficients to the 3rd degree
  65737. */
  65738. export class SphericalHarmonics {
  65739. /**
  65740. * Defines whether or not the harmonics have been prescaled for rendering.
  65741. */
  65742. preScaled: boolean;
  65743. /**
  65744. * The l0,0 coefficients of the spherical harmonics
  65745. */
  65746. l00: Vector3;
  65747. /**
  65748. * The l1,-1 coefficients of the spherical harmonics
  65749. */
  65750. l1_1: Vector3;
  65751. /**
  65752. * The l1,0 coefficients of the spherical harmonics
  65753. */
  65754. l10: Vector3;
  65755. /**
  65756. * The l1,1 coefficients of the spherical harmonics
  65757. */
  65758. l11: Vector3;
  65759. /**
  65760. * The l2,-2 coefficients of the spherical harmonics
  65761. */
  65762. l2_2: Vector3;
  65763. /**
  65764. * The l2,-1 coefficients of the spherical harmonics
  65765. */
  65766. l2_1: Vector3;
  65767. /**
  65768. * The l2,0 coefficients of the spherical harmonics
  65769. */
  65770. l20: Vector3;
  65771. /**
  65772. * The l2,1 coefficients of the spherical harmonics
  65773. */
  65774. l21: Vector3;
  65775. /**
  65776. * The l2,2 coefficients of the spherical harmonics
  65777. */
  65778. l22: Vector3;
  65779. /**
  65780. * Adds a light to the spherical harmonics
  65781. * @param direction the direction of the light
  65782. * @param color the color of the light
  65783. * @param deltaSolidAngle the delta solid angle of the light
  65784. */
  65785. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65786. /**
  65787. * Scales the spherical harmonics by the given amount
  65788. * @param scale the amount to scale
  65789. */
  65790. scaleInPlace(scale: number): void;
  65791. /**
  65792. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65793. *
  65794. * ```
  65795. * E_lm = A_l * L_lm
  65796. * ```
  65797. *
  65798. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65799. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65800. * the scaling factors are given in equation 9.
  65801. */
  65802. convertIncidentRadianceToIrradiance(): void;
  65803. /**
  65804. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65805. *
  65806. * ```
  65807. * L = (1/pi) * E * rho
  65808. * ```
  65809. *
  65810. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65811. */
  65812. convertIrradianceToLambertianRadiance(): void;
  65813. /**
  65814. * Integrates the reconstruction coefficients directly in to the SH preventing further
  65815. * required operations at run time.
  65816. *
  65817. * This is simply done by scaling back the SH with Ylm constants parameter.
  65818. * The trigonometric part being applied by the shader at run time.
  65819. */
  65820. preScaleForRendering(): void;
  65821. /**
  65822. * Constructs a spherical harmonics from an array.
  65823. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65824. * @returns the spherical harmonics
  65825. */
  65826. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65827. /**
  65828. * Gets the spherical harmonics from polynomial
  65829. * @param polynomial the spherical polynomial
  65830. * @returns the spherical harmonics
  65831. */
  65832. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65833. }
  65834. /**
  65835. * Class representing spherical polynomial coefficients to the 3rd degree
  65836. */
  65837. export class SphericalPolynomial {
  65838. private _harmonics;
  65839. /**
  65840. * The spherical harmonics used to create the polynomials.
  65841. */
  65842. readonly preScaledHarmonics: SphericalHarmonics;
  65843. /**
  65844. * The x coefficients of the spherical polynomial
  65845. */
  65846. x: Vector3;
  65847. /**
  65848. * The y coefficients of the spherical polynomial
  65849. */
  65850. y: Vector3;
  65851. /**
  65852. * The z coefficients of the spherical polynomial
  65853. */
  65854. z: Vector3;
  65855. /**
  65856. * The xx coefficients of the spherical polynomial
  65857. */
  65858. xx: Vector3;
  65859. /**
  65860. * The yy coefficients of the spherical polynomial
  65861. */
  65862. yy: Vector3;
  65863. /**
  65864. * The zz coefficients of the spherical polynomial
  65865. */
  65866. zz: Vector3;
  65867. /**
  65868. * The xy coefficients of the spherical polynomial
  65869. */
  65870. xy: Vector3;
  65871. /**
  65872. * The yz coefficients of the spherical polynomial
  65873. */
  65874. yz: Vector3;
  65875. /**
  65876. * The zx coefficients of the spherical polynomial
  65877. */
  65878. zx: Vector3;
  65879. /**
  65880. * Adds an ambient color to the spherical polynomial
  65881. * @param color the color to add
  65882. */
  65883. addAmbient(color: Color3): void;
  65884. /**
  65885. * Scales the spherical polynomial by the given amount
  65886. * @param scale the amount to scale
  65887. */
  65888. scaleInPlace(scale: number): void;
  65889. /**
  65890. * Gets the spherical polynomial from harmonics
  65891. * @param harmonics the spherical harmonics
  65892. * @returns the spherical polynomial
  65893. */
  65894. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65895. /**
  65896. * Constructs a spherical polynomial from an array.
  65897. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65898. * @returns the spherical polynomial
  65899. */
  65900. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65901. }
  65902. }
  65903. declare module BABYLON {
  65904. /**
  65905. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65906. */
  65907. export interface CubeMapInfo {
  65908. /**
  65909. * The pixel array for the front face.
  65910. * This is stored in format, left to right, up to down format.
  65911. */
  65912. front: Nullable<ArrayBufferView>;
  65913. /**
  65914. * The pixel array for the back face.
  65915. * This is stored in format, left to right, up to down format.
  65916. */
  65917. back: Nullable<ArrayBufferView>;
  65918. /**
  65919. * The pixel array for the left face.
  65920. * This is stored in format, left to right, up to down format.
  65921. */
  65922. left: Nullable<ArrayBufferView>;
  65923. /**
  65924. * The pixel array for the right face.
  65925. * This is stored in format, left to right, up to down format.
  65926. */
  65927. right: Nullable<ArrayBufferView>;
  65928. /**
  65929. * The pixel array for the up face.
  65930. * This is stored in format, left to right, up to down format.
  65931. */
  65932. up: Nullable<ArrayBufferView>;
  65933. /**
  65934. * The pixel array for the down face.
  65935. * This is stored in format, left to right, up to down format.
  65936. */
  65937. down: Nullable<ArrayBufferView>;
  65938. /**
  65939. * The size of the cubemap stored.
  65940. *
  65941. * Each faces will be size * size pixels.
  65942. */
  65943. size: number;
  65944. /**
  65945. * The format of the texture.
  65946. *
  65947. * RGBA, RGB.
  65948. */
  65949. format: number;
  65950. /**
  65951. * The type of the texture data.
  65952. *
  65953. * UNSIGNED_INT, FLOAT.
  65954. */
  65955. type: number;
  65956. /**
  65957. * Specifies whether the texture is in gamma space.
  65958. */
  65959. gammaSpace: boolean;
  65960. }
  65961. /**
  65962. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65963. */
  65964. export class PanoramaToCubeMapTools {
  65965. private static FACE_FRONT;
  65966. private static FACE_BACK;
  65967. private static FACE_RIGHT;
  65968. private static FACE_LEFT;
  65969. private static FACE_DOWN;
  65970. private static FACE_UP;
  65971. /**
  65972. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65973. *
  65974. * @param float32Array The source data.
  65975. * @param inputWidth The width of the input panorama.
  65976. * @param inputHeight The height of the input panorama.
  65977. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65978. * @return The cubemap data
  65979. */
  65980. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65981. private static CreateCubemapTexture;
  65982. private static CalcProjectionSpherical;
  65983. }
  65984. }
  65985. declare module BABYLON {
  65986. /**
  65987. * Helper class dealing with the extraction of spherical polynomial dataArray
  65988. * from a cube map.
  65989. */
  65990. export class CubeMapToSphericalPolynomialTools {
  65991. private static FileFaces;
  65992. /**
  65993. * Converts a texture to the according Spherical Polynomial data.
  65994. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65995. *
  65996. * @param texture The texture to extract the information from.
  65997. * @return The Spherical Polynomial data.
  65998. */
  65999. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  66000. /**
  66001. * Converts a cubemap to the according Spherical Polynomial data.
  66002. * This extracts the first 3 orders only as they are the only one used in the lighting.
  66003. *
  66004. * @param cubeInfo The Cube map to extract the information from.
  66005. * @return The Spherical Polynomial data.
  66006. */
  66007. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  66008. }
  66009. }
  66010. declare module BABYLON {
  66011. /**
  66012. * The engine store class is responsible to hold all the instances of Engine and Scene created
  66013. * during the life time of the application.
  66014. */
  66015. export class EngineStore {
  66016. /** Gets the list of created engines */
  66017. static Instances: Engine[];
  66018. /**
  66019. * Gets the latest created engine
  66020. */
  66021. static readonly LastCreatedEngine: Nullable<Engine>;
  66022. /**
  66023. * Gets the latest created scene
  66024. */
  66025. static readonly LastCreatedScene: Nullable<Scene>;
  66026. }
  66027. }
  66028. declare module BABYLON {
  66029. /**
  66030. * Define options used to create a render target texture
  66031. */
  66032. export class RenderTargetCreationOptions {
  66033. /**
  66034. * Specifies is mipmaps must be generated
  66035. */
  66036. generateMipMaps?: boolean;
  66037. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  66038. generateDepthBuffer?: boolean;
  66039. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  66040. generateStencilBuffer?: boolean;
  66041. /** Defines texture type (int by default) */
  66042. type?: number;
  66043. /** Defines sampling mode (trilinear by default) */
  66044. samplingMode?: number;
  66045. /** Defines format (RGBA by default) */
  66046. format?: number;
  66047. }
  66048. }
  66049. declare module BABYLON {
  66050. /**
  66051. * @hidden
  66052. **/
  66053. export class _AlphaState {
  66054. private _isAlphaBlendDirty;
  66055. private _isBlendFunctionParametersDirty;
  66056. private _isBlendEquationParametersDirty;
  66057. private _isBlendConstantsDirty;
  66058. private _alphaBlend;
  66059. private _blendFunctionParameters;
  66060. private _blendEquationParameters;
  66061. private _blendConstants;
  66062. /**
  66063. * Initializes the state.
  66064. */
  66065. constructor();
  66066. readonly isDirty: boolean;
  66067. alphaBlend: boolean;
  66068. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  66069. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  66070. setAlphaEquationParameters(rgb: number, alpha: number): void;
  66071. reset(): void;
  66072. apply(gl: WebGLRenderingContext): void;
  66073. }
  66074. }
  66075. declare module BABYLON {
  66076. /**
  66077. * @hidden
  66078. **/
  66079. export class _DepthCullingState {
  66080. private _isDepthTestDirty;
  66081. private _isDepthMaskDirty;
  66082. private _isDepthFuncDirty;
  66083. private _isCullFaceDirty;
  66084. private _isCullDirty;
  66085. private _isZOffsetDirty;
  66086. private _isFrontFaceDirty;
  66087. private _depthTest;
  66088. private _depthMask;
  66089. private _depthFunc;
  66090. private _cull;
  66091. private _cullFace;
  66092. private _zOffset;
  66093. private _frontFace;
  66094. /**
  66095. * Initializes the state.
  66096. */
  66097. constructor();
  66098. readonly isDirty: boolean;
  66099. zOffset: number;
  66100. cullFace: Nullable<number>;
  66101. cull: Nullable<boolean>;
  66102. depthFunc: Nullable<number>;
  66103. depthMask: boolean;
  66104. depthTest: boolean;
  66105. frontFace: Nullable<number>;
  66106. reset(): void;
  66107. apply(gl: WebGLRenderingContext): void;
  66108. }
  66109. }
  66110. declare module BABYLON {
  66111. /**
  66112. * @hidden
  66113. **/
  66114. export class _StencilState {
  66115. /** 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 */
  66116. static readonly ALWAYS: number;
  66117. /** Passed to stencilOperation to specify that stencil value must be kept */
  66118. static readonly KEEP: number;
  66119. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66120. static readonly REPLACE: number;
  66121. private _isStencilTestDirty;
  66122. private _isStencilMaskDirty;
  66123. private _isStencilFuncDirty;
  66124. private _isStencilOpDirty;
  66125. private _stencilTest;
  66126. private _stencilMask;
  66127. private _stencilFunc;
  66128. private _stencilFuncRef;
  66129. private _stencilFuncMask;
  66130. private _stencilOpStencilFail;
  66131. private _stencilOpDepthFail;
  66132. private _stencilOpStencilDepthPass;
  66133. readonly isDirty: boolean;
  66134. stencilFunc: number;
  66135. stencilFuncRef: number;
  66136. stencilFuncMask: number;
  66137. stencilOpStencilFail: number;
  66138. stencilOpDepthFail: number;
  66139. stencilOpStencilDepthPass: number;
  66140. stencilMask: number;
  66141. stencilTest: boolean;
  66142. constructor();
  66143. reset(): void;
  66144. apply(gl: WebGLRenderingContext): void;
  66145. }
  66146. }
  66147. declare module BABYLON {
  66148. /**
  66149. * @hidden
  66150. **/
  66151. export class _TimeToken {
  66152. _startTimeQuery: Nullable<WebGLQuery>;
  66153. _endTimeQuery: Nullable<WebGLQuery>;
  66154. _timeElapsedQuery: Nullable<WebGLQuery>;
  66155. _timeElapsedQueryEnded: boolean;
  66156. }
  66157. }
  66158. declare module BABYLON {
  66159. /**
  66160. * Class used to store data associated with WebGL texture data for the engine
  66161. * This class should not be used directly
  66162. */
  66163. export class InternalTexture {
  66164. /** hidden */
  66165. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  66166. /**
  66167. * The source of the texture data is unknown
  66168. */
  66169. static DATASOURCE_UNKNOWN: number;
  66170. /**
  66171. * Texture data comes from an URL
  66172. */
  66173. static DATASOURCE_URL: number;
  66174. /**
  66175. * Texture data is only used for temporary storage
  66176. */
  66177. static DATASOURCE_TEMP: number;
  66178. /**
  66179. * Texture data comes from raw data (ArrayBuffer)
  66180. */
  66181. static DATASOURCE_RAW: number;
  66182. /**
  66183. * Texture content is dynamic (video or dynamic texture)
  66184. */
  66185. static DATASOURCE_DYNAMIC: number;
  66186. /**
  66187. * Texture content is generated by rendering to it
  66188. */
  66189. static DATASOURCE_RENDERTARGET: number;
  66190. /**
  66191. * Texture content is part of a multi render target process
  66192. */
  66193. static DATASOURCE_MULTIRENDERTARGET: number;
  66194. /**
  66195. * Texture data comes from a cube data file
  66196. */
  66197. static DATASOURCE_CUBE: number;
  66198. /**
  66199. * Texture data comes from a raw cube data
  66200. */
  66201. static DATASOURCE_CUBERAW: number;
  66202. /**
  66203. * Texture data come from a prefiltered cube data file
  66204. */
  66205. static DATASOURCE_CUBEPREFILTERED: number;
  66206. /**
  66207. * Texture content is raw 3D data
  66208. */
  66209. static DATASOURCE_RAW3D: number;
  66210. /**
  66211. * Texture content is a depth texture
  66212. */
  66213. static DATASOURCE_DEPTHTEXTURE: number;
  66214. /**
  66215. * Texture data comes from a raw cube data encoded with RGBD
  66216. */
  66217. static DATASOURCE_CUBERAW_RGBD: number;
  66218. /**
  66219. * Defines if the texture is ready
  66220. */
  66221. isReady: boolean;
  66222. /**
  66223. * Defines if the texture is a cube texture
  66224. */
  66225. isCube: boolean;
  66226. /**
  66227. * Defines if the texture contains 3D data
  66228. */
  66229. is3D: boolean;
  66230. /**
  66231. * Defines if the texture contains multiview data
  66232. */
  66233. isMultiview: boolean;
  66234. /**
  66235. * Gets the URL used to load this texture
  66236. */
  66237. url: string;
  66238. /**
  66239. * Gets the sampling mode of the texture
  66240. */
  66241. samplingMode: number;
  66242. /**
  66243. * Gets a boolean indicating if the texture needs mipmaps generation
  66244. */
  66245. generateMipMaps: boolean;
  66246. /**
  66247. * Gets the number of samples used by the texture (WebGL2+ only)
  66248. */
  66249. samples: number;
  66250. /**
  66251. * Gets the type of the texture (int, float...)
  66252. */
  66253. type: number;
  66254. /**
  66255. * Gets the format of the texture (RGB, RGBA...)
  66256. */
  66257. format: number;
  66258. /**
  66259. * Observable called when the texture is loaded
  66260. */
  66261. onLoadedObservable: Observable<InternalTexture>;
  66262. /**
  66263. * Gets the width of the texture
  66264. */
  66265. width: number;
  66266. /**
  66267. * Gets the height of the texture
  66268. */
  66269. height: number;
  66270. /**
  66271. * Gets the depth of the texture
  66272. */
  66273. depth: number;
  66274. /**
  66275. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  66276. */
  66277. baseWidth: number;
  66278. /**
  66279. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  66280. */
  66281. baseHeight: number;
  66282. /**
  66283. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  66284. */
  66285. baseDepth: number;
  66286. /**
  66287. * Gets a boolean indicating if the texture is inverted on Y axis
  66288. */
  66289. invertY: boolean;
  66290. /** @hidden */
  66291. _invertVScale: boolean;
  66292. /** @hidden */
  66293. _associatedChannel: number;
  66294. /** @hidden */
  66295. _dataSource: number;
  66296. /** @hidden */
  66297. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  66298. /** @hidden */
  66299. _bufferView: Nullable<ArrayBufferView>;
  66300. /** @hidden */
  66301. _bufferViewArray: Nullable<ArrayBufferView[]>;
  66302. /** @hidden */
  66303. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  66304. /** @hidden */
  66305. _size: number;
  66306. /** @hidden */
  66307. _extension: string;
  66308. /** @hidden */
  66309. _files: Nullable<string[]>;
  66310. /** @hidden */
  66311. _workingCanvas: Nullable<HTMLCanvasElement>;
  66312. /** @hidden */
  66313. _workingContext: Nullable<CanvasRenderingContext2D>;
  66314. /** @hidden */
  66315. _framebuffer: Nullable<WebGLFramebuffer>;
  66316. /** @hidden */
  66317. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  66318. /** @hidden */
  66319. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  66320. /** @hidden */
  66321. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  66322. /** @hidden */
  66323. _attachments: Nullable<number[]>;
  66324. /** @hidden */
  66325. _cachedCoordinatesMode: Nullable<number>;
  66326. /** @hidden */
  66327. _cachedWrapU: Nullable<number>;
  66328. /** @hidden */
  66329. _cachedWrapV: Nullable<number>;
  66330. /** @hidden */
  66331. _cachedWrapR: Nullable<number>;
  66332. /** @hidden */
  66333. _cachedAnisotropicFilteringLevel: Nullable<number>;
  66334. /** @hidden */
  66335. _isDisabled: boolean;
  66336. /** @hidden */
  66337. _compression: Nullable<string>;
  66338. /** @hidden */
  66339. _generateStencilBuffer: boolean;
  66340. /** @hidden */
  66341. _generateDepthBuffer: boolean;
  66342. /** @hidden */
  66343. _comparisonFunction: number;
  66344. /** @hidden */
  66345. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  66346. /** @hidden */
  66347. _lodGenerationScale: number;
  66348. /** @hidden */
  66349. _lodGenerationOffset: number;
  66350. /** @hidden */
  66351. _colorTextureArray: Nullable<WebGLTexture>;
  66352. /** @hidden */
  66353. _depthStencilTextureArray: Nullable<WebGLTexture>;
  66354. /** @hidden */
  66355. _lodTextureHigh: Nullable<BaseTexture>;
  66356. /** @hidden */
  66357. _lodTextureMid: Nullable<BaseTexture>;
  66358. /** @hidden */
  66359. _lodTextureLow: Nullable<BaseTexture>;
  66360. /** @hidden */
  66361. _isRGBD: boolean;
  66362. /** @hidden */
  66363. _webGLTexture: Nullable<WebGLTexture>;
  66364. /** @hidden */
  66365. _references: number;
  66366. private _engine;
  66367. /**
  66368. * Gets the Engine the texture belongs to.
  66369. * @returns The babylon engine
  66370. */
  66371. getEngine(): Engine;
  66372. /**
  66373. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  66374. */
  66375. readonly dataSource: number;
  66376. /**
  66377. * Creates a new InternalTexture
  66378. * @param engine defines the engine to use
  66379. * @param dataSource defines the type of data that will be used
  66380. * @param delayAllocation if the texture allocation should be delayed (default: false)
  66381. */
  66382. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  66383. /**
  66384. * Increments the number of references (ie. the number of Texture that point to it)
  66385. */
  66386. incrementReferences(): void;
  66387. /**
  66388. * Change the size of the texture (not the size of the content)
  66389. * @param width defines the new width
  66390. * @param height defines the new height
  66391. * @param depth defines the new depth (1 by default)
  66392. */
  66393. updateSize(width: int, height: int, depth?: int): void;
  66394. /** @hidden */
  66395. _rebuild(): void;
  66396. /** @hidden */
  66397. _swapAndDie(target: InternalTexture): void;
  66398. /**
  66399. * Dispose the current allocated resources
  66400. */
  66401. dispose(): void;
  66402. }
  66403. }
  66404. declare module BABYLON {
  66405. /**
  66406. * This represents the main contract an easing function should follow.
  66407. * Easing functions are used throughout the animation system.
  66408. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66409. */
  66410. export interface IEasingFunction {
  66411. /**
  66412. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66413. * of the easing function.
  66414. * The link below provides some of the most common examples of easing functions.
  66415. * @see https://easings.net/
  66416. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66417. * @returns the corresponding value on the curve defined by the easing function
  66418. */
  66419. ease(gradient: number): number;
  66420. }
  66421. /**
  66422. * Base class used for every default easing function.
  66423. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66424. */
  66425. export class EasingFunction implements IEasingFunction {
  66426. /**
  66427. * Interpolation follows the mathematical formula associated with the easing function.
  66428. */
  66429. static readonly EASINGMODE_EASEIN: number;
  66430. /**
  66431. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  66432. */
  66433. static readonly EASINGMODE_EASEOUT: number;
  66434. /**
  66435. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  66436. */
  66437. static readonly EASINGMODE_EASEINOUT: number;
  66438. private _easingMode;
  66439. /**
  66440. * Sets the easing mode of the current function.
  66441. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  66442. */
  66443. setEasingMode(easingMode: number): void;
  66444. /**
  66445. * Gets the current easing mode.
  66446. * @returns the easing mode
  66447. */
  66448. getEasingMode(): number;
  66449. /**
  66450. * @hidden
  66451. */
  66452. easeInCore(gradient: number): number;
  66453. /**
  66454. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66455. * of the easing function.
  66456. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66457. * @returns the corresponding value on the curve defined by the easing function
  66458. */
  66459. ease(gradient: number): number;
  66460. }
  66461. /**
  66462. * Easing function with a circle shape (see link below).
  66463. * @see https://easings.net/#easeInCirc
  66464. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66465. */
  66466. export class CircleEase extends EasingFunction implements IEasingFunction {
  66467. /** @hidden */
  66468. easeInCore(gradient: number): number;
  66469. }
  66470. /**
  66471. * Easing function with a ease back shape (see link below).
  66472. * @see https://easings.net/#easeInBack
  66473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66474. */
  66475. export class BackEase extends EasingFunction implements IEasingFunction {
  66476. /** Defines the amplitude of the function */
  66477. amplitude: number;
  66478. /**
  66479. * Instantiates a back ease easing
  66480. * @see https://easings.net/#easeInBack
  66481. * @param amplitude Defines the amplitude of the function
  66482. */
  66483. constructor(
  66484. /** Defines the amplitude of the function */
  66485. amplitude?: number);
  66486. /** @hidden */
  66487. easeInCore(gradient: number): number;
  66488. }
  66489. /**
  66490. * Easing function with a bouncing shape (see link below).
  66491. * @see https://easings.net/#easeInBounce
  66492. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66493. */
  66494. export class BounceEase extends EasingFunction implements IEasingFunction {
  66495. /** Defines the number of bounces */
  66496. bounces: number;
  66497. /** Defines the amplitude of the bounce */
  66498. bounciness: number;
  66499. /**
  66500. * Instantiates a bounce easing
  66501. * @see https://easings.net/#easeInBounce
  66502. * @param bounces Defines the number of bounces
  66503. * @param bounciness Defines the amplitude of the bounce
  66504. */
  66505. constructor(
  66506. /** Defines the number of bounces */
  66507. bounces?: number,
  66508. /** Defines the amplitude of the bounce */
  66509. bounciness?: number);
  66510. /** @hidden */
  66511. easeInCore(gradient: number): number;
  66512. }
  66513. /**
  66514. * Easing function with a power of 3 shape (see link below).
  66515. * @see https://easings.net/#easeInCubic
  66516. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66517. */
  66518. export class CubicEase extends EasingFunction implements IEasingFunction {
  66519. /** @hidden */
  66520. easeInCore(gradient: number): number;
  66521. }
  66522. /**
  66523. * Easing function with an elastic shape (see link below).
  66524. * @see https://easings.net/#easeInElastic
  66525. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66526. */
  66527. export class ElasticEase extends EasingFunction implements IEasingFunction {
  66528. /** Defines the number of oscillations*/
  66529. oscillations: number;
  66530. /** Defines the amplitude of the oscillations*/
  66531. springiness: number;
  66532. /**
  66533. * Instantiates an elastic easing function
  66534. * @see https://easings.net/#easeInElastic
  66535. * @param oscillations Defines the number of oscillations
  66536. * @param springiness Defines the amplitude of the oscillations
  66537. */
  66538. constructor(
  66539. /** Defines the number of oscillations*/
  66540. oscillations?: number,
  66541. /** Defines the amplitude of the oscillations*/
  66542. springiness?: number);
  66543. /** @hidden */
  66544. easeInCore(gradient: number): number;
  66545. }
  66546. /**
  66547. * Easing function with an exponential shape (see link below).
  66548. * @see https://easings.net/#easeInExpo
  66549. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66550. */
  66551. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  66552. /** Defines the exponent of the function */
  66553. exponent: number;
  66554. /**
  66555. * Instantiates an exponential easing function
  66556. * @see https://easings.net/#easeInExpo
  66557. * @param exponent Defines the exponent of the function
  66558. */
  66559. constructor(
  66560. /** Defines the exponent of the function */
  66561. exponent?: number);
  66562. /** @hidden */
  66563. easeInCore(gradient: number): number;
  66564. }
  66565. /**
  66566. * Easing function with a power shape (see link below).
  66567. * @see https://easings.net/#easeInQuad
  66568. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66569. */
  66570. export class PowerEase extends EasingFunction implements IEasingFunction {
  66571. /** Defines the power of the function */
  66572. power: number;
  66573. /**
  66574. * Instantiates an power base easing function
  66575. * @see https://easings.net/#easeInQuad
  66576. * @param power Defines the power of the function
  66577. */
  66578. constructor(
  66579. /** Defines the power of the function */
  66580. power?: number);
  66581. /** @hidden */
  66582. easeInCore(gradient: number): number;
  66583. }
  66584. /**
  66585. * Easing function with a power of 2 shape (see link below).
  66586. * @see https://easings.net/#easeInQuad
  66587. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66588. */
  66589. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66590. /** @hidden */
  66591. easeInCore(gradient: number): number;
  66592. }
  66593. /**
  66594. * Easing function with a power of 4 shape (see link below).
  66595. * @see https://easings.net/#easeInQuart
  66596. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66597. */
  66598. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66599. /** @hidden */
  66600. easeInCore(gradient: number): number;
  66601. }
  66602. /**
  66603. * Easing function with a power of 5 shape (see link below).
  66604. * @see https://easings.net/#easeInQuint
  66605. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66606. */
  66607. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66608. /** @hidden */
  66609. easeInCore(gradient: number): number;
  66610. }
  66611. /**
  66612. * Easing function with a sin shape (see link below).
  66613. * @see https://easings.net/#easeInSine
  66614. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66615. */
  66616. export class SineEase extends EasingFunction implements IEasingFunction {
  66617. /** @hidden */
  66618. easeInCore(gradient: number): number;
  66619. }
  66620. /**
  66621. * Easing function with a bezier shape (see link below).
  66622. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66623. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66624. */
  66625. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66626. /** Defines the x component of the start tangent in the bezier curve */
  66627. x1: number;
  66628. /** Defines the y component of the start tangent in the bezier curve */
  66629. y1: number;
  66630. /** Defines the x component of the end tangent in the bezier curve */
  66631. x2: number;
  66632. /** Defines the y component of the end tangent in the bezier curve */
  66633. y2: number;
  66634. /**
  66635. * Instantiates a bezier function
  66636. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66637. * @param x1 Defines the x component of the start tangent in the bezier curve
  66638. * @param y1 Defines the y component of the start tangent in the bezier curve
  66639. * @param x2 Defines the x component of the end tangent in the bezier curve
  66640. * @param y2 Defines the y component of the end tangent in the bezier curve
  66641. */
  66642. constructor(
  66643. /** Defines the x component of the start tangent in the bezier curve */
  66644. x1?: number,
  66645. /** Defines the y component of the start tangent in the bezier curve */
  66646. y1?: number,
  66647. /** Defines the x component of the end tangent in the bezier curve */
  66648. x2?: number,
  66649. /** Defines the y component of the end tangent in the bezier curve */
  66650. y2?: number);
  66651. /** @hidden */
  66652. easeInCore(gradient: number): number;
  66653. }
  66654. }
  66655. declare module BABYLON {
  66656. /**
  66657. * Defines an interface which represents an animation key frame
  66658. */
  66659. export interface IAnimationKey {
  66660. /**
  66661. * Frame of the key frame
  66662. */
  66663. frame: number;
  66664. /**
  66665. * Value at the specifies key frame
  66666. */
  66667. value: any;
  66668. /**
  66669. * The input tangent for the cubic hermite spline
  66670. */
  66671. inTangent?: any;
  66672. /**
  66673. * The output tangent for the cubic hermite spline
  66674. */
  66675. outTangent?: any;
  66676. /**
  66677. * The animation interpolation type
  66678. */
  66679. interpolation?: AnimationKeyInterpolation;
  66680. }
  66681. /**
  66682. * Enum for the animation key frame interpolation type
  66683. */
  66684. export enum AnimationKeyInterpolation {
  66685. /**
  66686. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66687. */
  66688. STEP = 1
  66689. }
  66690. }
  66691. declare module BABYLON {
  66692. /**
  66693. * Represents the range of an animation
  66694. */
  66695. export class AnimationRange {
  66696. /**The name of the animation range**/
  66697. name: string;
  66698. /**The starting frame of the animation */
  66699. from: number;
  66700. /**The ending frame of the animation*/
  66701. to: number;
  66702. /**
  66703. * Initializes the range of an animation
  66704. * @param name The name of the animation range
  66705. * @param from The starting frame of the animation
  66706. * @param to The ending frame of the animation
  66707. */
  66708. constructor(
  66709. /**The name of the animation range**/
  66710. name: string,
  66711. /**The starting frame of the animation */
  66712. from: number,
  66713. /**The ending frame of the animation*/
  66714. to: number);
  66715. /**
  66716. * Makes a copy of the animation range
  66717. * @returns A copy of the animation range
  66718. */
  66719. clone(): AnimationRange;
  66720. }
  66721. }
  66722. declare module BABYLON {
  66723. /**
  66724. * Composed of a frame, and an action function
  66725. */
  66726. export class AnimationEvent {
  66727. /** The frame for which the event is triggered **/
  66728. frame: number;
  66729. /** The event to perform when triggered **/
  66730. action: (currentFrame: number) => void;
  66731. /** Specifies if the event should be triggered only once**/
  66732. onlyOnce?: boolean | undefined;
  66733. /**
  66734. * Specifies if the animation event is done
  66735. */
  66736. isDone: boolean;
  66737. /**
  66738. * Initializes the animation event
  66739. * @param frame The frame for which the event is triggered
  66740. * @param action The event to perform when triggered
  66741. * @param onlyOnce Specifies if the event should be triggered only once
  66742. */
  66743. constructor(
  66744. /** The frame for which the event is triggered **/
  66745. frame: number,
  66746. /** The event to perform when triggered **/
  66747. action: (currentFrame: number) => void,
  66748. /** Specifies if the event should be triggered only once**/
  66749. onlyOnce?: boolean | undefined);
  66750. /** @hidden */
  66751. _clone(): AnimationEvent;
  66752. }
  66753. }
  66754. declare module BABYLON {
  66755. /**
  66756. * Interface used to define a behavior
  66757. */
  66758. export interface Behavior<T> {
  66759. /** gets or sets behavior's name */
  66760. name: string;
  66761. /**
  66762. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66763. */
  66764. init(): void;
  66765. /**
  66766. * Called when the behavior is attached to a target
  66767. * @param target defines the target where the behavior is attached to
  66768. */
  66769. attach(target: T): void;
  66770. /**
  66771. * Called when the behavior is detached from its target
  66772. */
  66773. detach(): void;
  66774. }
  66775. /**
  66776. * Interface implemented by classes supporting behaviors
  66777. */
  66778. export interface IBehaviorAware<T> {
  66779. /**
  66780. * Attach a behavior
  66781. * @param behavior defines the behavior to attach
  66782. * @returns the current host
  66783. */
  66784. addBehavior(behavior: Behavior<T>): T;
  66785. /**
  66786. * Remove a behavior from the current object
  66787. * @param behavior defines the behavior to detach
  66788. * @returns the current host
  66789. */
  66790. removeBehavior(behavior: Behavior<T>): T;
  66791. /**
  66792. * Gets a behavior using its name to search
  66793. * @param name defines the name to search
  66794. * @returns the behavior or null if not found
  66795. */
  66796. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66797. }
  66798. }
  66799. declare module BABYLON {
  66800. /**
  66801. * @hidden
  66802. */
  66803. export class IntersectionInfo {
  66804. bu: Nullable<number>;
  66805. bv: Nullable<number>;
  66806. distance: number;
  66807. faceId: number;
  66808. subMeshId: number;
  66809. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66810. }
  66811. }
  66812. declare module BABYLON {
  66813. /**
  66814. * Class used to store bounding sphere information
  66815. */
  66816. export class BoundingSphere {
  66817. /**
  66818. * Gets the center of the bounding sphere in local space
  66819. */
  66820. readonly center: Vector3;
  66821. /**
  66822. * Radius of the bounding sphere in local space
  66823. */
  66824. radius: number;
  66825. /**
  66826. * Gets the center of the bounding sphere in world space
  66827. */
  66828. readonly centerWorld: Vector3;
  66829. /**
  66830. * Radius of the bounding sphere in world space
  66831. */
  66832. radiusWorld: number;
  66833. /**
  66834. * Gets the minimum vector in local space
  66835. */
  66836. readonly minimum: Vector3;
  66837. /**
  66838. * Gets the maximum vector in local space
  66839. */
  66840. readonly maximum: Vector3;
  66841. private _worldMatrix;
  66842. private static readonly TmpVector3;
  66843. /**
  66844. * Creates a new bounding sphere
  66845. * @param min defines the minimum vector (in local space)
  66846. * @param max defines the maximum vector (in local space)
  66847. * @param worldMatrix defines the new world matrix
  66848. */
  66849. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66850. /**
  66851. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66852. * @param min defines the new minimum vector (in local space)
  66853. * @param max defines the new maximum vector (in local space)
  66854. * @param worldMatrix defines the new world matrix
  66855. */
  66856. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66857. /**
  66858. * Scale the current bounding sphere by applying a scale factor
  66859. * @param factor defines the scale factor to apply
  66860. * @returns the current bounding box
  66861. */
  66862. scale(factor: number): BoundingSphere;
  66863. /**
  66864. * Gets the world matrix of the bounding box
  66865. * @returns a matrix
  66866. */
  66867. getWorldMatrix(): DeepImmutable<Matrix>;
  66868. /** @hidden */
  66869. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66870. /**
  66871. * Tests if the bounding sphere is intersecting the frustum planes
  66872. * @param frustumPlanes defines the frustum planes to test
  66873. * @returns true if there is an intersection
  66874. */
  66875. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66876. /**
  66877. * Tests if the bounding sphere center is in between the frustum planes.
  66878. * Used for optimistic fast inclusion.
  66879. * @param frustumPlanes defines the frustum planes to test
  66880. * @returns true if the sphere center is in between the frustum planes
  66881. */
  66882. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66883. /**
  66884. * Tests if a point is inside the bounding sphere
  66885. * @param point defines the point to test
  66886. * @returns true if the point is inside the bounding sphere
  66887. */
  66888. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66889. /**
  66890. * Checks if two sphere intersct
  66891. * @param sphere0 sphere 0
  66892. * @param sphere1 sphere 1
  66893. * @returns true if the speres intersect
  66894. */
  66895. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66896. }
  66897. }
  66898. declare module BABYLON {
  66899. /**
  66900. * Class used to store bounding box information
  66901. */
  66902. export class BoundingBox implements ICullable {
  66903. /**
  66904. * Gets the 8 vectors representing the bounding box in local space
  66905. */
  66906. readonly vectors: Vector3[];
  66907. /**
  66908. * Gets the center of the bounding box in local space
  66909. */
  66910. readonly center: Vector3;
  66911. /**
  66912. * Gets the center of the bounding box in world space
  66913. */
  66914. readonly centerWorld: Vector3;
  66915. /**
  66916. * Gets the extend size in local space
  66917. */
  66918. readonly extendSize: Vector3;
  66919. /**
  66920. * Gets the extend size in world space
  66921. */
  66922. readonly extendSizeWorld: Vector3;
  66923. /**
  66924. * Gets the OBB (object bounding box) directions
  66925. */
  66926. readonly directions: Vector3[];
  66927. /**
  66928. * Gets the 8 vectors representing the bounding box in world space
  66929. */
  66930. readonly vectorsWorld: Vector3[];
  66931. /**
  66932. * Gets the minimum vector in world space
  66933. */
  66934. readonly minimumWorld: Vector3;
  66935. /**
  66936. * Gets the maximum vector in world space
  66937. */
  66938. readonly maximumWorld: Vector3;
  66939. /**
  66940. * Gets the minimum vector in local space
  66941. */
  66942. readonly minimum: Vector3;
  66943. /**
  66944. * Gets the maximum vector in local space
  66945. */
  66946. readonly maximum: Vector3;
  66947. private _worldMatrix;
  66948. private static readonly TmpVector3;
  66949. /**
  66950. * @hidden
  66951. */
  66952. _tag: number;
  66953. /**
  66954. * Creates a new bounding box
  66955. * @param min defines the minimum vector (in local space)
  66956. * @param max defines the maximum vector (in local space)
  66957. * @param worldMatrix defines the new world matrix
  66958. */
  66959. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66960. /**
  66961. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66962. * @param min defines the new minimum vector (in local space)
  66963. * @param max defines the new maximum vector (in local space)
  66964. * @param worldMatrix defines the new world matrix
  66965. */
  66966. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66967. /**
  66968. * Scale the current bounding box by applying a scale factor
  66969. * @param factor defines the scale factor to apply
  66970. * @returns the current bounding box
  66971. */
  66972. scale(factor: number): BoundingBox;
  66973. /**
  66974. * Gets the world matrix of the bounding box
  66975. * @returns a matrix
  66976. */
  66977. getWorldMatrix(): DeepImmutable<Matrix>;
  66978. /** @hidden */
  66979. _update(world: DeepImmutable<Matrix>): void;
  66980. /**
  66981. * Tests if the bounding box is intersecting the frustum planes
  66982. * @param frustumPlanes defines the frustum planes to test
  66983. * @returns true if there is an intersection
  66984. */
  66985. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66986. /**
  66987. * Tests if the bounding box is entirely inside the frustum planes
  66988. * @param frustumPlanes defines the frustum planes to test
  66989. * @returns true if there is an inclusion
  66990. */
  66991. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66992. /**
  66993. * Tests if a point is inside the bounding box
  66994. * @param point defines the point to test
  66995. * @returns true if the point is inside the bounding box
  66996. */
  66997. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66998. /**
  66999. * Tests if the bounding box intersects with a bounding sphere
  67000. * @param sphere defines the sphere to test
  67001. * @returns true if there is an intersection
  67002. */
  67003. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  67004. /**
  67005. * Tests if the bounding box intersects with a box defined by a min and max vectors
  67006. * @param min defines the min vector to use
  67007. * @param max defines the max vector to use
  67008. * @returns true if there is an intersection
  67009. */
  67010. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  67011. /**
  67012. * Tests if two bounding boxes are intersections
  67013. * @param box0 defines the first box to test
  67014. * @param box1 defines the second box to test
  67015. * @returns true if there is an intersection
  67016. */
  67017. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  67018. /**
  67019. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  67020. * @param minPoint defines the minimum vector of the bounding box
  67021. * @param maxPoint defines the maximum vector of the bounding box
  67022. * @param sphereCenter defines the sphere center
  67023. * @param sphereRadius defines the sphere radius
  67024. * @returns true if there is an intersection
  67025. */
  67026. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  67027. /**
  67028. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  67029. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67030. * @param frustumPlanes defines the frustum planes to test
  67031. * @return true if there is an inclusion
  67032. */
  67033. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67034. /**
  67035. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  67036. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67037. * @param frustumPlanes defines the frustum planes to test
  67038. * @return true if there is an intersection
  67039. */
  67040. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67041. }
  67042. }
  67043. declare module BABYLON {
  67044. /** @hidden */
  67045. export class Collider {
  67046. /** Define if a collision was found */
  67047. collisionFound: boolean;
  67048. /**
  67049. * Define last intersection point in local space
  67050. */
  67051. intersectionPoint: Vector3;
  67052. /**
  67053. * Define last collided mesh
  67054. */
  67055. collidedMesh: Nullable<AbstractMesh>;
  67056. private _collisionPoint;
  67057. private _planeIntersectionPoint;
  67058. private _tempVector;
  67059. private _tempVector2;
  67060. private _tempVector3;
  67061. private _tempVector4;
  67062. private _edge;
  67063. private _baseToVertex;
  67064. private _destinationPoint;
  67065. private _slidePlaneNormal;
  67066. private _displacementVector;
  67067. /** @hidden */
  67068. _radius: Vector3;
  67069. /** @hidden */
  67070. _retry: number;
  67071. private _velocity;
  67072. private _basePoint;
  67073. private _epsilon;
  67074. /** @hidden */
  67075. _velocityWorldLength: number;
  67076. /** @hidden */
  67077. _basePointWorld: Vector3;
  67078. private _velocityWorld;
  67079. private _normalizedVelocity;
  67080. /** @hidden */
  67081. _initialVelocity: Vector3;
  67082. /** @hidden */
  67083. _initialPosition: Vector3;
  67084. private _nearestDistance;
  67085. private _collisionMask;
  67086. collisionMask: number;
  67087. /**
  67088. * Gets the plane normal used to compute the sliding response (in local space)
  67089. */
  67090. readonly slidePlaneNormal: Vector3;
  67091. /** @hidden */
  67092. _initialize(source: Vector3, dir: Vector3, e: number): void;
  67093. /** @hidden */
  67094. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  67095. /** @hidden */
  67096. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  67097. /** @hidden */
  67098. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  67099. /** @hidden */
  67100. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  67101. /** @hidden */
  67102. _getResponse(pos: Vector3, vel: Vector3): void;
  67103. }
  67104. }
  67105. declare module BABYLON {
  67106. /**
  67107. * Interface for cullable objects
  67108. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  67109. */
  67110. export interface ICullable {
  67111. /**
  67112. * Checks if the object or part of the object is in the frustum
  67113. * @param frustumPlanes Camera near/planes
  67114. * @returns true if the object is in frustum otherwise false
  67115. */
  67116. isInFrustum(frustumPlanes: Plane[]): boolean;
  67117. /**
  67118. * Checks if a cullable object (mesh...) is in the camera frustum
  67119. * Unlike isInFrustum this cheks the full bounding box
  67120. * @param frustumPlanes Camera near/planes
  67121. * @returns true if the object is in frustum otherwise false
  67122. */
  67123. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  67124. }
  67125. /**
  67126. * Info for a bounding data of a mesh
  67127. */
  67128. export class BoundingInfo implements ICullable {
  67129. /**
  67130. * Bounding box for the mesh
  67131. */
  67132. readonly boundingBox: BoundingBox;
  67133. /**
  67134. * Bounding sphere for the mesh
  67135. */
  67136. readonly boundingSphere: BoundingSphere;
  67137. private _isLocked;
  67138. private static readonly TmpVector3;
  67139. /**
  67140. * Constructs bounding info
  67141. * @param minimum min vector of the bounding box/sphere
  67142. * @param maximum max vector of the bounding box/sphere
  67143. * @param worldMatrix defines the new world matrix
  67144. */
  67145. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  67146. /**
  67147. * Recreates the entire bounding info from scratch as if we call the constructor in place
  67148. * @param min defines the new minimum vector (in local space)
  67149. * @param max defines the new maximum vector (in local space)
  67150. * @param worldMatrix defines the new world matrix
  67151. */
  67152. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  67153. /**
  67154. * min vector of the bounding box/sphere
  67155. */
  67156. readonly minimum: Vector3;
  67157. /**
  67158. * max vector of the bounding box/sphere
  67159. */
  67160. readonly maximum: Vector3;
  67161. /**
  67162. * If the info is locked and won't be updated to avoid perf overhead
  67163. */
  67164. isLocked: boolean;
  67165. /**
  67166. * Updates the bounding sphere and box
  67167. * @param world world matrix to be used to update
  67168. */
  67169. update(world: DeepImmutable<Matrix>): void;
  67170. /**
  67171. * Recreate the bounding info to be centered around a specific point given a specific extend.
  67172. * @param center New center of the bounding info
  67173. * @param extend New extend of the bounding info
  67174. * @returns the current bounding info
  67175. */
  67176. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  67177. /**
  67178. * Scale the current bounding info by applying a scale factor
  67179. * @param factor defines the scale factor to apply
  67180. * @returns the current bounding info
  67181. */
  67182. scale(factor: number): BoundingInfo;
  67183. /**
  67184. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  67185. * @param frustumPlanes defines the frustum to test
  67186. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  67187. * @returns true if the bounding info is in the frustum planes
  67188. */
  67189. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  67190. /**
  67191. * Gets the world distance between the min and max points of the bounding box
  67192. */
  67193. readonly diagonalLength: number;
  67194. /**
  67195. * Checks if a cullable object (mesh...) is in the camera frustum
  67196. * Unlike isInFrustum this cheks the full bounding box
  67197. * @param frustumPlanes Camera near/planes
  67198. * @returns true if the object is in frustum otherwise false
  67199. */
  67200. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67201. /** @hidden */
  67202. _checkCollision(collider: Collider): boolean;
  67203. /**
  67204. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  67205. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67206. * @param point the point to check intersection with
  67207. * @returns if the point intersects
  67208. */
  67209. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  67210. /**
  67211. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  67212. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67213. * @param boundingInfo the bounding info to check intersection with
  67214. * @param precise if the intersection should be done using OBB
  67215. * @returns if the bounding info intersects
  67216. */
  67217. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  67218. }
  67219. }
  67220. declare module BABYLON {
  67221. /**
  67222. * Defines an array and its length.
  67223. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  67224. */
  67225. export interface ISmartArrayLike<T> {
  67226. /**
  67227. * The data of the array.
  67228. */
  67229. data: Array<T>;
  67230. /**
  67231. * The active length of the array.
  67232. */
  67233. length: number;
  67234. }
  67235. /**
  67236. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67237. */
  67238. export class SmartArray<T> implements ISmartArrayLike<T> {
  67239. /**
  67240. * The full set of data from the array.
  67241. */
  67242. data: Array<T>;
  67243. /**
  67244. * The active length of the array.
  67245. */
  67246. length: number;
  67247. protected _id: number;
  67248. /**
  67249. * Instantiates a Smart Array.
  67250. * @param capacity defines the default capacity of the array.
  67251. */
  67252. constructor(capacity: number);
  67253. /**
  67254. * Pushes a value at the end of the active data.
  67255. * @param value defines the object to push in the array.
  67256. */
  67257. push(value: T): void;
  67258. /**
  67259. * Iterates over the active data and apply the lambda to them.
  67260. * @param func defines the action to apply on each value.
  67261. */
  67262. forEach(func: (content: T) => void): void;
  67263. /**
  67264. * Sorts the full sets of data.
  67265. * @param compareFn defines the comparison function to apply.
  67266. */
  67267. sort(compareFn: (a: T, b: T) => number): void;
  67268. /**
  67269. * Resets the active data to an empty array.
  67270. */
  67271. reset(): void;
  67272. /**
  67273. * Releases all the data from the array as well as the array.
  67274. */
  67275. dispose(): void;
  67276. /**
  67277. * Concats the active data with a given array.
  67278. * @param array defines the data to concatenate with.
  67279. */
  67280. concat(array: any): void;
  67281. /**
  67282. * Returns the position of a value in the active data.
  67283. * @param value defines the value to find the index for
  67284. * @returns the index if found in the active data otherwise -1
  67285. */
  67286. indexOf(value: T): number;
  67287. /**
  67288. * Returns whether an element is part of the active data.
  67289. * @param value defines the value to look for
  67290. * @returns true if found in the active data otherwise false
  67291. */
  67292. contains(value: T): boolean;
  67293. private static _GlobalId;
  67294. }
  67295. /**
  67296. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67297. * The data in this array can only be present once
  67298. */
  67299. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  67300. private _duplicateId;
  67301. /**
  67302. * Pushes a value at the end of the active data.
  67303. * THIS DOES NOT PREVENT DUPPLICATE DATA
  67304. * @param value defines the object to push in the array.
  67305. */
  67306. push(value: T): void;
  67307. /**
  67308. * Pushes a value at the end of the active data.
  67309. * If the data is already present, it won t be added again
  67310. * @param value defines the object to push in the array.
  67311. * @returns true if added false if it was already present
  67312. */
  67313. pushNoDuplicate(value: T): boolean;
  67314. /**
  67315. * Resets the active data to an empty array.
  67316. */
  67317. reset(): void;
  67318. /**
  67319. * Concats the active data with a given array.
  67320. * This ensures no dupplicate will be present in the result.
  67321. * @param array defines the data to concatenate with.
  67322. */
  67323. concatWithNoDuplicate(array: any): void;
  67324. }
  67325. }
  67326. declare module BABYLON {
  67327. /**
  67328. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67329. * separate meshes. This can be use to improve performances.
  67330. * @see http://doc.babylonjs.com/how_to/multi_materials
  67331. */
  67332. export class MultiMaterial extends Material {
  67333. private _subMaterials;
  67334. /**
  67335. * Gets or Sets the list of Materials used within the multi material.
  67336. * They need to be ordered according to the submeshes order in the associated mesh
  67337. */
  67338. subMaterials: Nullable<Material>[];
  67339. /**
  67340. * Function used to align with Node.getChildren()
  67341. * @returns the list of Materials used within the multi material
  67342. */
  67343. getChildren(): Nullable<Material>[];
  67344. /**
  67345. * Instantiates a new Multi Material
  67346. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67347. * separate meshes. This can be use to improve performances.
  67348. * @see http://doc.babylonjs.com/how_to/multi_materials
  67349. * @param name Define the name in the scene
  67350. * @param scene Define the scene the material belongs to
  67351. */
  67352. constructor(name: string, scene: Scene);
  67353. private _hookArray;
  67354. /**
  67355. * Get one of the submaterial by its index in the submaterials array
  67356. * @param index The index to look the sub material at
  67357. * @returns The Material if the index has been defined
  67358. */
  67359. getSubMaterial(index: number): Nullable<Material>;
  67360. /**
  67361. * Get the list of active textures for the whole sub materials list.
  67362. * @returns All the textures that will be used during the rendering
  67363. */
  67364. getActiveTextures(): BaseTexture[];
  67365. /**
  67366. * Gets the current class name of the material e.g. "MultiMaterial"
  67367. * Mainly use in serialization.
  67368. * @returns the class name
  67369. */
  67370. getClassName(): string;
  67371. /**
  67372. * Checks if the material is ready to render the requested sub mesh
  67373. * @param mesh Define the mesh the submesh belongs to
  67374. * @param subMesh Define the sub mesh to look readyness for
  67375. * @param useInstances Define whether or not the material is used with instances
  67376. * @returns true if ready, otherwise false
  67377. */
  67378. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  67379. /**
  67380. * Clones the current material and its related sub materials
  67381. * @param name Define the name of the newly cloned material
  67382. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67383. * @returns the cloned material
  67384. */
  67385. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  67386. /**
  67387. * Serializes the materials into a JSON representation.
  67388. * @returns the JSON representation
  67389. */
  67390. serialize(): any;
  67391. /**
  67392. * Dispose the material and release its associated resources
  67393. * @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)
  67394. * @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)
  67395. * @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)
  67396. */
  67397. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  67398. /**
  67399. * Creates a MultiMaterial from parsed MultiMaterial data.
  67400. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67401. * @param scene defines the hosting scene
  67402. * @returns a new MultiMaterial
  67403. */
  67404. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  67405. }
  67406. }
  67407. declare module BABYLON {
  67408. /**
  67409. * Class used to represent data loading progression
  67410. */
  67411. export class SceneLoaderFlags {
  67412. private static _ForceFullSceneLoadingForIncremental;
  67413. private static _ShowLoadingScreen;
  67414. private static _CleanBoneMatrixWeights;
  67415. private static _loggingLevel;
  67416. /**
  67417. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  67418. */
  67419. static ForceFullSceneLoadingForIncremental: boolean;
  67420. /**
  67421. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  67422. */
  67423. static ShowLoadingScreen: boolean;
  67424. /**
  67425. * Defines the current logging level (while loading the scene)
  67426. * @ignorenaming
  67427. */
  67428. static loggingLevel: number;
  67429. /**
  67430. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  67431. */
  67432. static CleanBoneMatrixWeights: boolean;
  67433. }
  67434. }
  67435. declare module BABYLON {
  67436. /**
  67437. * 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.
  67438. * @see https://doc.babylonjs.com/how_to/transformnode
  67439. */
  67440. export class TransformNode extends Node {
  67441. /**
  67442. * Object will not rotate to face the camera
  67443. */
  67444. static BILLBOARDMODE_NONE: number;
  67445. /**
  67446. * Object will rotate to face the camera but only on the x axis
  67447. */
  67448. static BILLBOARDMODE_X: number;
  67449. /**
  67450. * Object will rotate to face the camera but only on the y axis
  67451. */
  67452. static BILLBOARDMODE_Y: number;
  67453. /**
  67454. * Object will rotate to face the camera but only on the z axis
  67455. */
  67456. static BILLBOARDMODE_Z: number;
  67457. /**
  67458. * Object will rotate to face the camera
  67459. */
  67460. static BILLBOARDMODE_ALL: number;
  67461. private _forward;
  67462. private _forwardInverted;
  67463. private _up;
  67464. private _right;
  67465. private _rightInverted;
  67466. private _position;
  67467. private _rotation;
  67468. private _rotationQuaternion;
  67469. protected _scaling: Vector3;
  67470. protected _isDirty: boolean;
  67471. private _transformToBoneReferal;
  67472. private _billboardMode;
  67473. /**
  67474. * Gets or sets the billboard mode. Default is 0.
  67475. *
  67476. * | Value | Type | Description |
  67477. * | --- | --- | --- |
  67478. * | 0 | BILLBOARDMODE_NONE | |
  67479. * | 1 | BILLBOARDMODE_X | |
  67480. * | 2 | BILLBOARDMODE_Y | |
  67481. * | 4 | BILLBOARDMODE_Z | |
  67482. * | 7 | BILLBOARDMODE_ALL | |
  67483. *
  67484. */
  67485. billboardMode: number;
  67486. private _preserveParentRotationForBillboard;
  67487. /**
  67488. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  67489. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  67490. */
  67491. preserveParentRotationForBillboard: boolean;
  67492. /**
  67493. * 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
  67494. */
  67495. scalingDeterminant: number;
  67496. private _infiniteDistance;
  67497. /**
  67498. * Gets or sets the distance of the object to max, often used by skybox
  67499. */
  67500. infiniteDistance: boolean;
  67501. /**
  67502. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  67503. * By default the system will update normals to compensate
  67504. */
  67505. ignoreNonUniformScaling: boolean;
  67506. /**
  67507. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  67508. */
  67509. reIntegrateRotationIntoRotationQuaternion: boolean;
  67510. /** @hidden */
  67511. _poseMatrix: Nullable<Matrix>;
  67512. /** @hidden */
  67513. _localMatrix: Matrix;
  67514. private _usePivotMatrix;
  67515. private _absolutePosition;
  67516. private _pivotMatrix;
  67517. private _pivotMatrixInverse;
  67518. protected _postMultiplyPivotMatrix: boolean;
  67519. protected _isWorldMatrixFrozen: boolean;
  67520. /** @hidden */
  67521. _indexInSceneTransformNodesArray: number;
  67522. /**
  67523. * An event triggered after the world matrix is updated
  67524. */
  67525. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  67526. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  67527. /**
  67528. * Gets a string identifying the name of the class
  67529. * @returns "TransformNode" string
  67530. */
  67531. getClassName(): string;
  67532. /**
  67533. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  67534. */
  67535. position: Vector3;
  67536. /**
  67537. * 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)).
  67538. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  67539. */
  67540. rotation: Vector3;
  67541. /**
  67542. * 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)).
  67543. */
  67544. scaling: Vector3;
  67545. /**
  67546. * 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).
  67547. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  67548. */
  67549. rotationQuaternion: Nullable<Quaternion>;
  67550. /**
  67551. * The forward direction of that transform in world space.
  67552. */
  67553. readonly forward: Vector3;
  67554. /**
  67555. * The up direction of that transform in world space.
  67556. */
  67557. readonly up: Vector3;
  67558. /**
  67559. * The right direction of that transform in world space.
  67560. */
  67561. readonly right: Vector3;
  67562. /**
  67563. * Copies the parameter passed Matrix into the mesh Pose matrix.
  67564. * @param matrix the matrix to copy the pose from
  67565. * @returns this TransformNode.
  67566. */
  67567. updatePoseMatrix(matrix: Matrix): TransformNode;
  67568. /**
  67569. * Returns the mesh Pose matrix.
  67570. * @returns the pose matrix
  67571. */
  67572. getPoseMatrix(): Matrix;
  67573. /** @hidden */
  67574. _isSynchronized(): boolean;
  67575. /** @hidden */
  67576. _initCache(): void;
  67577. /**
  67578. * Flag the transform node as dirty (Forcing it to update everything)
  67579. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67580. * @returns this transform node
  67581. */
  67582. markAsDirty(property: string): TransformNode;
  67583. /**
  67584. * Returns the current mesh absolute position.
  67585. * Returns a Vector3.
  67586. */
  67587. readonly absolutePosition: Vector3;
  67588. /**
  67589. * Sets a new matrix to apply before all other transformation
  67590. * @param matrix defines the transform matrix
  67591. * @returns the current TransformNode
  67592. */
  67593. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67594. /**
  67595. * Sets a new pivot matrix to the current node
  67596. * @param matrix defines the new pivot matrix to use
  67597. * @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
  67598. * @returns the current TransformNode
  67599. */
  67600. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67601. /**
  67602. * Returns the mesh pivot matrix.
  67603. * Default : Identity.
  67604. * @returns the matrix
  67605. */
  67606. getPivotMatrix(): Matrix;
  67607. /**
  67608. * Prevents the World matrix to be computed any longer.
  67609. * @returns the TransformNode.
  67610. */
  67611. freezeWorldMatrix(): TransformNode;
  67612. /**
  67613. * Allows back the World matrix computation.
  67614. * @returns the TransformNode.
  67615. */
  67616. unfreezeWorldMatrix(): this;
  67617. /**
  67618. * True if the World matrix has been frozen.
  67619. */
  67620. readonly isWorldMatrixFrozen: boolean;
  67621. /**
  67622. * Retuns the mesh absolute position in the World.
  67623. * @returns a Vector3.
  67624. */
  67625. getAbsolutePosition(): Vector3;
  67626. /**
  67627. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67628. * @param absolutePosition the absolute position to set
  67629. * @returns the TransformNode.
  67630. */
  67631. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67632. /**
  67633. * Sets the mesh position in its local space.
  67634. * @param vector3 the position to set in localspace
  67635. * @returns the TransformNode.
  67636. */
  67637. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67638. /**
  67639. * Returns the mesh position in the local space from the current World matrix values.
  67640. * @returns a new Vector3.
  67641. */
  67642. getPositionExpressedInLocalSpace(): Vector3;
  67643. /**
  67644. * Translates the mesh along the passed Vector3 in its local space.
  67645. * @param vector3 the distance to translate in localspace
  67646. * @returns the TransformNode.
  67647. */
  67648. locallyTranslate(vector3: Vector3): TransformNode;
  67649. private static _lookAtVectorCache;
  67650. /**
  67651. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67652. * @param targetPoint the position (must be in same space as current mesh) to look at
  67653. * @param yawCor optional yaw (y-axis) correction in radians
  67654. * @param pitchCor optional pitch (x-axis) correction in radians
  67655. * @param rollCor optional roll (z-axis) correction in radians
  67656. * @param space the choosen space of the target
  67657. * @returns the TransformNode.
  67658. */
  67659. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67660. /**
  67661. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67662. * This Vector3 is expressed in the World space.
  67663. * @param localAxis axis to rotate
  67664. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67665. */
  67666. getDirection(localAxis: Vector3): Vector3;
  67667. /**
  67668. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67669. * localAxis is expressed in the mesh local space.
  67670. * result is computed in the Wordl space from the mesh World matrix.
  67671. * @param localAxis axis to rotate
  67672. * @param result the resulting transformnode
  67673. * @returns this TransformNode.
  67674. */
  67675. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67676. /**
  67677. * Sets this transform node rotation to the given local axis.
  67678. * @param localAxis the axis in local space
  67679. * @param yawCor optional yaw (y-axis) correction in radians
  67680. * @param pitchCor optional pitch (x-axis) correction in radians
  67681. * @param rollCor optional roll (z-axis) correction in radians
  67682. * @returns this TransformNode
  67683. */
  67684. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67685. /**
  67686. * Sets a new pivot point to the current node
  67687. * @param point defines the new pivot point to use
  67688. * @param space defines if the point is in world or local space (local by default)
  67689. * @returns the current TransformNode
  67690. */
  67691. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67692. /**
  67693. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67694. * @returns the pivot point
  67695. */
  67696. getPivotPoint(): Vector3;
  67697. /**
  67698. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67699. * @param result the vector3 to store the result
  67700. * @returns this TransformNode.
  67701. */
  67702. getPivotPointToRef(result: Vector3): TransformNode;
  67703. /**
  67704. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67705. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67706. */
  67707. getAbsolutePivotPoint(): Vector3;
  67708. /**
  67709. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67710. * @param result vector3 to store the result
  67711. * @returns this TransformNode.
  67712. */
  67713. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67714. /**
  67715. * Defines the passed node as the parent of the current node.
  67716. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67717. * @see https://doc.babylonjs.com/how_to/parenting
  67718. * @param node the node ot set as the parent
  67719. * @returns this TransformNode.
  67720. */
  67721. setParent(node: Nullable<Node>): TransformNode;
  67722. private _nonUniformScaling;
  67723. /**
  67724. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67725. */
  67726. readonly nonUniformScaling: boolean;
  67727. /** @hidden */
  67728. _updateNonUniformScalingState(value: boolean): boolean;
  67729. /**
  67730. * Attach the current TransformNode to another TransformNode associated with a bone
  67731. * @param bone Bone affecting the TransformNode
  67732. * @param affectedTransformNode TransformNode associated with the bone
  67733. * @returns this object
  67734. */
  67735. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67736. /**
  67737. * Detach the transform node if its associated with a bone
  67738. * @returns this object
  67739. */
  67740. detachFromBone(): TransformNode;
  67741. private static _rotationAxisCache;
  67742. /**
  67743. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67744. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67745. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67746. * The passed axis is also normalized.
  67747. * @param axis the axis to rotate around
  67748. * @param amount the amount to rotate in radians
  67749. * @param space Space to rotate in (Default: local)
  67750. * @returns the TransformNode.
  67751. */
  67752. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67753. /**
  67754. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67755. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67756. * The passed axis is also normalized. .
  67757. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67758. * @param point the point to rotate around
  67759. * @param axis the axis to rotate around
  67760. * @param amount the amount to rotate in radians
  67761. * @returns the TransformNode
  67762. */
  67763. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67764. /**
  67765. * Translates the mesh along the axis vector for the passed distance in the given space.
  67766. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67767. * @param axis the axis to translate in
  67768. * @param distance the distance to translate
  67769. * @param space Space to rotate in (Default: local)
  67770. * @returns the TransformNode.
  67771. */
  67772. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67773. /**
  67774. * Adds a rotation step to the mesh current rotation.
  67775. * x, y, z are Euler angles expressed in radians.
  67776. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67777. * This means this rotation is made in the mesh local space only.
  67778. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67779. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67780. * ```javascript
  67781. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67782. * ```
  67783. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67784. * 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.
  67785. * @param x Rotation to add
  67786. * @param y Rotation to add
  67787. * @param z Rotation to add
  67788. * @returns the TransformNode.
  67789. */
  67790. addRotation(x: number, y: number, z: number): TransformNode;
  67791. /**
  67792. * @hidden
  67793. */
  67794. protected _getEffectiveParent(): Nullable<Node>;
  67795. /**
  67796. * Computes the world matrix of the node
  67797. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67798. * @returns the world matrix
  67799. */
  67800. computeWorldMatrix(force?: boolean): Matrix;
  67801. protected _afterComputeWorldMatrix(): void;
  67802. /**
  67803. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67804. * @param func callback function to add
  67805. *
  67806. * @returns the TransformNode.
  67807. */
  67808. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67809. /**
  67810. * Removes a registered callback function.
  67811. * @param func callback function to remove
  67812. * @returns the TransformNode.
  67813. */
  67814. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67815. /**
  67816. * Gets the position of the current mesh in camera space
  67817. * @param camera defines the camera to use
  67818. * @returns a position
  67819. */
  67820. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67821. /**
  67822. * Returns the distance from the mesh to the active camera
  67823. * @param camera defines the camera to use
  67824. * @returns the distance
  67825. */
  67826. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67827. /**
  67828. * Clone the current transform node
  67829. * @param name Name of the new clone
  67830. * @param newParent New parent for the clone
  67831. * @param doNotCloneChildren Do not clone children hierarchy
  67832. * @returns the new transform node
  67833. */
  67834. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67835. /**
  67836. * Serializes the objects information.
  67837. * @param currentSerializationObject defines the object to serialize in
  67838. * @returns the serialized object
  67839. */
  67840. serialize(currentSerializationObject?: any): any;
  67841. /**
  67842. * Returns a new TransformNode object parsed from the source provided.
  67843. * @param parsedTransformNode is the source.
  67844. * @param scene the scne the object belongs to
  67845. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67846. * @returns a new TransformNode object parsed from the source provided.
  67847. */
  67848. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67849. /**
  67850. * Get all child-transformNodes of this node
  67851. * @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
  67852. * @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
  67853. * @returns an array of TransformNode
  67854. */
  67855. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67856. /**
  67857. * Releases resources associated with this transform node.
  67858. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67859. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67860. */
  67861. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67862. }
  67863. }
  67864. declare module BABYLON {
  67865. /**
  67866. * Class used to override all child animations of a given target
  67867. */
  67868. export class AnimationPropertiesOverride {
  67869. /**
  67870. * Gets or sets a value indicating if animation blending must be used
  67871. */
  67872. enableBlending: boolean;
  67873. /**
  67874. * Gets or sets the blending speed to use when enableBlending is true
  67875. */
  67876. blendingSpeed: number;
  67877. /**
  67878. * Gets or sets the default loop mode to use
  67879. */
  67880. loopMode: number;
  67881. }
  67882. }
  67883. declare module BABYLON {
  67884. /**
  67885. * Class used to store bone information
  67886. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67887. */
  67888. export class Bone extends Node {
  67889. /**
  67890. * defines the bone name
  67891. */
  67892. name: string;
  67893. private static _tmpVecs;
  67894. private static _tmpQuat;
  67895. private static _tmpMats;
  67896. /**
  67897. * Gets the list of child bones
  67898. */
  67899. children: Bone[];
  67900. /** Gets the animations associated with this bone */
  67901. animations: Animation[];
  67902. /**
  67903. * Gets or sets bone length
  67904. */
  67905. length: number;
  67906. /**
  67907. * @hidden Internal only
  67908. * Set this value to map this bone to a different index in the transform matrices
  67909. * Set this value to -1 to exclude the bone from the transform matrices
  67910. */
  67911. _index: Nullable<number>;
  67912. private _skeleton;
  67913. private _localMatrix;
  67914. private _restPose;
  67915. private _baseMatrix;
  67916. private _absoluteTransform;
  67917. private _invertedAbsoluteTransform;
  67918. private _parent;
  67919. private _scalingDeterminant;
  67920. private _worldTransform;
  67921. private _localScaling;
  67922. private _localRotation;
  67923. private _localPosition;
  67924. private _needToDecompose;
  67925. private _needToCompose;
  67926. /** @hidden */
  67927. _linkedTransformNode: Nullable<TransformNode>;
  67928. /** @hidden */
  67929. /** @hidden */
  67930. _matrix: Matrix;
  67931. /**
  67932. * Create a new bone
  67933. * @param name defines the bone name
  67934. * @param skeleton defines the parent skeleton
  67935. * @param parentBone defines the parent (can be null if the bone is the root)
  67936. * @param localMatrix defines the local matrix
  67937. * @param restPose defines the rest pose matrix
  67938. * @param baseMatrix defines the base matrix
  67939. * @param index defines index of the bone in the hiearchy
  67940. */
  67941. constructor(
  67942. /**
  67943. * defines the bone name
  67944. */
  67945. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67946. /**
  67947. * Gets the current object class name.
  67948. * @return the class name
  67949. */
  67950. getClassName(): string;
  67951. /**
  67952. * Gets the parent skeleton
  67953. * @returns a skeleton
  67954. */
  67955. getSkeleton(): Skeleton;
  67956. /**
  67957. * Gets parent bone
  67958. * @returns a bone or null if the bone is the root of the bone hierarchy
  67959. */
  67960. getParent(): Nullable<Bone>;
  67961. /**
  67962. * Returns an array containing the root bones
  67963. * @returns an array containing the root bones
  67964. */
  67965. getChildren(): Array<Bone>;
  67966. /**
  67967. * Sets the parent bone
  67968. * @param parent defines the parent (can be null if the bone is the root)
  67969. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67970. */
  67971. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67972. /**
  67973. * Gets the local matrix
  67974. * @returns a matrix
  67975. */
  67976. getLocalMatrix(): Matrix;
  67977. /**
  67978. * Gets the base matrix (initial matrix which remains unchanged)
  67979. * @returns a matrix
  67980. */
  67981. getBaseMatrix(): Matrix;
  67982. /**
  67983. * Gets the rest pose matrix
  67984. * @returns a matrix
  67985. */
  67986. getRestPose(): Matrix;
  67987. /**
  67988. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67989. */
  67990. getWorldMatrix(): Matrix;
  67991. /**
  67992. * Sets the local matrix to rest pose matrix
  67993. */
  67994. returnToRest(): void;
  67995. /**
  67996. * Gets the inverse of the absolute transform matrix.
  67997. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67998. * @returns a matrix
  67999. */
  68000. getInvertedAbsoluteTransform(): Matrix;
  68001. /**
  68002. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  68003. * @returns a matrix
  68004. */
  68005. getAbsoluteTransform(): Matrix;
  68006. /**
  68007. * Links with the given transform node.
  68008. * The local matrix of this bone is copied from the transform node every frame.
  68009. * @param transformNode defines the transform node to link to
  68010. */
  68011. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  68012. /** Gets or sets current position (in local space) */
  68013. position: Vector3;
  68014. /** Gets or sets current rotation (in local space) */
  68015. rotation: Vector3;
  68016. /** Gets or sets current rotation quaternion (in local space) */
  68017. rotationQuaternion: Quaternion;
  68018. /** Gets or sets current scaling (in local space) */
  68019. scaling: Vector3;
  68020. /**
  68021. * Gets the animation properties override
  68022. */
  68023. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  68024. private _decompose;
  68025. private _compose;
  68026. /**
  68027. * Update the base and local matrices
  68028. * @param matrix defines the new base or local matrix
  68029. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  68030. * @param updateLocalMatrix defines if the local matrix should be updated
  68031. */
  68032. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  68033. /** @hidden */
  68034. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  68035. /**
  68036. * Flag the bone as dirty (Forcing it to update everything)
  68037. */
  68038. markAsDirty(): void;
  68039. private _markAsDirtyAndCompose;
  68040. private _markAsDirtyAndDecompose;
  68041. /**
  68042. * Translate the bone in local or world space
  68043. * @param vec The amount to translate the bone
  68044. * @param space The space that the translation is in
  68045. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68046. */
  68047. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68048. /**
  68049. * Set the postion of the bone in local or world space
  68050. * @param position The position to set the bone
  68051. * @param space The space that the position is in
  68052. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68053. */
  68054. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68055. /**
  68056. * Set the absolute position of the bone (world space)
  68057. * @param position The position to set the bone
  68058. * @param mesh The mesh that this bone is attached to
  68059. */
  68060. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  68061. /**
  68062. * Scale the bone on the x, y and z axes (in local space)
  68063. * @param x The amount to scale the bone on the x axis
  68064. * @param y The amount to scale the bone on the y axis
  68065. * @param z The amount to scale the bone on the z axis
  68066. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  68067. */
  68068. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  68069. /**
  68070. * Set the bone scaling in local space
  68071. * @param scale defines the scaling vector
  68072. */
  68073. setScale(scale: Vector3): void;
  68074. /**
  68075. * Gets the current scaling in local space
  68076. * @returns the current scaling vector
  68077. */
  68078. getScale(): Vector3;
  68079. /**
  68080. * Gets the current scaling in local space and stores it in a target vector
  68081. * @param result defines the target vector
  68082. */
  68083. getScaleToRef(result: Vector3): void;
  68084. /**
  68085. * Set the yaw, pitch, and roll of the bone in local or world space
  68086. * @param yaw The rotation of the bone on the y axis
  68087. * @param pitch The rotation of the bone on the x axis
  68088. * @param roll The rotation of the bone on the z axis
  68089. * @param space The space that the axes of rotation are in
  68090. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68091. */
  68092. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  68093. /**
  68094. * Add a rotation to the bone on an axis in local or world space
  68095. * @param axis The axis to rotate the bone on
  68096. * @param amount The amount to rotate the bone
  68097. * @param space The space that the axis is in
  68098. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68099. */
  68100. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  68101. /**
  68102. * Set the rotation of the bone to a particular axis angle in local or world space
  68103. * @param axis The axis to rotate the bone on
  68104. * @param angle The angle that the bone should be rotated to
  68105. * @param space The space that the axis is in
  68106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68107. */
  68108. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  68109. /**
  68110. * Set the euler rotation of the bone in local of world space
  68111. * @param rotation The euler rotation that the bone should be set to
  68112. * @param space The space that the rotation is in
  68113. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68114. */
  68115. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68116. /**
  68117. * Set the quaternion rotation of the bone in local of world space
  68118. * @param quat The quaternion rotation that the bone should be set to
  68119. * @param space The space that the rotation is in
  68120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68121. */
  68122. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  68123. /**
  68124. * Set the rotation matrix of the bone in local of world space
  68125. * @param rotMat The rotation matrix that the bone should be set to
  68126. * @param space The space that the rotation is in
  68127. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68128. */
  68129. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  68130. private _rotateWithMatrix;
  68131. private _getNegativeRotationToRef;
  68132. /**
  68133. * Get the position of the bone in local or world space
  68134. * @param space The space that the returned position is in
  68135. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68136. * @returns The position of the bone
  68137. */
  68138. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68139. /**
  68140. * Copy the position of the bone to a vector3 in local or world space
  68141. * @param space The space that the returned position is in
  68142. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68143. * @param result The vector3 to copy the position to
  68144. */
  68145. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  68146. /**
  68147. * Get the absolute position of the bone (world space)
  68148. * @param mesh The mesh that this bone is attached to
  68149. * @returns The absolute position of the bone
  68150. */
  68151. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  68152. /**
  68153. * Copy the absolute position of the bone (world space) to the result param
  68154. * @param mesh The mesh that this bone is attached to
  68155. * @param result The vector3 to copy the absolute position to
  68156. */
  68157. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  68158. /**
  68159. * Compute the absolute transforms of this bone and its children
  68160. */
  68161. computeAbsoluteTransforms(): void;
  68162. /**
  68163. * Get the world direction from an axis that is in the local space of the bone
  68164. * @param localAxis The local direction that is used to compute the world direction
  68165. * @param mesh The mesh that this bone is attached to
  68166. * @returns The world direction
  68167. */
  68168. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68169. /**
  68170. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  68171. * @param localAxis The local direction that is used to compute the world direction
  68172. * @param mesh The mesh that this bone is attached to
  68173. * @param result The vector3 that the world direction will be copied to
  68174. */
  68175. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68176. /**
  68177. * Get the euler rotation of the bone in local or world space
  68178. * @param space The space that the rotation should be in
  68179. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68180. * @returns The euler rotation
  68181. */
  68182. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68183. /**
  68184. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  68185. * @param space The space that the rotation should be in
  68186. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68187. * @param result The vector3 that the rotation should be copied to
  68188. */
  68189. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68190. /**
  68191. * Get the quaternion rotation of the bone in either local or world space
  68192. * @param space The space that the rotation should be in
  68193. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68194. * @returns The quaternion rotation
  68195. */
  68196. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  68197. /**
  68198. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  68199. * @param space The space that the rotation should be in
  68200. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68201. * @param result The quaternion that the rotation should be copied to
  68202. */
  68203. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  68204. /**
  68205. * Get the rotation matrix of the bone in local or world space
  68206. * @param space The space that the rotation should be in
  68207. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68208. * @returns The rotation matrix
  68209. */
  68210. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  68211. /**
  68212. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  68213. * @param space The space that the rotation should be in
  68214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68215. * @param result The quaternion that the rotation should be copied to
  68216. */
  68217. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  68218. /**
  68219. * Get the world position of a point that is in the local space of the bone
  68220. * @param position The local position
  68221. * @param mesh The mesh that this bone is attached to
  68222. * @returns The world position
  68223. */
  68224. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68225. /**
  68226. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  68227. * @param position The local position
  68228. * @param mesh The mesh that this bone is attached to
  68229. * @param result The vector3 that the world position should be copied to
  68230. */
  68231. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68232. /**
  68233. * Get the local position of a point that is in world space
  68234. * @param position The world position
  68235. * @param mesh The mesh that this bone is attached to
  68236. * @returns The local position
  68237. */
  68238. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68239. /**
  68240. * Get the local position of a point that is in world space and copy it to the result param
  68241. * @param position The world position
  68242. * @param mesh The mesh that this bone is attached to
  68243. * @param result The vector3 that the local position should be copied to
  68244. */
  68245. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68246. }
  68247. }
  68248. declare module BABYLON {
  68249. /**
  68250. * Enum that determines the text-wrapping mode to use.
  68251. */
  68252. export enum InspectableType {
  68253. /**
  68254. * Checkbox for booleans
  68255. */
  68256. Checkbox = 0,
  68257. /**
  68258. * Sliders for numbers
  68259. */
  68260. Slider = 1,
  68261. /**
  68262. * Vector3
  68263. */
  68264. Vector3 = 2,
  68265. /**
  68266. * Quaternions
  68267. */
  68268. Quaternion = 3,
  68269. /**
  68270. * Color3
  68271. */
  68272. Color3 = 4
  68273. }
  68274. /**
  68275. * Interface used to define custom inspectable properties.
  68276. * This interface is used by the inspector to display custom property grids
  68277. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68278. */
  68279. export interface IInspectable {
  68280. /**
  68281. * Gets the label to display
  68282. */
  68283. label: string;
  68284. /**
  68285. * Gets the name of the property to edit
  68286. */
  68287. propertyName: string;
  68288. /**
  68289. * Gets the type of the editor to use
  68290. */
  68291. type: InspectableType;
  68292. /**
  68293. * Gets the minimum value of the property when using in "slider" mode
  68294. */
  68295. min?: number;
  68296. /**
  68297. * Gets the maximum value of the property when using in "slider" mode
  68298. */
  68299. max?: number;
  68300. /**
  68301. * Gets the setp to use when using in "slider" mode
  68302. */
  68303. step?: number;
  68304. }
  68305. }
  68306. declare module BABYLON {
  68307. /**
  68308. * This represents the required contract to create a new type of texture loader.
  68309. */
  68310. export interface IInternalTextureLoader {
  68311. /**
  68312. * Defines wether the loader supports cascade loading the different faces.
  68313. */
  68314. supportCascades: boolean;
  68315. /**
  68316. * This returns if the loader support the current file information.
  68317. * @param extension defines the file extension of the file being loaded
  68318. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68319. * @param fallback defines the fallback internal texture if any
  68320. * @param isBase64 defines whether the texture is encoded as a base64
  68321. * @param isBuffer defines whether the texture data are stored as a buffer
  68322. * @returns true if the loader can load the specified file
  68323. */
  68324. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68325. /**
  68326. * Transform the url before loading if required.
  68327. * @param rootUrl the url of the texture
  68328. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68329. * @returns the transformed texture
  68330. */
  68331. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68332. /**
  68333. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68334. * @param rootUrl the url of the texture
  68335. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68336. * @returns the fallback texture
  68337. */
  68338. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68339. /**
  68340. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68341. * @param data contains the texture data
  68342. * @param texture defines the BabylonJS internal texture
  68343. * @param createPolynomials will be true if polynomials have been requested
  68344. * @param onLoad defines the callback to trigger once the texture is ready
  68345. * @param onError defines the callback to trigger in case of error
  68346. */
  68347. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68348. /**
  68349. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68350. * @param data contains the texture data
  68351. * @param texture defines the BabylonJS internal texture
  68352. * @param callback defines the method to call once ready to upload
  68353. */
  68354. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68355. }
  68356. }
  68357. declare module BABYLON {
  68358. interface Engine {
  68359. /**
  68360. * Creates a depth stencil cube texture.
  68361. * This is only available in WebGL 2.
  68362. * @param size The size of face edge in the cube texture.
  68363. * @param options The options defining the cube texture.
  68364. * @returns The cube texture
  68365. */
  68366. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  68367. /**
  68368. * Creates a cube texture
  68369. * @param rootUrl defines the url where the files to load is located
  68370. * @param scene defines the current scene
  68371. * @param files defines the list of files to load (1 per face)
  68372. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68373. * @param onLoad defines an optional callback raised when the texture is loaded
  68374. * @param onError defines an optional callback raised if there is an issue to load the texture
  68375. * @param format defines the format of the data
  68376. * @param forcedExtension defines the extension to use to pick the right loader
  68377. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68378. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68379. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68380. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  68381. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  68382. * @returns the cube texture as an InternalTexture
  68383. */
  68384. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  68385. /**
  68386. * Creates a cube texture
  68387. * @param rootUrl defines the url where the files to load is located
  68388. * @param scene defines the current scene
  68389. * @param files defines the list of files to load (1 per face)
  68390. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68391. * @param onLoad defines an optional callback raised when the texture is loaded
  68392. * @param onError defines an optional callback raised if there is an issue to load the texture
  68393. * @param format defines the format of the data
  68394. * @param forcedExtension defines the extension to use to pick the right loader
  68395. * @returns the cube texture as an InternalTexture
  68396. */
  68397. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  68398. /**
  68399. * Creates a cube texture
  68400. * @param rootUrl defines the url where the files to load is located
  68401. * @param scene defines the current scene
  68402. * @param files defines the list of files to load (1 per face)
  68403. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68404. * @param onLoad defines an optional callback raised when the texture is loaded
  68405. * @param onError defines an optional callback raised if there is an issue to load the texture
  68406. * @param format defines the format of the data
  68407. * @param forcedExtension defines the extension to use to pick the right loader
  68408. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68409. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68410. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68411. * @returns the cube texture as an InternalTexture
  68412. */
  68413. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  68414. /** @hidden */
  68415. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68416. /** @hidden */
  68417. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68418. /** @hidden */
  68419. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68420. /** @hidden */
  68421. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68422. }
  68423. }
  68424. declare module BABYLON {
  68425. /**
  68426. * Class for creating a cube texture
  68427. */
  68428. export class CubeTexture extends BaseTexture {
  68429. private _delayedOnLoad;
  68430. /**
  68431. * The url of the texture
  68432. */
  68433. url: string;
  68434. /**
  68435. * Gets or sets the center of the bounding box associated with the cube texture.
  68436. * It must define where the camera used to render the texture was set
  68437. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68438. */
  68439. boundingBoxPosition: Vector3;
  68440. private _boundingBoxSize;
  68441. /**
  68442. * Gets or sets the size of the bounding box associated with the cube texture
  68443. * When defined, the cubemap will switch to local mode
  68444. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  68445. * @example https://www.babylonjs-playground.com/#RNASML
  68446. */
  68447. /**
  68448. * Returns the bounding box size
  68449. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68450. */
  68451. boundingBoxSize: Vector3;
  68452. protected _rotationY: number;
  68453. /**
  68454. * Sets texture matrix rotation angle around Y axis in radians.
  68455. */
  68456. /**
  68457. * Gets texture matrix rotation angle around Y axis radians.
  68458. */
  68459. rotationY: number;
  68460. /**
  68461. * Are mip maps generated for this texture or not.
  68462. */
  68463. readonly noMipmap: boolean;
  68464. private _noMipmap;
  68465. private _files;
  68466. private _extensions;
  68467. private _textureMatrix;
  68468. private _format;
  68469. private _createPolynomials;
  68470. /** @hidden */
  68471. _prefiltered: boolean;
  68472. /**
  68473. * Creates a cube texture from an array of image urls
  68474. * @param files defines an array of image urls
  68475. * @param scene defines the hosting scene
  68476. * @param noMipmap specifies if mip maps are not used
  68477. * @returns a cube texture
  68478. */
  68479. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  68480. /**
  68481. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  68482. * @param url defines the url of the prefiltered texture
  68483. * @param scene defines the scene the texture is attached to
  68484. * @param forcedExtension defines the extension of the file if different from the url
  68485. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68486. * @return the prefiltered texture
  68487. */
  68488. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  68489. /**
  68490. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  68491. * as prefiltered data.
  68492. * @param rootUrl defines the url of the texture or the root name of the six images
  68493. * @param scene defines the scene the texture is attached to
  68494. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  68495. * @param noMipmap defines if mipmaps should be created or not
  68496. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  68497. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  68498. * @param onError defines a callback triggered in case of error during load
  68499. * @param format defines the internal format to use for the texture once loaded
  68500. * @param prefiltered defines whether or not the texture is created from prefiltered data
  68501. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  68502. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68503. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68504. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68505. * @return the cube texture
  68506. */
  68507. 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);
  68508. /**
  68509. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  68510. */
  68511. readonly isPrefiltered: boolean;
  68512. /**
  68513. * Get the current class name of the texture useful for serialization or dynamic coding.
  68514. * @returns "CubeTexture"
  68515. */
  68516. getClassName(): string;
  68517. /**
  68518. * Update the url (and optional buffer) of this texture if url was null during construction.
  68519. * @param url the url of the texture
  68520. * @param forcedExtension defines the extension to use
  68521. * @param onLoad callback called when the texture is loaded (defaults to null)
  68522. */
  68523. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  68524. /**
  68525. * Delays loading of the cube texture
  68526. * @param forcedExtension defines the extension to use
  68527. */
  68528. delayLoad(forcedExtension?: string): void;
  68529. /**
  68530. * Returns the reflection texture matrix
  68531. * @returns the reflection texture matrix
  68532. */
  68533. getReflectionTextureMatrix(): Matrix;
  68534. /**
  68535. * Sets the reflection texture matrix
  68536. * @param value Reflection texture matrix
  68537. */
  68538. setReflectionTextureMatrix(value: Matrix): void;
  68539. /**
  68540. * Parses text to create a cube texture
  68541. * @param parsedTexture define the serialized text to read from
  68542. * @param scene defines the hosting scene
  68543. * @param rootUrl defines the root url of the cube texture
  68544. * @returns a cube texture
  68545. */
  68546. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  68547. /**
  68548. * Makes a clone, or deep copy, of the cube texture
  68549. * @returns a new cube texture
  68550. */
  68551. clone(): CubeTexture;
  68552. }
  68553. }
  68554. declare module BABYLON {
  68555. /** @hidden */
  68556. export var postprocessVertexShader: {
  68557. name: string;
  68558. shader: string;
  68559. };
  68560. }
  68561. declare module BABYLON {
  68562. /**
  68563. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  68564. * This is the base of the follow, arc rotate cameras and Free camera
  68565. * @see http://doc.babylonjs.com/features/cameras
  68566. */
  68567. export class TargetCamera extends Camera {
  68568. private static _RigCamTransformMatrix;
  68569. private static _TargetTransformMatrix;
  68570. private static _TargetFocalPoint;
  68571. /**
  68572. * Define the current direction the camera is moving to
  68573. */
  68574. cameraDirection: Vector3;
  68575. /**
  68576. * Define the current rotation the camera is rotating to
  68577. */
  68578. cameraRotation: Vector2;
  68579. /**
  68580. * When set, the up vector of the camera will be updated by the rotation of the camera
  68581. */
  68582. updateUpVectorFromRotation: boolean;
  68583. private _tmpQuaternion;
  68584. /**
  68585. * Define the current rotation of the camera
  68586. */
  68587. rotation: Vector3;
  68588. /**
  68589. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  68590. */
  68591. rotationQuaternion: Quaternion;
  68592. /**
  68593. * Define the current speed of the camera
  68594. */
  68595. speed: number;
  68596. /**
  68597. * Add cconstraint to the camera to prevent it to move freely in all directions and
  68598. * around all axis.
  68599. */
  68600. noRotationConstraint: boolean;
  68601. /**
  68602. * Define the current target of the camera as an object or a position.
  68603. */
  68604. lockedTarget: any;
  68605. /** @hidden */
  68606. _currentTarget: Vector3;
  68607. /** @hidden */
  68608. _initialFocalDistance: number;
  68609. /** @hidden */
  68610. _viewMatrix: Matrix;
  68611. /** @hidden */
  68612. _camMatrix: Matrix;
  68613. /** @hidden */
  68614. _cameraTransformMatrix: Matrix;
  68615. /** @hidden */
  68616. _cameraRotationMatrix: Matrix;
  68617. /** @hidden */
  68618. _referencePoint: Vector3;
  68619. /** @hidden */
  68620. _transformedReferencePoint: Vector3;
  68621. protected _globalCurrentTarget: Vector3;
  68622. protected _globalCurrentUpVector: Vector3;
  68623. /** @hidden */
  68624. _reset: () => void;
  68625. private _defaultUp;
  68626. /**
  68627. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  68628. * This is the base of the follow, arc rotate cameras and Free camera
  68629. * @see http://doc.babylonjs.com/features/cameras
  68630. * @param name Defines the name of the camera in the scene
  68631. * @param position Defines the start position of the camera in the scene
  68632. * @param scene Defines the scene the camera belongs to
  68633. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68634. */
  68635. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68636. /**
  68637. * Gets the position in front of the camera at a given distance.
  68638. * @param distance The distance from the camera we want the position to be
  68639. * @returns the position
  68640. */
  68641. getFrontPosition(distance: number): Vector3;
  68642. /** @hidden */
  68643. _getLockedTargetPosition(): Nullable<Vector3>;
  68644. private _storedPosition;
  68645. private _storedRotation;
  68646. private _storedRotationQuaternion;
  68647. /**
  68648. * Store current camera state of the camera (fov, position, rotation, etc..)
  68649. * @returns the camera
  68650. */
  68651. storeState(): Camera;
  68652. /**
  68653. * Restored camera state. You must call storeState() first
  68654. * @returns whether it was successful or not
  68655. * @hidden
  68656. */
  68657. _restoreStateValues(): boolean;
  68658. /** @hidden */
  68659. _initCache(): void;
  68660. /** @hidden */
  68661. _updateCache(ignoreParentClass?: boolean): void;
  68662. /** @hidden */
  68663. _isSynchronizedViewMatrix(): boolean;
  68664. /** @hidden */
  68665. _computeLocalCameraSpeed(): number;
  68666. /**
  68667. * Defines the target the camera should look at.
  68668. * This will automatically adapt alpha beta and radius to fit within the new target.
  68669. * @param target Defines the new target as a Vector or a mesh
  68670. */
  68671. setTarget(target: Vector3): void;
  68672. /**
  68673. * Return the current target position of the camera. This value is expressed in local space.
  68674. * @returns the target position
  68675. */
  68676. getTarget(): Vector3;
  68677. /** @hidden */
  68678. _decideIfNeedsToMove(): boolean;
  68679. /** @hidden */
  68680. _updatePosition(): void;
  68681. /** @hidden */
  68682. _checkInputs(): void;
  68683. protected _updateCameraRotationMatrix(): void;
  68684. /**
  68685. * 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)
  68686. * @returns the current camera
  68687. */
  68688. private _rotateUpVectorWithCameraRotationMatrix;
  68689. private _cachedRotationZ;
  68690. private _cachedQuaternionRotationZ;
  68691. /** @hidden */
  68692. _getViewMatrix(): Matrix;
  68693. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68694. /**
  68695. * @hidden
  68696. */
  68697. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68698. /**
  68699. * @hidden
  68700. */
  68701. _updateRigCameras(): void;
  68702. private _getRigCamPositionAndTarget;
  68703. /**
  68704. * Gets the current object class name.
  68705. * @return the class name
  68706. */
  68707. getClassName(): string;
  68708. }
  68709. }
  68710. declare module BABYLON {
  68711. /**
  68712. * @ignore
  68713. * This is a list of all the different input types that are available in the application.
  68714. * Fo instance: ArcRotateCameraGamepadInput...
  68715. */
  68716. export var CameraInputTypes: {};
  68717. /**
  68718. * This is the contract to implement in order to create a new input class.
  68719. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68720. */
  68721. export interface ICameraInput<TCamera extends Camera> {
  68722. /**
  68723. * Defines the camera the input is attached to.
  68724. */
  68725. camera: Nullable<TCamera>;
  68726. /**
  68727. * Gets the class name of the current intput.
  68728. * @returns the class name
  68729. */
  68730. getClassName(): string;
  68731. /**
  68732. * Get the friendly name associated with the input class.
  68733. * @returns the input friendly name
  68734. */
  68735. getSimpleName(): string;
  68736. /**
  68737. * Attach the input controls to a specific dom element to get the input from.
  68738. * @param element Defines the element the controls should be listened from
  68739. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68740. */
  68741. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68742. /**
  68743. * Detach the current controls from the specified dom element.
  68744. * @param element Defines the element to stop listening the inputs from
  68745. */
  68746. detachControl(element: Nullable<HTMLElement>): void;
  68747. /**
  68748. * Update the current camera state depending on the inputs that have been used this frame.
  68749. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68750. */
  68751. checkInputs?: () => void;
  68752. }
  68753. /**
  68754. * Represents a map of input types to input instance or input index to input instance.
  68755. */
  68756. export interface CameraInputsMap<TCamera extends Camera> {
  68757. /**
  68758. * Accessor to the input by input type.
  68759. */
  68760. [name: string]: ICameraInput<TCamera>;
  68761. /**
  68762. * Accessor to the input by input index.
  68763. */
  68764. [idx: number]: ICameraInput<TCamera>;
  68765. }
  68766. /**
  68767. * This represents the input manager used within a camera.
  68768. * It helps dealing with all the different kind of input attached to a camera.
  68769. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68770. */
  68771. export class CameraInputsManager<TCamera extends Camera> {
  68772. /**
  68773. * Defines the list of inputs attahed to the camera.
  68774. */
  68775. attached: CameraInputsMap<TCamera>;
  68776. /**
  68777. * Defines the dom element the camera is collecting inputs from.
  68778. * This is null if the controls have not been attached.
  68779. */
  68780. attachedElement: Nullable<HTMLElement>;
  68781. /**
  68782. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68783. */
  68784. noPreventDefault: boolean;
  68785. /**
  68786. * Defined the camera the input manager belongs to.
  68787. */
  68788. camera: TCamera;
  68789. /**
  68790. * Update the current camera state depending on the inputs that have been used this frame.
  68791. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68792. */
  68793. checkInputs: () => void;
  68794. /**
  68795. * Instantiate a new Camera Input Manager.
  68796. * @param camera Defines the camera the input manager blongs to
  68797. */
  68798. constructor(camera: TCamera);
  68799. /**
  68800. * Add an input method to a camera
  68801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68802. * @param input camera input method
  68803. */
  68804. add(input: ICameraInput<TCamera>): void;
  68805. /**
  68806. * Remove a specific input method from a camera
  68807. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68808. * @param inputToRemove camera input method
  68809. */
  68810. remove(inputToRemove: ICameraInput<TCamera>): void;
  68811. /**
  68812. * Remove a specific input type from a camera
  68813. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68814. * @param inputType the type of the input to remove
  68815. */
  68816. removeByType(inputType: string): void;
  68817. private _addCheckInputs;
  68818. /**
  68819. * Attach the input controls to the currently attached dom element to listen the events from.
  68820. * @param input Defines the input to attach
  68821. */
  68822. attachInput(input: ICameraInput<TCamera>): void;
  68823. /**
  68824. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68825. * @param element Defines the dom element to collect the events from
  68826. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68827. */
  68828. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68829. /**
  68830. * Detach the current manager inputs controls from a specific dom element.
  68831. * @param element Defines the dom element to collect the events from
  68832. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68833. */
  68834. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68835. /**
  68836. * Rebuild the dynamic inputCheck function from the current list of
  68837. * defined inputs in the manager.
  68838. */
  68839. rebuildInputCheck(): void;
  68840. /**
  68841. * Remove all attached input methods from a camera
  68842. */
  68843. clear(): void;
  68844. /**
  68845. * Serialize the current input manager attached to a camera.
  68846. * This ensures than once parsed,
  68847. * the input associated to the camera will be identical to the current ones
  68848. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68849. */
  68850. serialize(serializedCamera: any): void;
  68851. /**
  68852. * Parses an input manager serialized JSON to restore the previous list of inputs
  68853. * and states associated to a camera.
  68854. * @param parsedCamera Defines the JSON to parse
  68855. */
  68856. parse(parsedCamera: any): void;
  68857. }
  68858. }
  68859. declare module BABYLON {
  68860. /**
  68861. * Gather the list of keyboard event types as constants.
  68862. */
  68863. export class KeyboardEventTypes {
  68864. /**
  68865. * The keydown event is fired when a key becomes active (pressed).
  68866. */
  68867. static readonly KEYDOWN: number;
  68868. /**
  68869. * The keyup event is fired when a key has been released.
  68870. */
  68871. static readonly KEYUP: number;
  68872. }
  68873. /**
  68874. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68875. */
  68876. export class KeyboardInfo {
  68877. /**
  68878. * Defines the type of event (KeyboardEventTypes)
  68879. */
  68880. type: number;
  68881. /**
  68882. * Defines the related dom event
  68883. */
  68884. event: KeyboardEvent;
  68885. /**
  68886. * Instantiates a new keyboard info.
  68887. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68888. * @param type Defines the type of event (KeyboardEventTypes)
  68889. * @param event Defines the related dom event
  68890. */
  68891. constructor(
  68892. /**
  68893. * Defines the type of event (KeyboardEventTypes)
  68894. */
  68895. type: number,
  68896. /**
  68897. * Defines the related dom event
  68898. */
  68899. event: KeyboardEvent);
  68900. }
  68901. /**
  68902. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68903. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68904. */
  68905. export class KeyboardInfoPre extends KeyboardInfo {
  68906. /**
  68907. * Defines the type of event (KeyboardEventTypes)
  68908. */
  68909. type: number;
  68910. /**
  68911. * Defines the related dom event
  68912. */
  68913. event: KeyboardEvent;
  68914. /**
  68915. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68916. */
  68917. skipOnPointerObservable: boolean;
  68918. /**
  68919. * Instantiates a new keyboard pre info.
  68920. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68921. * @param type Defines the type of event (KeyboardEventTypes)
  68922. * @param event Defines the related dom event
  68923. */
  68924. constructor(
  68925. /**
  68926. * Defines the type of event (KeyboardEventTypes)
  68927. */
  68928. type: number,
  68929. /**
  68930. * Defines the related dom event
  68931. */
  68932. event: KeyboardEvent);
  68933. }
  68934. }
  68935. declare module BABYLON {
  68936. /**
  68937. * Manage the keyboard inputs to control the movement of a free camera.
  68938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68939. */
  68940. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68941. /**
  68942. * Defines the camera the input is attached to.
  68943. */
  68944. camera: FreeCamera;
  68945. /**
  68946. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68947. */
  68948. keysUp: number[];
  68949. /**
  68950. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68951. */
  68952. keysDown: number[];
  68953. /**
  68954. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68955. */
  68956. keysLeft: number[];
  68957. /**
  68958. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68959. */
  68960. keysRight: number[];
  68961. private _keys;
  68962. private _onCanvasBlurObserver;
  68963. private _onKeyboardObserver;
  68964. private _engine;
  68965. private _scene;
  68966. /**
  68967. * Attach the input controls to a specific dom element to get the input from.
  68968. * @param element Defines the element the controls should be listened from
  68969. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68970. */
  68971. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68972. /**
  68973. * Detach the current controls from the specified dom element.
  68974. * @param element Defines the element to stop listening the inputs from
  68975. */
  68976. detachControl(element: Nullable<HTMLElement>): void;
  68977. /**
  68978. * Update the current camera state depending on the inputs that have been used this frame.
  68979. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68980. */
  68981. checkInputs(): void;
  68982. /**
  68983. * Gets the class name of the current intput.
  68984. * @returns the class name
  68985. */
  68986. getClassName(): string;
  68987. /** @hidden */
  68988. _onLostFocus(): void;
  68989. /**
  68990. * Get the friendly name associated with the input class.
  68991. * @returns the input friendly name
  68992. */
  68993. getSimpleName(): string;
  68994. }
  68995. }
  68996. declare module BABYLON {
  68997. /**
  68998. * Interface describing all the common properties and methods a shadow light needs to implement.
  68999. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  69000. * as well as binding the different shadow properties to the effects.
  69001. */
  69002. export interface IShadowLight extends Light {
  69003. /**
  69004. * The light id in the scene (used in scene.findLighById for instance)
  69005. */
  69006. id: string;
  69007. /**
  69008. * The position the shdow will be casted from.
  69009. */
  69010. position: Vector3;
  69011. /**
  69012. * In 2d mode (needCube being false), the direction used to cast the shadow.
  69013. */
  69014. direction: Vector3;
  69015. /**
  69016. * The transformed position. Position of the light in world space taking parenting in account.
  69017. */
  69018. transformedPosition: Vector3;
  69019. /**
  69020. * The transformed direction. Direction of the light in world space taking parenting in account.
  69021. */
  69022. transformedDirection: Vector3;
  69023. /**
  69024. * The friendly name of the light in the scene.
  69025. */
  69026. name: string;
  69027. /**
  69028. * Defines the shadow projection clipping minimum z value.
  69029. */
  69030. shadowMinZ: number;
  69031. /**
  69032. * Defines the shadow projection clipping maximum z value.
  69033. */
  69034. shadowMaxZ: number;
  69035. /**
  69036. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69037. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69038. */
  69039. computeTransformedInformation(): boolean;
  69040. /**
  69041. * Gets the scene the light belongs to.
  69042. * @returns The scene
  69043. */
  69044. getScene(): Scene;
  69045. /**
  69046. * Callback defining a custom Projection Matrix Builder.
  69047. * This can be used to override the default projection matrix computation.
  69048. */
  69049. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69050. /**
  69051. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69052. * @param matrix The materix to updated with the projection information
  69053. * @param viewMatrix The transform matrix of the light
  69054. * @param renderList The list of mesh to render in the map
  69055. * @returns The current light
  69056. */
  69057. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69058. /**
  69059. * Gets the current depth scale used in ESM.
  69060. * @returns The scale
  69061. */
  69062. getDepthScale(): number;
  69063. /**
  69064. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69065. * @returns true if a cube texture needs to be use
  69066. */
  69067. needCube(): boolean;
  69068. /**
  69069. * Detects if the projection matrix requires to be recomputed this frame.
  69070. * @returns true if it requires to be recomputed otherwise, false.
  69071. */
  69072. needProjectionMatrixCompute(): boolean;
  69073. /**
  69074. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69075. */
  69076. forceProjectionMatrixCompute(): void;
  69077. /**
  69078. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69079. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69080. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69081. */
  69082. getShadowDirection(faceIndex?: number): Vector3;
  69083. /**
  69084. * Gets the minZ used for shadow according to both the scene and the light.
  69085. * @param activeCamera The camera we are returning the min for
  69086. * @returns the depth min z
  69087. */
  69088. getDepthMinZ(activeCamera: Camera): number;
  69089. /**
  69090. * Gets the maxZ used for shadow according to both the scene and the light.
  69091. * @param activeCamera The camera we are returning the max for
  69092. * @returns the depth max z
  69093. */
  69094. getDepthMaxZ(activeCamera: Camera): number;
  69095. }
  69096. /**
  69097. * Base implementation IShadowLight
  69098. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  69099. */
  69100. export abstract class ShadowLight extends Light implements IShadowLight {
  69101. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  69102. protected _position: Vector3;
  69103. protected _setPosition(value: Vector3): void;
  69104. /**
  69105. * Sets the position the shadow will be casted from. Also use as the light position for both
  69106. * point and spot lights.
  69107. */
  69108. /**
  69109. * Sets the position the shadow will be casted from. Also use as the light position for both
  69110. * point and spot lights.
  69111. */
  69112. position: Vector3;
  69113. protected _direction: Vector3;
  69114. protected _setDirection(value: Vector3): void;
  69115. /**
  69116. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  69117. * Also use as the light direction on spot and directional lights.
  69118. */
  69119. /**
  69120. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  69121. * Also use as the light direction on spot and directional lights.
  69122. */
  69123. direction: Vector3;
  69124. private _shadowMinZ;
  69125. /**
  69126. * Gets the shadow projection clipping minimum z value.
  69127. */
  69128. /**
  69129. * Sets the shadow projection clipping minimum z value.
  69130. */
  69131. shadowMinZ: number;
  69132. private _shadowMaxZ;
  69133. /**
  69134. * Sets the shadow projection clipping maximum z value.
  69135. */
  69136. /**
  69137. * Gets the shadow projection clipping maximum z value.
  69138. */
  69139. shadowMaxZ: number;
  69140. /**
  69141. * Callback defining a custom Projection Matrix Builder.
  69142. * This can be used to override the default projection matrix computation.
  69143. */
  69144. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69145. /**
  69146. * The transformed position. Position of the light in world space taking parenting in account.
  69147. */
  69148. transformedPosition: Vector3;
  69149. /**
  69150. * The transformed direction. Direction of the light in world space taking parenting in account.
  69151. */
  69152. transformedDirection: Vector3;
  69153. private _needProjectionMatrixCompute;
  69154. /**
  69155. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69156. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69157. */
  69158. computeTransformedInformation(): boolean;
  69159. /**
  69160. * Return the depth scale used for the shadow map.
  69161. * @returns the depth scale.
  69162. */
  69163. getDepthScale(): number;
  69164. /**
  69165. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69166. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69167. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69168. */
  69169. getShadowDirection(faceIndex?: number): Vector3;
  69170. /**
  69171. * Returns the ShadowLight absolute position in the World.
  69172. * @returns the position vector in world space
  69173. */
  69174. getAbsolutePosition(): Vector3;
  69175. /**
  69176. * Sets the ShadowLight direction toward the passed target.
  69177. * @param target The point to target in local space
  69178. * @returns the updated ShadowLight direction
  69179. */
  69180. setDirectionToTarget(target: Vector3): Vector3;
  69181. /**
  69182. * Returns the light rotation in euler definition.
  69183. * @returns the x y z rotation in local space.
  69184. */
  69185. getRotation(): Vector3;
  69186. /**
  69187. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69188. * @returns true if a cube texture needs to be use
  69189. */
  69190. needCube(): boolean;
  69191. /**
  69192. * Detects if the projection matrix requires to be recomputed this frame.
  69193. * @returns true if it requires to be recomputed otherwise, false.
  69194. */
  69195. needProjectionMatrixCompute(): boolean;
  69196. /**
  69197. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69198. */
  69199. forceProjectionMatrixCompute(): void;
  69200. /** @hidden */
  69201. _initCache(): void;
  69202. /** @hidden */
  69203. _isSynchronized(): boolean;
  69204. /**
  69205. * Computes the world matrix of the node
  69206. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69207. * @returns the world matrix
  69208. */
  69209. computeWorldMatrix(force?: boolean): Matrix;
  69210. /**
  69211. * Gets the minZ used for shadow according to both the scene and the light.
  69212. * @param activeCamera The camera we are returning the min for
  69213. * @returns the depth min z
  69214. */
  69215. getDepthMinZ(activeCamera: Camera): number;
  69216. /**
  69217. * Gets the maxZ used for shadow according to both the scene and the light.
  69218. * @param activeCamera The camera we are returning the max for
  69219. * @returns the depth max z
  69220. */
  69221. getDepthMaxZ(activeCamera: Camera): number;
  69222. /**
  69223. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69224. * @param matrix The materix to updated with the projection information
  69225. * @param viewMatrix The transform matrix of the light
  69226. * @param renderList The list of mesh to render in the map
  69227. * @returns The current light
  69228. */
  69229. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69230. }
  69231. }
  69232. declare module BABYLON {
  69233. /**
  69234. * "Static Class" containing the most commonly used helper while dealing with material for
  69235. * rendering purpose.
  69236. *
  69237. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  69238. *
  69239. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  69240. */
  69241. export class MaterialHelper {
  69242. /**
  69243. * Bind the current view position to an effect.
  69244. * @param effect The effect to be bound
  69245. * @param scene The scene the eyes position is used from
  69246. */
  69247. static BindEyePosition(effect: Effect, scene: Scene): void;
  69248. /**
  69249. * Helps preparing the defines values about the UVs in used in the effect.
  69250. * UVs are shared as much as we can accross channels in the shaders.
  69251. * @param texture The texture we are preparing the UVs for
  69252. * @param defines The defines to update
  69253. * @param key The channel key "diffuse", "specular"... used in the shader
  69254. */
  69255. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  69256. /**
  69257. * Binds a texture matrix value to its corrsponding uniform
  69258. * @param texture The texture to bind the matrix for
  69259. * @param uniformBuffer The uniform buffer receivin the data
  69260. * @param key The channel key "diffuse", "specular"... used in the shader
  69261. */
  69262. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  69263. /**
  69264. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  69265. * @param mesh defines the current mesh
  69266. * @param scene defines the current scene
  69267. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  69268. * @param pointsCloud defines if point cloud rendering has to be turned on
  69269. * @param fogEnabled defines if fog has to be turned on
  69270. * @param alphaTest defines if alpha testing has to be turned on
  69271. * @param defines defines the current list of defines
  69272. */
  69273. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  69274. /**
  69275. * Helper used to prepare the list of defines associated with frame values for shader compilation
  69276. * @param scene defines the current scene
  69277. * @param engine defines the current engine
  69278. * @param defines specifies the list of active defines
  69279. * @param useInstances defines if instances have to be turned on
  69280. * @param useClipPlane defines if clip plane have to be turned on
  69281. */
  69282. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  69283. /**
  69284. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  69285. * @param mesh The mesh containing the geometry data we will draw
  69286. * @param defines The defines to update
  69287. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  69288. * @param useBones Precise whether bones should be used or not (override mesh info)
  69289. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  69290. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  69291. * @returns false if defines are considered not dirty and have not been checked
  69292. */
  69293. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  69294. /**
  69295. * Prepares the defines related to multiview
  69296. * @param scene The scene we are intending to draw
  69297. * @param defines The defines to update
  69298. */
  69299. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  69300. /**
  69301. * Prepares the defines related to the light information passed in parameter
  69302. * @param scene The scene we are intending to draw
  69303. * @param mesh The mesh the effect is compiling for
  69304. * @param defines The defines to update
  69305. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  69306. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  69307. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  69308. * @returns true if normals will be required for the rest of the effect
  69309. */
  69310. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  69311. /**
  69312. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  69313. * that won t be acctive due to defines being turned off.
  69314. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  69315. * @param samplersList The samplers list
  69316. * @param defines The defines helping in the list generation
  69317. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  69318. */
  69319. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  69320. /**
  69321. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  69322. * @param defines The defines to update while falling back
  69323. * @param fallbacks The authorized effect fallbacks
  69324. * @param maxSimultaneousLights The maximum number of lights allowed
  69325. * @param rank the current rank of the Effect
  69326. * @returns The newly affected rank
  69327. */
  69328. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  69329. /**
  69330. * Prepares the list of attributes required for morph targets according to the effect defines.
  69331. * @param attribs The current list of supported attribs
  69332. * @param mesh The mesh to prepare the morph targets attributes for
  69333. * @param defines The current Defines of the effect
  69334. */
  69335. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  69336. /**
  69337. * Prepares the list of attributes required for bones according to the effect defines.
  69338. * @param attribs The current list of supported attribs
  69339. * @param mesh The mesh to prepare the bones attributes for
  69340. * @param defines The current Defines of the effect
  69341. * @param fallbacks The current efffect fallback strategy
  69342. */
  69343. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  69344. /**
  69345. * Prepares the list of attributes required for instances according to the effect defines.
  69346. * @param attribs The current list of supported attribs
  69347. * @param defines The current Defines of the effect
  69348. */
  69349. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  69350. /**
  69351. * Binds the light shadow information to the effect for the given mesh.
  69352. * @param light The light containing the generator
  69353. * @param scene The scene the lights belongs to
  69354. * @param mesh The mesh we are binding the information to render
  69355. * @param lightIndex The light index in the effect used to render the mesh
  69356. * @param effect The effect we are binding the data to
  69357. */
  69358. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  69359. /**
  69360. * Binds the light information to the effect.
  69361. * @param light The light containing the generator
  69362. * @param effect The effect we are binding the data to
  69363. * @param lightIndex The light index in the effect used to render
  69364. */
  69365. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  69366. /**
  69367. * Binds the lights information from the scene to the effect for the given mesh.
  69368. * @param scene The scene the lights belongs to
  69369. * @param mesh The mesh we are binding the information to render
  69370. * @param effect The effect we are binding the data to
  69371. * @param defines The generated defines for the effect
  69372. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  69373. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  69374. */
  69375. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  69376. private static _tempFogColor;
  69377. /**
  69378. * Binds the fog information from the scene to the effect for the given mesh.
  69379. * @param scene The scene the lights belongs to
  69380. * @param mesh The mesh we are binding the information to render
  69381. * @param effect The effect we are binding the data to
  69382. * @param linearSpace Defines if the fog effect is applied in linear space
  69383. */
  69384. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  69385. /**
  69386. * Binds the bones information from the mesh to the effect.
  69387. * @param mesh The mesh we are binding the information to render
  69388. * @param effect The effect we are binding the data to
  69389. */
  69390. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  69391. /**
  69392. * Binds the morph targets information from the mesh to the effect.
  69393. * @param abstractMesh The mesh we are binding the information to render
  69394. * @param effect The effect we are binding the data to
  69395. */
  69396. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  69397. /**
  69398. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  69399. * @param defines The generated defines used in the effect
  69400. * @param effect The effect we are binding the data to
  69401. * @param scene The scene we are willing to render with logarithmic scale for
  69402. */
  69403. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  69404. /**
  69405. * Binds the clip plane information from the scene to the effect.
  69406. * @param scene The scene the clip plane information are extracted from
  69407. * @param effect The effect we are binding the data to
  69408. */
  69409. static BindClipPlane(effect: Effect, scene: Scene): void;
  69410. }
  69411. }
  69412. declare module BABYLON {
  69413. /** @hidden */
  69414. export var kernelBlurVaryingDeclaration: {
  69415. name: string;
  69416. shader: string;
  69417. };
  69418. }
  69419. declare module BABYLON {
  69420. /** @hidden */
  69421. export var kernelBlurFragment: {
  69422. name: string;
  69423. shader: string;
  69424. };
  69425. }
  69426. declare module BABYLON {
  69427. /** @hidden */
  69428. export var kernelBlurFragment2: {
  69429. name: string;
  69430. shader: string;
  69431. };
  69432. }
  69433. declare module BABYLON {
  69434. /** @hidden */
  69435. export var kernelBlurPixelShader: {
  69436. name: string;
  69437. shader: string;
  69438. };
  69439. }
  69440. declare module BABYLON {
  69441. /** @hidden */
  69442. export var kernelBlurVertex: {
  69443. name: string;
  69444. shader: string;
  69445. };
  69446. }
  69447. declare module BABYLON {
  69448. /** @hidden */
  69449. export var kernelBlurVertexShader: {
  69450. name: string;
  69451. shader: string;
  69452. };
  69453. }
  69454. declare module BABYLON {
  69455. /**
  69456. * The Blur Post Process which blurs an image based on a kernel and direction.
  69457. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  69458. */
  69459. export class BlurPostProcess extends PostProcess {
  69460. /** The direction in which to blur the image. */
  69461. direction: Vector2;
  69462. private blockCompilation;
  69463. protected _kernel: number;
  69464. protected _idealKernel: number;
  69465. protected _packedFloat: boolean;
  69466. private _staticDefines;
  69467. /**
  69468. * Sets the length in pixels of the blur sample region
  69469. */
  69470. /**
  69471. * Gets the length in pixels of the blur sample region
  69472. */
  69473. kernel: number;
  69474. /**
  69475. * Sets wether or not the blur needs to unpack/repack floats
  69476. */
  69477. /**
  69478. * Gets wether or not the blur is unpacking/repacking floats
  69479. */
  69480. packedFloat: boolean;
  69481. /**
  69482. * Creates a new instance BlurPostProcess
  69483. * @param name The name of the effect.
  69484. * @param direction The direction in which to blur the image.
  69485. * @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.
  69486. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69487. * @param camera The camera to apply the render pass to.
  69488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69489. * @param engine The engine which the post process will be applied. (default: current engine)
  69490. * @param reusable If the post process can be reused on the same frame. (default: false)
  69491. * @param textureType Type of textures used when performing the post process. (default: 0)
  69492. * @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)
  69493. */
  69494. constructor(name: string,
  69495. /** The direction in which to blur the image. */
  69496. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  69497. /**
  69498. * Updates the effect with the current post process compile time values and recompiles the shader.
  69499. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69500. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69501. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69502. * @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
  69503. * @param onCompiled Called when the shader has been compiled.
  69504. * @param onError Called if there is an error when compiling a shader.
  69505. */
  69506. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69507. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69508. /**
  69509. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  69510. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  69511. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  69512. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  69513. * The gaps between physical kernels are compensated for in the weighting of the samples
  69514. * @param idealKernel Ideal blur kernel.
  69515. * @return Nearest best kernel.
  69516. */
  69517. protected _nearestBestKernel(idealKernel: number): number;
  69518. /**
  69519. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  69520. * @param x The point on the Gaussian distribution to sample.
  69521. * @return the value of the Gaussian function at x.
  69522. */
  69523. protected _gaussianWeight(x: number): number;
  69524. /**
  69525. * Generates a string that can be used as a floating point number in GLSL.
  69526. * @param x Value to print.
  69527. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  69528. * @return GLSL float string.
  69529. */
  69530. protected _glslFloat(x: number, decimalFigures?: number): string;
  69531. }
  69532. }
  69533. declare module BABYLON {
  69534. /** @hidden */
  69535. export var shadowMapPixelShader: {
  69536. name: string;
  69537. shader: string;
  69538. };
  69539. }
  69540. declare module BABYLON {
  69541. /** @hidden */
  69542. export var bonesDeclaration: {
  69543. name: string;
  69544. shader: string;
  69545. };
  69546. }
  69547. declare module BABYLON {
  69548. /** @hidden */
  69549. export var morphTargetsVertexGlobalDeclaration: {
  69550. name: string;
  69551. shader: string;
  69552. };
  69553. }
  69554. declare module BABYLON {
  69555. /** @hidden */
  69556. export var morphTargetsVertexDeclaration: {
  69557. name: string;
  69558. shader: string;
  69559. };
  69560. }
  69561. declare module BABYLON {
  69562. /** @hidden */
  69563. export var instancesDeclaration: {
  69564. name: string;
  69565. shader: string;
  69566. };
  69567. }
  69568. declare module BABYLON {
  69569. /** @hidden */
  69570. export var helperFunctions: {
  69571. name: string;
  69572. shader: string;
  69573. };
  69574. }
  69575. declare module BABYLON {
  69576. /** @hidden */
  69577. export var morphTargetsVertex: {
  69578. name: string;
  69579. shader: string;
  69580. };
  69581. }
  69582. declare module BABYLON {
  69583. /** @hidden */
  69584. export var instancesVertex: {
  69585. name: string;
  69586. shader: string;
  69587. };
  69588. }
  69589. declare module BABYLON {
  69590. /** @hidden */
  69591. export var bonesVertex: {
  69592. name: string;
  69593. shader: string;
  69594. };
  69595. }
  69596. declare module BABYLON {
  69597. /** @hidden */
  69598. export var shadowMapVertexShader: {
  69599. name: string;
  69600. shader: string;
  69601. };
  69602. }
  69603. declare module BABYLON {
  69604. /** @hidden */
  69605. export var depthBoxBlurPixelShader: {
  69606. name: string;
  69607. shader: string;
  69608. };
  69609. }
  69610. declare module BABYLON {
  69611. /**
  69612. * Defines the options associated with the creation of a custom shader for a shadow generator.
  69613. */
  69614. export interface ICustomShaderOptions {
  69615. /**
  69616. * Gets or sets the custom shader name to use
  69617. */
  69618. shaderName: string;
  69619. /**
  69620. * The list of attribute names used in the shader
  69621. */
  69622. attributes?: string[];
  69623. /**
  69624. * The list of unifrom names used in the shader
  69625. */
  69626. uniforms?: string[];
  69627. /**
  69628. * The list of sampler names used in the shader
  69629. */
  69630. samplers?: string[];
  69631. /**
  69632. * The list of defines used in the shader
  69633. */
  69634. defines?: string[];
  69635. }
  69636. /**
  69637. * Interface to implement to create a shadow generator compatible with BJS.
  69638. */
  69639. export interface IShadowGenerator {
  69640. /**
  69641. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69642. * @returns The render target texture if present otherwise, null
  69643. */
  69644. getShadowMap(): Nullable<RenderTargetTexture>;
  69645. /**
  69646. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69647. * @returns The render target texture if the shadow map is present otherwise, null
  69648. */
  69649. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69650. /**
  69651. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69652. * @param subMesh The submesh we want to render in the shadow map
  69653. * @param useInstances Defines wether will draw in the map using instances
  69654. * @returns true if ready otherwise, false
  69655. */
  69656. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69657. /**
  69658. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69659. * @param defines Defines of the material we want to update
  69660. * @param lightIndex Index of the light in the enabled light list of the material
  69661. */
  69662. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  69663. /**
  69664. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69665. * defined in the generator but impacting the effect).
  69666. * It implies the unifroms available on the materials are the standard BJS ones.
  69667. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69668. * @param effect The effect we are binfing the information for
  69669. */
  69670. bindShadowLight(lightIndex: string, effect: Effect): void;
  69671. /**
  69672. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69673. * (eq to shadow prjection matrix * light transform matrix)
  69674. * @returns The transform matrix used to create the shadow map
  69675. */
  69676. getTransformMatrix(): Matrix;
  69677. /**
  69678. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69679. * Cube and 2D textures for instance.
  69680. */
  69681. recreateShadowMap(): void;
  69682. /**
  69683. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69684. * @param onCompiled Callback triggered at the and of the effects compilation
  69685. * @param options Sets of optional options forcing the compilation with different modes
  69686. */
  69687. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69688. useInstances: boolean;
  69689. }>): void;
  69690. /**
  69691. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69692. * @param options Sets of optional options forcing the compilation with different modes
  69693. * @returns A promise that resolves when the compilation completes
  69694. */
  69695. forceCompilationAsync(options?: Partial<{
  69696. useInstances: boolean;
  69697. }>): Promise<void>;
  69698. /**
  69699. * Serializes the shadow generator setup to a json object.
  69700. * @returns The serialized JSON object
  69701. */
  69702. serialize(): any;
  69703. /**
  69704. * Disposes the Shadow map and related Textures and effects.
  69705. */
  69706. dispose(): void;
  69707. }
  69708. /**
  69709. * Default implementation IShadowGenerator.
  69710. * This is the main object responsible of generating shadows in the framework.
  69711. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69712. */
  69713. export class ShadowGenerator implements IShadowGenerator {
  69714. /**
  69715. * Shadow generator mode None: no filtering applied.
  69716. */
  69717. static readonly FILTER_NONE: number;
  69718. /**
  69719. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69720. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69721. */
  69722. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69723. /**
  69724. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69725. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69726. */
  69727. static readonly FILTER_POISSONSAMPLING: number;
  69728. /**
  69729. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69730. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69731. */
  69732. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69733. /**
  69734. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69735. * edge artifacts on steep falloff.
  69736. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69737. */
  69738. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69739. /**
  69740. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69741. * edge artifacts on steep falloff.
  69742. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69743. */
  69744. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69745. /**
  69746. * Shadow generator mode PCF: Percentage Closer Filtering
  69747. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69748. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69749. */
  69750. static readonly FILTER_PCF: number;
  69751. /**
  69752. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69753. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69754. * Contact Hardening
  69755. */
  69756. static readonly FILTER_PCSS: number;
  69757. /**
  69758. * Reserved for PCF and PCSS
  69759. * Highest Quality.
  69760. *
  69761. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69762. *
  69763. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69764. */
  69765. static readonly QUALITY_HIGH: number;
  69766. /**
  69767. * Reserved for PCF and PCSS
  69768. * Good tradeoff for quality/perf cross devices
  69769. *
  69770. * Execute PCF on a 3*3 kernel.
  69771. *
  69772. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69773. */
  69774. static readonly QUALITY_MEDIUM: number;
  69775. /**
  69776. * Reserved for PCF and PCSS
  69777. * The lowest quality but the fastest.
  69778. *
  69779. * Execute PCF on a 1*1 kernel.
  69780. *
  69781. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69782. */
  69783. static readonly QUALITY_LOW: number;
  69784. /** Gets or sets the custom shader name to use */
  69785. customShaderOptions: ICustomShaderOptions;
  69786. /**
  69787. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69788. */
  69789. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69790. /**
  69791. * Observable triggered before a mesh is rendered in the shadow map.
  69792. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69793. */
  69794. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69795. private _bias;
  69796. /**
  69797. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69798. */
  69799. /**
  69800. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69801. */
  69802. bias: number;
  69803. private _normalBias;
  69804. /**
  69805. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69806. */
  69807. /**
  69808. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69809. */
  69810. normalBias: number;
  69811. private _blurBoxOffset;
  69812. /**
  69813. * Gets the blur box offset: offset applied during the blur pass.
  69814. * Only useful if useKernelBlur = false
  69815. */
  69816. /**
  69817. * Sets the blur box offset: offset applied during the blur pass.
  69818. * Only useful if useKernelBlur = false
  69819. */
  69820. blurBoxOffset: number;
  69821. private _blurScale;
  69822. /**
  69823. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69824. * 2 means half of the size.
  69825. */
  69826. /**
  69827. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69828. * 2 means half of the size.
  69829. */
  69830. blurScale: number;
  69831. private _blurKernel;
  69832. /**
  69833. * Gets the blur kernel: kernel size of the blur pass.
  69834. * Only useful if useKernelBlur = true
  69835. */
  69836. /**
  69837. * Sets the blur kernel: kernel size of the blur pass.
  69838. * Only useful if useKernelBlur = true
  69839. */
  69840. blurKernel: number;
  69841. private _useKernelBlur;
  69842. /**
  69843. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69844. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69845. */
  69846. /**
  69847. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69848. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69849. */
  69850. useKernelBlur: boolean;
  69851. private _depthScale;
  69852. /**
  69853. * Gets the depth scale used in ESM mode.
  69854. */
  69855. /**
  69856. * Sets the depth scale used in ESM mode.
  69857. * This can override the scale stored on the light.
  69858. */
  69859. depthScale: number;
  69860. private _filter;
  69861. /**
  69862. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69863. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69864. */
  69865. /**
  69866. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69867. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69868. */
  69869. filter: number;
  69870. /**
  69871. * Gets if the current filter is set to Poisson Sampling.
  69872. */
  69873. /**
  69874. * Sets the current filter to Poisson Sampling.
  69875. */
  69876. usePoissonSampling: boolean;
  69877. /**
  69878. * Gets if the current filter is set to ESM.
  69879. */
  69880. /**
  69881. * Sets the current filter is to ESM.
  69882. */
  69883. useExponentialShadowMap: boolean;
  69884. /**
  69885. * Gets if the current filter is set to filtered ESM.
  69886. */
  69887. /**
  69888. * Gets if the current filter is set to filtered ESM.
  69889. */
  69890. useBlurExponentialShadowMap: boolean;
  69891. /**
  69892. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69893. * exponential to prevent steep falloff artifacts).
  69894. */
  69895. /**
  69896. * Sets the current filter to "close ESM" (using the inverse of the
  69897. * exponential to prevent steep falloff artifacts).
  69898. */
  69899. useCloseExponentialShadowMap: boolean;
  69900. /**
  69901. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69902. * exponential to prevent steep falloff artifacts).
  69903. */
  69904. /**
  69905. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69906. * exponential to prevent steep falloff artifacts).
  69907. */
  69908. useBlurCloseExponentialShadowMap: boolean;
  69909. /**
  69910. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69911. */
  69912. /**
  69913. * Sets the current filter to "PCF" (percentage closer filtering).
  69914. */
  69915. usePercentageCloserFiltering: boolean;
  69916. private _filteringQuality;
  69917. /**
  69918. * Gets the PCF or PCSS Quality.
  69919. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69920. */
  69921. /**
  69922. * Sets the PCF or PCSS Quality.
  69923. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69924. */
  69925. filteringQuality: number;
  69926. /**
  69927. * Gets if the current filter is set to "PCSS" (contact hardening).
  69928. */
  69929. /**
  69930. * Sets the current filter to "PCSS" (contact hardening).
  69931. */
  69932. useContactHardeningShadow: boolean;
  69933. private _contactHardeningLightSizeUVRatio;
  69934. /**
  69935. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69936. * Using a ratio helps keeping shape stability independently of the map size.
  69937. *
  69938. * It does not account for the light projection as it was having too much
  69939. * instability during the light setup or during light position changes.
  69940. *
  69941. * Only valid if useContactHardeningShadow is true.
  69942. */
  69943. /**
  69944. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69945. * Using a ratio helps keeping shape stability independently of the map size.
  69946. *
  69947. * It does not account for the light projection as it was having too much
  69948. * instability during the light setup or during light position changes.
  69949. *
  69950. * Only valid if useContactHardeningShadow is true.
  69951. */
  69952. contactHardeningLightSizeUVRatio: number;
  69953. private _darkness;
  69954. /**
  69955. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69956. * 0 means strongest and 1 would means no shadow.
  69957. * @returns the darkness.
  69958. */
  69959. getDarkness(): number;
  69960. /**
  69961. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69962. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69963. * @returns the shadow generator allowing fluent coding.
  69964. */
  69965. setDarkness(darkness: number): ShadowGenerator;
  69966. private _transparencyShadow;
  69967. /**
  69968. * Sets the ability to have transparent shadow (boolean).
  69969. * @param transparent True if transparent else False
  69970. * @returns the shadow generator allowing fluent coding
  69971. */
  69972. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69973. private _shadowMap;
  69974. private _shadowMap2;
  69975. /**
  69976. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69977. * @returns The render target texture if present otherwise, null
  69978. */
  69979. getShadowMap(): Nullable<RenderTargetTexture>;
  69980. /**
  69981. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69982. * @returns The render target texture if the shadow map is present otherwise, null
  69983. */
  69984. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69985. /**
  69986. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69987. * @param mesh Mesh to add
  69988. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69989. * @returns the Shadow Generator itself
  69990. */
  69991. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69992. /**
  69993. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69994. * @param mesh Mesh to remove
  69995. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69996. * @returns the Shadow Generator itself
  69997. */
  69998. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69999. /**
  70000. * Controls the extent to which the shadows fade out at the edge of the frustum
  70001. * Used only by directionals and spots
  70002. */
  70003. frustumEdgeFalloff: number;
  70004. private _light;
  70005. /**
  70006. * Returns the associated light object.
  70007. * @returns the light generating the shadow
  70008. */
  70009. getLight(): IShadowLight;
  70010. /**
  70011. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  70012. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  70013. * It might on the other hand introduce peter panning.
  70014. */
  70015. forceBackFacesOnly: boolean;
  70016. private _scene;
  70017. private _lightDirection;
  70018. private _effect;
  70019. private _viewMatrix;
  70020. private _projectionMatrix;
  70021. private _transformMatrix;
  70022. private _cachedPosition;
  70023. private _cachedDirection;
  70024. private _cachedDefines;
  70025. private _currentRenderID;
  70026. private _boxBlurPostprocess;
  70027. private _kernelBlurXPostprocess;
  70028. private _kernelBlurYPostprocess;
  70029. private _blurPostProcesses;
  70030. private _mapSize;
  70031. private _currentFaceIndex;
  70032. private _currentFaceIndexCache;
  70033. private _textureType;
  70034. private _defaultTextureMatrix;
  70035. /** @hidden */
  70036. static _SceneComponentInitialization: (scene: Scene) => void;
  70037. /**
  70038. * Creates a ShadowGenerator object.
  70039. * A ShadowGenerator is the required tool to use the shadows.
  70040. * Each light casting shadows needs to use its own ShadowGenerator.
  70041. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  70042. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  70043. * @param light The light object generating the shadows.
  70044. * @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.
  70045. */
  70046. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  70047. private _initializeGenerator;
  70048. private _initializeShadowMap;
  70049. private _initializeBlurRTTAndPostProcesses;
  70050. private _renderForShadowMap;
  70051. private _renderSubMeshForShadowMap;
  70052. private _applyFilterValues;
  70053. /**
  70054. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70055. * @param onCompiled Callback triggered at the and of the effects compilation
  70056. * @param options Sets of optional options forcing the compilation with different modes
  70057. */
  70058. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  70059. useInstances: boolean;
  70060. }>): void;
  70061. /**
  70062. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70063. * @param options Sets of optional options forcing the compilation with different modes
  70064. * @returns A promise that resolves when the compilation completes
  70065. */
  70066. forceCompilationAsync(options?: Partial<{
  70067. useInstances: boolean;
  70068. }>): Promise<void>;
  70069. /**
  70070. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  70071. * @param subMesh The submesh we want to render in the shadow map
  70072. * @param useInstances Defines wether will draw in the map using instances
  70073. * @returns true if ready otherwise, false
  70074. */
  70075. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70076. /**
  70077. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  70078. * @param defines Defines of the material we want to update
  70079. * @param lightIndex Index of the light in the enabled light list of the material
  70080. */
  70081. prepareDefines(defines: any, lightIndex: number): void;
  70082. /**
  70083. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  70084. * defined in the generator but impacting the effect).
  70085. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  70086. * @param effect The effect we are binfing the information for
  70087. */
  70088. bindShadowLight(lightIndex: string, effect: Effect): void;
  70089. /**
  70090. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  70091. * (eq to shadow prjection matrix * light transform matrix)
  70092. * @returns The transform matrix used to create the shadow map
  70093. */
  70094. getTransformMatrix(): Matrix;
  70095. /**
  70096. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  70097. * Cube and 2D textures for instance.
  70098. */
  70099. recreateShadowMap(): void;
  70100. private _disposeBlurPostProcesses;
  70101. private _disposeRTTandPostProcesses;
  70102. /**
  70103. * Disposes the ShadowGenerator.
  70104. * Returns nothing.
  70105. */
  70106. dispose(): void;
  70107. /**
  70108. * Serializes the shadow generator setup to a json object.
  70109. * @returns The serialized JSON object
  70110. */
  70111. serialize(): any;
  70112. /**
  70113. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  70114. * @param parsedShadowGenerator The JSON object to parse
  70115. * @param scene The scene to create the shadow map for
  70116. * @returns The parsed shadow generator
  70117. */
  70118. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  70119. }
  70120. }
  70121. declare module BABYLON {
  70122. /**
  70123. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  70124. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  70125. * 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.
  70126. */
  70127. export abstract class Light extends Node {
  70128. /**
  70129. * Falloff Default: light is falling off following the material specification:
  70130. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  70131. */
  70132. static readonly FALLOFF_DEFAULT: number;
  70133. /**
  70134. * Falloff Physical: light is falling off following the inverse squared distance law.
  70135. */
  70136. static readonly FALLOFF_PHYSICAL: number;
  70137. /**
  70138. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  70139. * to enhance interoperability with other engines.
  70140. */
  70141. static readonly FALLOFF_GLTF: number;
  70142. /**
  70143. * Falloff Standard: light is falling off like in the standard material
  70144. * to enhance interoperability with other materials.
  70145. */
  70146. static readonly FALLOFF_STANDARD: number;
  70147. /**
  70148. * If every light affecting the material is in this lightmapMode,
  70149. * material.lightmapTexture adds or multiplies
  70150. * (depends on material.useLightmapAsShadowmap)
  70151. * after every other light calculations.
  70152. */
  70153. static readonly LIGHTMAP_DEFAULT: number;
  70154. /**
  70155. * material.lightmapTexture as only diffuse lighting from this light
  70156. * adds only specular lighting from this light
  70157. * adds dynamic shadows
  70158. */
  70159. static readonly LIGHTMAP_SPECULAR: number;
  70160. /**
  70161. * material.lightmapTexture as only lighting
  70162. * no light calculation from this light
  70163. * only adds dynamic shadows from this light
  70164. */
  70165. static readonly LIGHTMAP_SHADOWSONLY: number;
  70166. /**
  70167. * Each light type uses the default quantity according to its type:
  70168. * point/spot lights use luminous intensity
  70169. * directional lights use illuminance
  70170. */
  70171. static readonly INTENSITYMODE_AUTOMATIC: number;
  70172. /**
  70173. * lumen (lm)
  70174. */
  70175. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  70176. /**
  70177. * candela (lm/sr)
  70178. */
  70179. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  70180. /**
  70181. * lux (lm/m^2)
  70182. */
  70183. static readonly INTENSITYMODE_ILLUMINANCE: number;
  70184. /**
  70185. * nit (cd/m^2)
  70186. */
  70187. static readonly INTENSITYMODE_LUMINANCE: number;
  70188. /**
  70189. * Light type const id of the point light.
  70190. */
  70191. static readonly LIGHTTYPEID_POINTLIGHT: number;
  70192. /**
  70193. * Light type const id of the directional light.
  70194. */
  70195. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  70196. /**
  70197. * Light type const id of the spot light.
  70198. */
  70199. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  70200. /**
  70201. * Light type const id of the hemispheric light.
  70202. */
  70203. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  70204. /**
  70205. * Diffuse gives the basic color to an object.
  70206. */
  70207. diffuse: Color3;
  70208. /**
  70209. * Specular produces a highlight color on an object.
  70210. * Note: This is note affecting PBR materials.
  70211. */
  70212. specular: Color3;
  70213. /**
  70214. * Defines the falloff type for this light. This lets overrriding how punctual light are
  70215. * falling off base on range or angle.
  70216. * This can be set to any values in Light.FALLOFF_x.
  70217. *
  70218. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  70219. * other types of materials.
  70220. */
  70221. falloffType: number;
  70222. /**
  70223. * Strength of the light.
  70224. * Note: By default it is define in the framework own unit.
  70225. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  70226. */
  70227. intensity: number;
  70228. private _range;
  70229. protected _inverseSquaredRange: number;
  70230. /**
  70231. * Defines how far from the source the light is impacting in scene units.
  70232. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70233. */
  70234. /**
  70235. * Defines how far from the source the light is impacting in scene units.
  70236. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70237. */
  70238. range: number;
  70239. /**
  70240. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  70241. * of light.
  70242. */
  70243. private _photometricScale;
  70244. private _intensityMode;
  70245. /**
  70246. * Gets the photometric scale used to interpret the intensity.
  70247. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70248. */
  70249. /**
  70250. * Sets the photometric scale used to interpret the intensity.
  70251. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70252. */
  70253. intensityMode: number;
  70254. private _radius;
  70255. /**
  70256. * Gets the light radius used by PBR Materials to simulate soft area lights.
  70257. */
  70258. /**
  70259. * sets the light radius used by PBR Materials to simulate soft area lights.
  70260. */
  70261. radius: number;
  70262. private _renderPriority;
  70263. /**
  70264. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  70265. * exceeding the number allowed of the materials.
  70266. */
  70267. renderPriority: number;
  70268. private _shadowEnabled;
  70269. /**
  70270. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70271. * the current shadow generator.
  70272. */
  70273. /**
  70274. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70275. * the current shadow generator.
  70276. */
  70277. shadowEnabled: boolean;
  70278. private _includedOnlyMeshes;
  70279. /**
  70280. * Gets the only meshes impacted by this light.
  70281. */
  70282. /**
  70283. * Sets the only meshes impacted by this light.
  70284. */
  70285. includedOnlyMeshes: AbstractMesh[];
  70286. private _excludedMeshes;
  70287. /**
  70288. * Gets the meshes not impacted by this light.
  70289. */
  70290. /**
  70291. * Sets the meshes not impacted by this light.
  70292. */
  70293. excludedMeshes: AbstractMesh[];
  70294. private _excludeWithLayerMask;
  70295. /**
  70296. * Gets the layer id use to find what meshes are not impacted by the light.
  70297. * Inactive if 0
  70298. */
  70299. /**
  70300. * Sets the layer id use to find what meshes are not impacted by the light.
  70301. * Inactive if 0
  70302. */
  70303. excludeWithLayerMask: number;
  70304. private _includeOnlyWithLayerMask;
  70305. /**
  70306. * Gets the layer id use to find what meshes are impacted by the light.
  70307. * Inactive if 0
  70308. */
  70309. /**
  70310. * Sets the layer id use to find what meshes are impacted by the light.
  70311. * Inactive if 0
  70312. */
  70313. includeOnlyWithLayerMask: number;
  70314. private _lightmapMode;
  70315. /**
  70316. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70317. */
  70318. /**
  70319. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70320. */
  70321. lightmapMode: number;
  70322. /**
  70323. * Shadow generator associted to the light.
  70324. * @hidden Internal use only.
  70325. */
  70326. _shadowGenerator: Nullable<IShadowGenerator>;
  70327. /**
  70328. * @hidden Internal use only.
  70329. */
  70330. _excludedMeshesIds: string[];
  70331. /**
  70332. * @hidden Internal use only.
  70333. */
  70334. _includedOnlyMeshesIds: string[];
  70335. /**
  70336. * The current light unifom buffer.
  70337. * @hidden Internal use only.
  70338. */
  70339. _uniformBuffer: UniformBuffer;
  70340. /**
  70341. * Creates a Light object in the scene.
  70342. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70343. * @param name The firendly name of the light
  70344. * @param scene The scene the light belongs too
  70345. */
  70346. constructor(name: string, scene: Scene);
  70347. protected abstract _buildUniformLayout(): void;
  70348. /**
  70349. * Sets the passed Effect "effect" with the Light information.
  70350. * @param effect The effect to update
  70351. * @param lightIndex The index of the light in the effect to update
  70352. * @returns The light
  70353. */
  70354. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  70355. /**
  70356. * Returns the string "Light".
  70357. * @returns the class name
  70358. */
  70359. getClassName(): string;
  70360. /** @hidden */
  70361. readonly _isLight: boolean;
  70362. /**
  70363. * Converts the light information to a readable string for debug purpose.
  70364. * @param fullDetails Supports for multiple levels of logging within scene loading
  70365. * @returns the human readable light info
  70366. */
  70367. toString(fullDetails?: boolean): string;
  70368. /** @hidden */
  70369. protected _syncParentEnabledState(): void;
  70370. /**
  70371. * Set the enabled state of this node.
  70372. * @param value - the new enabled state
  70373. */
  70374. setEnabled(value: boolean): void;
  70375. /**
  70376. * Returns the Light associated shadow generator if any.
  70377. * @return the associated shadow generator.
  70378. */
  70379. getShadowGenerator(): Nullable<IShadowGenerator>;
  70380. /**
  70381. * Returns a Vector3, the absolute light position in the World.
  70382. * @returns the world space position of the light
  70383. */
  70384. getAbsolutePosition(): Vector3;
  70385. /**
  70386. * Specifies if the light will affect the passed mesh.
  70387. * @param mesh The mesh to test against the light
  70388. * @return true the mesh is affected otherwise, false.
  70389. */
  70390. canAffectMesh(mesh: AbstractMesh): boolean;
  70391. /**
  70392. * Sort function to order lights for rendering.
  70393. * @param a First Light object to compare to second.
  70394. * @param b Second Light object to compare first.
  70395. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  70396. */
  70397. static CompareLightsPriority(a: Light, b: Light): number;
  70398. /**
  70399. * Releases resources associated with this node.
  70400. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70401. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70402. */
  70403. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70404. /**
  70405. * Returns the light type ID (integer).
  70406. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70407. */
  70408. getTypeID(): number;
  70409. /**
  70410. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  70411. * @returns the scaled intensity in intensity mode unit
  70412. */
  70413. getScaledIntensity(): number;
  70414. /**
  70415. * Returns a new Light object, named "name", from the current one.
  70416. * @param name The name of the cloned light
  70417. * @returns the new created light
  70418. */
  70419. clone(name: string): Nullable<Light>;
  70420. /**
  70421. * Serializes the current light into a Serialization object.
  70422. * @returns the serialized object.
  70423. */
  70424. serialize(): any;
  70425. /**
  70426. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  70427. * This new light is named "name" and added to the passed scene.
  70428. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  70429. * @param name The friendly name of the light
  70430. * @param scene The scene the new light will belong to
  70431. * @returns the constructor function
  70432. */
  70433. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  70434. /**
  70435. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  70436. * @param parsedLight The JSON representation of the light
  70437. * @param scene The scene to create the parsed light in
  70438. * @returns the created light after parsing
  70439. */
  70440. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  70441. private _hookArrayForExcluded;
  70442. private _hookArrayForIncludedOnly;
  70443. private _resyncMeshes;
  70444. /**
  70445. * Forces the meshes to update their light related information in their rendering used effects
  70446. * @hidden Internal Use Only
  70447. */
  70448. _markMeshesAsLightDirty(): void;
  70449. /**
  70450. * Recomputes the cached photometric scale if needed.
  70451. */
  70452. private _computePhotometricScale;
  70453. /**
  70454. * Returns the Photometric Scale according to the light type and intensity mode.
  70455. */
  70456. private _getPhotometricScale;
  70457. /**
  70458. * Reorder the light in the scene according to their defined priority.
  70459. * @hidden Internal Use Only
  70460. */
  70461. _reorderLightsInScene(): void;
  70462. /**
  70463. * Prepares the list of defines specific to the light type.
  70464. * @param defines the list of defines
  70465. * @param lightIndex defines the index of the light for the effect
  70466. */
  70467. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70468. }
  70469. }
  70470. declare module BABYLON {
  70471. /**
  70472. * Interface used to define Action
  70473. */
  70474. export interface IAction {
  70475. /**
  70476. * Trigger for the action
  70477. */
  70478. trigger: number;
  70479. /** Options of the trigger */
  70480. triggerOptions: any;
  70481. /**
  70482. * Gets the trigger parameters
  70483. * @returns the trigger parameters
  70484. */
  70485. getTriggerParameter(): any;
  70486. /**
  70487. * Internal only - executes current action event
  70488. * @hidden
  70489. */
  70490. _executeCurrent(evt?: ActionEvent): void;
  70491. /**
  70492. * Serialize placeholder for child classes
  70493. * @param parent of child
  70494. * @returns the serialized object
  70495. */
  70496. serialize(parent: any): any;
  70497. /**
  70498. * Internal only
  70499. * @hidden
  70500. */
  70501. _prepare(): void;
  70502. /**
  70503. * Internal only - manager for action
  70504. * @hidden
  70505. */
  70506. _actionManager: AbstractActionManager;
  70507. }
  70508. /**
  70509. * The action to be carried out following a trigger
  70510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  70511. */
  70512. export class Action implements IAction {
  70513. /** the trigger, with or without parameters, for the action */
  70514. triggerOptions: any;
  70515. /**
  70516. * Trigger for the action
  70517. */
  70518. trigger: number;
  70519. /**
  70520. * Internal only - manager for action
  70521. * @hidden
  70522. */
  70523. _actionManager: ActionManager;
  70524. private _nextActiveAction;
  70525. private _child;
  70526. private _condition?;
  70527. private _triggerParameter;
  70528. /**
  70529. * An event triggered prior to action being executed.
  70530. */
  70531. onBeforeExecuteObservable: Observable<Action>;
  70532. /**
  70533. * Creates a new Action
  70534. * @param triggerOptions the trigger, with or without parameters, for the action
  70535. * @param condition an optional determinant of action
  70536. */
  70537. constructor(
  70538. /** the trigger, with or without parameters, for the action */
  70539. triggerOptions: any, condition?: Condition);
  70540. /**
  70541. * Internal only
  70542. * @hidden
  70543. */
  70544. _prepare(): void;
  70545. /**
  70546. * Gets the trigger parameters
  70547. * @returns the trigger parameters
  70548. */
  70549. getTriggerParameter(): any;
  70550. /**
  70551. * Internal only - executes current action event
  70552. * @hidden
  70553. */
  70554. _executeCurrent(evt?: ActionEvent): void;
  70555. /**
  70556. * Execute placeholder for child classes
  70557. * @param evt optional action event
  70558. */
  70559. execute(evt?: ActionEvent): void;
  70560. /**
  70561. * Skips to next active action
  70562. */
  70563. skipToNextActiveAction(): void;
  70564. /**
  70565. * Adds action to chain of actions, may be a DoNothingAction
  70566. * @param action defines the next action to execute
  70567. * @returns The action passed in
  70568. * @see https://www.babylonjs-playground.com/#1T30HR#0
  70569. */
  70570. then(action: Action): Action;
  70571. /**
  70572. * Internal only
  70573. * @hidden
  70574. */
  70575. _getProperty(propertyPath: string): string;
  70576. /**
  70577. * Internal only
  70578. * @hidden
  70579. */
  70580. _getEffectiveTarget(target: any, propertyPath: string): any;
  70581. /**
  70582. * Serialize placeholder for child classes
  70583. * @param parent of child
  70584. * @returns the serialized object
  70585. */
  70586. serialize(parent: any): any;
  70587. /**
  70588. * Internal only called by serialize
  70589. * @hidden
  70590. */
  70591. protected _serialize(serializedAction: any, parent?: any): any;
  70592. /**
  70593. * Internal only
  70594. * @hidden
  70595. */
  70596. static _SerializeValueAsString: (value: any) => string;
  70597. /**
  70598. * Internal only
  70599. * @hidden
  70600. */
  70601. static _GetTargetProperty: (target: Scene | Node) => {
  70602. name: string;
  70603. targetType: string;
  70604. value: string;
  70605. };
  70606. }
  70607. }
  70608. declare module BABYLON {
  70609. /**
  70610. * A Condition applied to an Action
  70611. */
  70612. export class Condition {
  70613. /**
  70614. * Internal only - manager for action
  70615. * @hidden
  70616. */
  70617. _actionManager: ActionManager;
  70618. /**
  70619. * Internal only
  70620. * @hidden
  70621. */
  70622. _evaluationId: number;
  70623. /**
  70624. * Internal only
  70625. * @hidden
  70626. */
  70627. _currentResult: boolean;
  70628. /**
  70629. * Creates a new Condition
  70630. * @param actionManager the manager of the action the condition is applied to
  70631. */
  70632. constructor(actionManager: ActionManager);
  70633. /**
  70634. * Check if the current condition is valid
  70635. * @returns a boolean
  70636. */
  70637. isValid(): boolean;
  70638. /**
  70639. * Internal only
  70640. * @hidden
  70641. */
  70642. _getProperty(propertyPath: string): string;
  70643. /**
  70644. * Internal only
  70645. * @hidden
  70646. */
  70647. _getEffectiveTarget(target: any, propertyPath: string): any;
  70648. /**
  70649. * Serialize placeholder for child classes
  70650. * @returns the serialized object
  70651. */
  70652. serialize(): any;
  70653. /**
  70654. * Internal only
  70655. * @hidden
  70656. */
  70657. protected _serialize(serializedCondition: any): any;
  70658. }
  70659. /**
  70660. * Defines specific conditional operators as extensions of Condition
  70661. */
  70662. export class ValueCondition extends Condition {
  70663. /** path to specify the property of the target the conditional operator uses */
  70664. propertyPath: string;
  70665. /** the value compared by the conditional operator against the current value of the property */
  70666. value: any;
  70667. /** the conditional operator, default ValueCondition.IsEqual */
  70668. operator: number;
  70669. /**
  70670. * Internal only
  70671. * @hidden
  70672. */
  70673. private static _IsEqual;
  70674. /**
  70675. * Internal only
  70676. * @hidden
  70677. */
  70678. private static _IsDifferent;
  70679. /**
  70680. * Internal only
  70681. * @hidden
  70682. */
  70683. private static _IsGreater;
  70684. /**
  70685. * Internal only
  70686. * @hidden
  70687. */
  70688. private static _IsLesser;
  70689. /**
  70690. * returns the number for IsEqual
  70691. */
  70692. static readonly IsEqual: number;
  70693. /**
  70694. * Returns the number for IsDifferent
  70695. */
  70696. static readonly IsDifferent: number;
  70697. /**
  70698. * Returns the number for IsGreater
  70699. */
  70700. static readonly IsGreater: number;
  70701. /**
  70702. * Returns the number for IsLesser
  70703. */
  70704. static readonly IsLesser: number;
  70705. /**
  70706. * Internal only The action manager for the condition
  70707. * @hidden
  70708. */
  70709. _actionManager: ActionManager;
  70710. /**
  70711. * Internal only
  70712. * @hidden
  70713. */
  70714. private _target;
  70715. /**
  70716. * Internal only
  70717. * @hidden
  70718. */
  70719. private _effectiveTarget;
  70720. /**
  70721. * Internal only
  70722. * @hidden
  70723. */
  70724. private _property;
  70725. /**
  70726. * Creates a new ValueCondition
  70727. * @param actionManager manager for the action the condition applies to
  70728. * @param target for the action
  70729. * @param propertyPath path to specify the property of the target the conditional operator uses
  70730. * @param value the value compared by the conditional operator against the current value of the property
  70731. * @param operator the conditional operator, default ValueCondition.IsEqual
  70732. */
  70733. constructor(actionManager: ActionManager, target: any,
  70734. /** path to specify the property of the target the conditional operator uses */
  70735. propertyPath: string,
  70736. /** the value compared by the conditional operator against the current value of the property */
  70737. value: any,
  70738. /** the conditional operator, default ValueCondition.IsEqual */
  70739. operator?: number);
  70740. /**
  70741. * Compares the given value with the property value for the specified conditional operator
  70742. * @returns the result of the comparison
  70743. */
  70744. isValid(): boolean;
  70745. /**
  70746. * Serialize the ValueCondition into a JSON compatible object
  70747. * @returns serialization object
  70748. */
  70749. serialize(): any;
  70750. /**
  70751. * Gets the name of the conditional operator for the ValueCondition
  70752. * @param operator the conditional operator
  70753. * @returns the name
  70754. */
  70755. static GetOperatorName(operator: number): string;
  70756. }
  70757. /**
  70758. * Defines a predicate condition as an extension of Condition
  70759. */
  70760. export class PredicateCondition extends Condition {
  70761. /** defines the predicate function used to validate the condition */
  70762. predicate: () => boolean;
  70763. /**
  70764. * Internal only - manager for action
  70765. * @hidden
  70766. */
  70767. _actionManager: ActionManager;
  70768. /**
  70769. * Creates a new PredicateCondition
  70770. * @param actionManager manager for the action the condition applies to
  70771. * @param predicate defines the predicate function used to validate the condition
  70772. */
  70773. constructor(actionManager: ActionManager,
  70774. /** defines the predicate function used to validate the condition */
  70775. predicate: () => boolean);
  70776. /**
  70777. * @returns the validity of the predicate condition
  70778. */
  70779. isValid(): boolean;
  70780. }
  70781. /**
  70782. * Defines a state condition as an extension of Condition
  70783. */
  70784. export class StateCondition extends Condition {
  70785. /** Value to compare with target state */
  70786. value: string;
  70787. /**
  70788. * Internal only - manager for action
  70789. * @hidden
  70790. */
  70791. _actionManager: ActionManager;
  70792. /**
  70793. * Internal only
  70794. * @hidden
  70795. */
  70796. private _target;
  70797. /**
  70798. * Creates a new StateCondition
  70799. * @param actionManager manager for the action the condition applies to
  70800. * @param target of the condition
  70801. * @param value to compare with target state
  70802. */
  70803. constructor(actionManager: ActionManager, target: any,
  70804. /** Value to compare with target state */
  70805. value: string);
  70806. /**
  70807. * Gets a boolean indicating if the current condition is met
  70808. * @returns the validity of the state
  70809. */
  70810. isValid(): boolean;
  70811. /**
  70812. * Serialize the StateCondition into a JSON compatible object
  70813. * @returns serialization object
  70814. */
  70815. serialize(): any;
  70816. }
  70817. }
  70818. declare module BABYLON {
  70819. /**
  70820. * This defines an action responsible to toggle a boolean once triggered.
  70821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70822. */
  70823. export class SwitchBooleanAction extends Action {
  70824. /**
  70825. * The path to the boolean property in the target object
  70826. */
  70827. propertyPath: string;
  70828. private _target;
  70829. private _effectiveTarget;
  70830. private _property;
  70831. /**
  70832. * Instantiate the action
  70833. * @param triggerOptions defines the trigger options
  70834. * @param target defines the object containing the boolean
  70835. * @param propertyPath defines the path to the boolean property in the target object
  70836. * @param condition defines the trigger related conditions
  70837. */
  70838. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70839. /** @hidden */
  70840. _prepare(): void;
  70841. /**
  70842. * Execute the action toggle the boolean value.
  70843. */
  70844. execute(): void;
  70845. /**
  70846. * Serializes the actions and its related information.
  70847. * @param parent defines the object to serialize in
  70848. * @returns the serialized object
  70849. */
  70850. serialize(parent: any): any;
  70851. }
  70852. /**
  70853. * This defines an action responsible to set a the state field of the target
  70854. * to a desired value once triggered.
  70855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70856. */
  70857. export class SetStateAction extends Action {
  70858. /**
  70859. * The value to store in the state field.
  70860. */
  70861. value: string;
  70862. private _target;
  70863. /**
  70864. * Instantiate the action
  70865. * @param triggerOptions defines the trigger options
  70866. * @param target defines the object containing the state property
  70867. * @param value defines the value to store in the state field
  70868. * @param condition defines the trigger related conditions
  70869. */
  70870. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70871. /**
  70872. * Execute the action and store the value on the target state property.
  70873. */
  70874. execute(): void;
  70875. /**
  70876. * Serializes the actions and its related information.
  70877. * @param parent defines the object to serialize in
  70878. * @returns the serialized object
  70879. */
  70880. serialize(parent: any): any;
  70881. }
  70882. /**
  70883. * This defines an action responsible to set a property of the target
  70884. * to a desired value once triggered.
  70885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70886. */
  70887. export class SetValueAction extends Action {
  70888. /**
  70889. * The path of the property to set in the target.
  70890. */
  70891. propertyPath: string;
  70892. /**
  70893. * The value to set in the property
  70894. */
  70895. value: any;
  70896. private _target;
  70897. private _effectiveTarget;
  70898. private _property;
  70899. /**
  70900. * Instantiate the action
  70901. * @param triggerOptions defines the trigger options
  70902. * @param target defines the object containing the property
  70903. * @param propertyPath defines the path of the property to set in the target
  70904. * @param value defines the value to set in the property
  70905. * @param condition defines the trigger related conditions
  70906. */
  70907. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70908. /** @hidden */
  70909. _prepare(): void;
  70910. /**
  70911. * Execute the action and set the targetted property to the desired value.
  70912. */
  70913. execute(): void;
  70914. /**
  70915. * Serializes the actions and its related information.
  70916. * @param parent defines the object to serialize in
  70917. * @returns the serialized object
  70918. */
  70919. serialize(parent: any): any;
  70920. }
  70921. /**
  70922. * This defines an action responsible to increment the target value
  70923. * to a desired value once triggered.
  70924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70925. */
  70926. export class IncrementValueAction extends Action {
  70927. /**
  70928. * The path of the property to increment in the target.
  70929. */
  70930. propertyPath: string;
  70931. /**
  70932. * The value we should increment the property by.
  70933. */
  70934. value: any;
  70935. private _target;
  70936. private _effectiveTarget;
  70937. private _property;
  70938. /**
  70939. * Instantiate the action
  70940. * @param triggerOptions defines the trigger options
  70941. * @param target defines the object containing the property
  70942. * @param propertyPath defines the path of the property to increment in the target
  70943. * @param value defines the value value we should increment the property by
  70944. * @param condition defines the trigger related conditions
  70945. */
  70946. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70947. /** @hidden */
  70948. _prepare(): void;
  70949. /**
  70950. * Execute the action and increment the target of the value amount.
  70951. */
  70952. execute(): void;
  70953. /**
  70954. * Serializes the actions and its related information.
  70955. * @param parent defines the object to serialize in
  70956. * @returns the serialized object
  70957. */
  70958. serialize(parent: any): any;
  70959. }
  70960. /**
  70961. * This defines an action responsible to start an animation once triggered.
  70962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70963. */
  70964. export class PlayAnimationAction extends Action {
  70965. /**
  70966. * Where the animation should start (animation frame)
  70967. */
  70968. from: number;
  70969. /**
  70970. * Where the animation should stop (animation frame)
  70971. */
  70972. to: number;
  70973. /**
  70974. * Define if the animation should loop or stop after the first play.
  70975. */
  70976. loop?: boolean;
  70977. private _target;
  70978. /**
  70979. * Instantiate the action
  70980. * @param triggerOptions defines the trigger options
  70981. * @param target defines the target animation or animation name
  70982. * @param from defines from where the animation should start (animation frame)
  70983. * @param end defines where the animation should stop (animation frame)
  70984. * @param loop defines if the animation should loop or stop after the first play
  70985. * @param condition defines the trigger related conditions
  70986. */
  70987. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70988. /** @hidden */
  70989. _prepare(): void;
  70990. /**
  70991. * Execute the action and play the animation.
  70992. */
  70993. execute(): void;
  70994. /**
  70995. * Serializes the actions and its related information.
  70996. * @param parent defines the object to serialize in
  70997. * @returns the serialized object
  70998. */
  70999. serialize(parent: any): any;
  71000. }
  71001. /**
  71002. * This defines an action responsible to stop an animation once triggered.
  71003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71004. */
  71005. export class StopAnimationAction extends Action {
  71006. private _target;
  71007. /**
  71008. * Instantiate the action
  71009. * @param triggerOptions defines the trigger options
  71010. * @param target defines the target animation or animation name
  71011. * @param condition defines the trigger related conditions
  71012. */
  71013. constructor(triggerOptions: any, target: any, condition?: Condition);
  71014. /** @hidden */
  71015. _prepare(): void;
  71016. /**
  71017. * Execute the action and stop the animation.
  71018. */
  71019. execute(): void;
  71020. /**
  71021. * Serializes the actions and its related information.
  71022. * @param parent defines the object to serialize in
  71023. * @returns the serialized object
  71024. */
  71025. serialize(parent: any): any;
  71026. }
  71027. /**
  71028. * This defines an action responsible that does nothing once triggered.
  71029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71030. */
  71031. export class DoNothingAction extends Action {
  71032. /**
  71033. * Instantiate the action
  71034. * @param triggerOptions defines the trigger options
  71035. * @param condition defines the trigger related conditions
  71036. */
  71037. constructor(triggerOptions?: any, condition?: Condition);
  71038. /**
  71039. * Execute the action and do nothing.
  71040. */
  71041. execute(): void;
  71042. /**
  71043. * Serializes the actions and its related information.
  71044. * @param parent defines the object to serialize in
  71045. * @returns the serialized object
  71046. */
  71047. serialize(parent: any): any;
  71048. }
  71049. /**
  71050. * This defines an action responsible to trigger several actions once triggered.
  71051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71052. */
  71053. export class CombineAction extends Action {
  71054. /**
  71055. * The list of aggregated animations to run.
  71056. */
  71057. children: Action[];
  71058. /**
  71059. * Instantiate the action
  71060. * @param triggerOptions defines the trigger options
  71061. * @param children defines the list of aggregated animations to run
  71062. * @param condition defines the trigger related conditions
  71063. */
  71064. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  71065. /** @hidden */
  71066. _prepare(): void;
  71067. /**
  71068. * Execute the action and executes all the aggregated actions.
  71069. */
  71070. execute(evt: ActionEvent): void;
  71071. /**
  71072. * Serializes the actions and its related information.
  71073. * @param parent defines the object to serialize in
  71074. * @returns the serialized object
  71075. */
  71076. serialize(parent: any): any;
  71077. }
  71078. /**
  71079. * This defines an action responsible to run code (external event) once triggered.
  71080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71081. */
  71082. export class ExecuteCodeAction extends Action {
  71083. /**
  71084. * The callback function to run.
  71085. */
  71086. func: (evt: ActionEvent) => void;
  71087. /**
  71088. * Instantiate the action
  71089. * @param triggerOptions defines the trigger options
  71090. * @param func defines the callback function to run
  71091. * @param condition defines the trigger related conditions
  71092. */
  71093. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  71094. /**
  71095. * Execute the action and run the attached code.
  71096. */
  71097. execute(evt: ActionEvent): void;
  71098. }
  71099. /**
  71100. * This defines an action responsible to set the parent property of the target once triggered.
  71101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71102. */
  71103. export class SetParentAction extends Action {
  71104. private _parent;
  71105. private _target;
  71106. /**
  71107. * Instantiate the action
  71108. * @param triggerOptions defines the trigger options
  71109. * @param target defines the target containing the parent property
  71110. * @param parent defines from where the animation should start (animation frame)
  71111. * @param condition defines the trigger related conditions
  71112. */
  71113. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  71114. /** @hidden */
  71115. _prepare(): void;
  71116. /**
  71117. * Execute the action and set the parent property.
  71118. */
  71119. execute(): void;
  71120. /**
  71121. * Serializes the actions and its related information.
  71122. * @param parent defines the object to serialize in
  71123. * @returns the serialized object
  71124. */
  71125. serialize(parent: any): any;
  71126. }
  71127. }
  71128. declare module BABYLON {
  71129. /**
  71130. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  71131. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  71132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71133. */
  71134. export class ActionManager extends AbstractActionManager {
  71135. /**
  71136. * Nothing
  71137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71138. */
  71139. static readonly NothingTrigger: number;
  71140. /**
  71141. * On pick
  71142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71143. */
  71144. static readonly OnPickTrigger: number;
  71145. /**
  71146. * On left pick
  71147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71148. */
  71149. static readonly OnLeftPickTrigger: number;
  71150. /**
  71151. * On right pick
  71152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71153. */
  71154. static readonly OnRightPickTrigger: number;
  71155. /**
  71156. * On center pick
  71157. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71158. */
  71159. static readonly OnCenterPickTrigger: number;
  71160. /**
  71161. * On pick down
  71162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71163. */
  71164. static readonly OnPickDownTrigger: number;
  71165. /**
  71166. * On double pick
  71167. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71168. */
  71169. static readonly OnDoublePickTrigger: number;
  71170. /**
  71171. * On pick up
  71172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71173. */
  71174. static readonly OnPickUpTrigger: number;
  71175. /**
  71176. * On pick out.
  71177. * This trigger will only be raised if you also declared a OnPickDown
  71178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71179. */
  71180. static readonly OnPickOutTrigger: number;
  71181. /**
  71182. * On long press
  71183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71184. */
  71185. static readonly OnLongPressTrigger: number;
  71186. /**
  71187. * On pointer over
  71188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71189. */
  71190. static readonly OnPointerOverTrigger: number;
  71191. /**
  71192. * On pointer out
  71193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71194. */
  71195. static readonly OnPointerOutTrigger: number;
  71196. /**
  71197. * On every frame
  71198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71199. */
  71200. static readonly OnEveryFrameTrigger: number;
  71201. /**
  71202. * On intersection enter
  71203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71204. */
  71205. static readonly OnIntersectionEnterTrigger: number;
  71206. /**
  71207. * On intersection exit
  71208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71209. */
  71210. static readonly OnIntersectionExitTrigger: number;
  71211. /**
  71212. * On key down
  71213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71214. */
  71215. static readonly OnKeyDownTrigger: number;
  71216. /**
  71217. * On key up
  71218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71219. */
  71220. static readonly OnKeyUpTrigger: number;
  71221. private _scene;
  71222. /**
  71223. * Creates a new action manager
  71224. * @param scene defines the hosting scene
  71225. */
  71226. constructor(scene: Scene);
  71227. /**
  71228. * Releases all associated resources
  71229. */
  71230. dispose(): void;
  71231. /**
  71232. * Gets hosting scene
  71233. * @returns the hosting scene
  71234. */
  71235. getScene(): Scene;
  71236. /**
  71237. * Does this action manager handles actions of any of the given triggers
  71238. * @param triggers defines the triggers to be tested
  71239. * @return a boolean indicating whether one (or more) of the triggers is handled
  71240. */
  71241. hasSpecificTriggers(triggers: number[]): boolean;
  71242. /**
  71243. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  71244. * speed.
  71245. * @param triggerA defines the trigger to be tested
  71246. * @param triggerB defines the trigger to be tested
  71247. * @return a boolean indicating whether one (or more) of the triggers is handled
  71248. */
  71249. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  71250. /**
  71251. * Does this action manager handles actions of a given trigger
  71252. * @param trigger defines the trigger to be tested
  71253. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  71254. * @return whether the trigger is handled
  71255. */
  71256. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  71257. /**
  71258. * Does this action manager has pointer triggers
  71259. */
  71260. readonly hasPointerTriggers: boolean;
  71261. /**
  71262. * Does this action manager has pick triggers
  71263. */
  71264. readonly hasPickTriggers: boolean;
  71265. /**
  71266. * Registers an action to this action manager
  71267. * @param action defines the action to be registered
  71268. * @return the action amended (prepared) after registration
  71269. */
  71270. registerAction(action: IAction): Nullable<IAction>;
  71271. /**
  71272. * Unregisters an action to this action manager
  71273. * @param action defines the action to be unregistered
  71274. * @return a boolean indicating whether the action has been unregistered
  71275. */
  71276. unregisterAction(action: IAction): Boolean;
  71277. /**
  71278. * Process a specific trigger
  71279. * @param trigger defines the trigger to process
  71280. * @param evt defines the event details to be processed
  71281. */
  71282. processTrigger(trigger: number, evt?: IActionEvent): void;
  71283. /** @hidden */
  71284. _getEffectiveTarget(target: any, propertyPath: string): any;
  71285. /** @hidden */
  71286. _getProperty(propertyPath: string): string;
  71287. /**
  71288. * Serialize this manager to a JSON object
  71289. * @param name defines the property name to store this manager
  71290. * @returns a JSON representation of this manager
  71291. */
  71292. serialize(name: string): any;
  71293. /**
  71294. * Creates a new ActionManager from a JSON data
  71295. * @param parsedActions defines the JSON data to read from
  71296. * @param object defines the hosting mesh
  71297. * @param scene defines the hosting scene
  71298. */
  71299. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  71300. /**
  71301. * Get a trigger name by index
  71302. * @param trigger defines the trigger index
  71303. * @returns a trigger name
  71304. */
  71305. static GetTriggerName(trigger: number): string;
  71306. }
  71307. }
  71308. declare module BABYLON {
  71309. /**
  71310. * Class representing a ray with position and direction
  71311. */
  71312. export class Ray {
  71313. /** origin point */
  71314. origin: Vector3;
  71315. /** direction */
  71316. direction: Vector3;
  71317. /** length of the ray */
  71318. length: number;
  71319. private static readonly TmpVector3;
  71320. private _tmpRay;
  71321. /**
  71322. * Creates a new ray
  71323. * @param origin origin point
  71324. * @param direction direction
  71325. * @param length length of the ray
  71326. */
  71327. constructor(
  71328. /** origin point */
  71329. origin: Vector3,
  71330. /** direction */
  71331. direction: Vector3,
  71332. /** length of the ray */
  71333. length?: number);
  71334. /**
  71335. * Checks if the ray intersects a box
  71336. * @param minimum bound of the box
  71337. * @param maximum bound of the box
  71338. * @param intersectionTreshold extra extend to be added to the box in all direction
  71339. * @returns if the box was hit
  71340. */
  71341. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  71342. /**
  71343. * Checks if the ray intersects a box
  71344. * @param box the bounding box to check
  71345. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  71346. * @returns if the box was hit
  71347. */
  71348. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  71349. /**
  71350. * If the ray hits a sphere
  71351. * @param sphere the bounding sphere to check
  71352. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  71353. * @returns true if it hits the sphere
  71354. */
  71355. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  71356. /**
  71357. * If the ray hits a triange
  71358. * @param vertex0 triangle vertex
  71359. * @param vertex1 triangle vertex
  71360. * @param vertex2 triangle vertex
  71361. * @returns intersection information if hit
  71362. */
  71363. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  71364. /**
  71365. * Checks if ray intersects a plane
  71366. * @param plane the plane to check
  71367. * @returns the distance away it was hit
  71368. */
  71369. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  71370. /**
  71371. * Checks if ray intersects a mesh
  71372. * @param mesh the mesh to check
  71373. * @param fastCheck if only the bounding box should checked
  71374. * @returns picking info of the intersecton
  71375. */
  71376. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  71377. /**
  71378. * Checks if ray intersects a mesh
  71379. * @param meshes the meshes to check
  71380. * @param fastCheck if only the bounding box should checked
  71381. * @param results array to store result in
  71382. * @returns Array of picking infos
  71383. */
  71384. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  71385. private _comparePickingInfo;
  71386. private static smallnum;
  71387. private static rayl;
  71388. /**
  71389. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  71390. * @param sega the first point of the segment to test the intersection against
  71391. * @param segb the second point of the segment to test the intersection against
  71392. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  71393. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  71394. */
  71395. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  71396. /**
  71397. * Update the ray from viewport position
  71398. * @param x position
  71399. * @param y y position
  71400. * @param viewportWidth viewport width
  71401. * @param viewportHeight viewport height
  71402. * @param world world matrix
  71403. * @param view view matrix
  71404. * @param projection projection matrix
  71405. * @returns this ray updated
  71406. */
  71407. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71408. /**
  71409. * Creates a ray with origin and direction of 0,0,0
  71410. * @returns the new ray
  71411. */
  71412. static Zero(): Ray;
  71413. /**
  71414. * Creates a new ray from screen space and viewport
  71415. * @param x position
  71416. * @param y y position
  71417. * @param viewportWidth viewport width
  71418. * @param viewportHeight viewport height
  71419. * @param world world matrix
  71420. * @param view view matrix
  71421. * @param projection projection matrix
  71422. * @returns new ray
  71423. */
  71424. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71425. /**
  71426. * 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
  71427. * transformed to the given world matrix.
  71428. * @param origin The origin point
  71429. * @param end The end point
  71430. * @param world a matrix to transform the ray to. Default is the identity matrix.
  71431. * @returns the new ray
  71432. */
  71433. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  71434. /**
  71435. * Transforms a ray by a matrix
  71436. * @param ray ray to transform
  71437. * @param matrix matrix to apply
  71438. * @returns the resulting new ray
  71439. */
  71440. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  71441. /**
  71442. * Transforms a ray by a matrix
  71443. * @param ray ray to transform
  71444. * @param matrix matrix to apply
  71445. * @param result ray to store result in
  71446. */
  71447. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  71448. /**
  71449. * Unproject a ray from screen space to object space
  71450. * @param sourceX defines the screen space x coordinate to use
  71451. * @param sourceY defines the screen space y coordinate to use
  71452. * @param viewportWidth defines the current width of the viewport
  71453. * @param viewportHeight defines the current height of the viewport
  71454. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71455. * @param view defines the view matrix to use
  71456. * @param projection defines the projection matrix to use
  71457. */
  71458. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  71459. }
  71460. /**
  71461. * Type used to define predicate used to select faces when a mesh intersection is detected
  71462. */
  71463. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  71464. interface Scene {
  71465. /** @hidden */
  71466. _tempPickingRay: Nullable<Ray>;
  71467. /** @hidden */
  71468. _cachedRayForTransform: Ray;
  71469. /** @hidden */
  71470. _pickWithRayInverseMatrix: Matrix;
  71471. /** @hidden */
  71472. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  71473. /** @hidden */
  71474. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  71475. }
  71476. }
  71477. declare module BABYLON {
  71478. /**
  71479. * Groups all the scene component constants in one place to ease maintenance.
  71480. * @hidden
  71481. */
  71482. export class SceneComponentConstants {
  71483. static readonly NAME_EFFECTLAYER: string;
  71484. static readonly NAME_LAYER: string;
  71485. static readonly NAME_LENSFLARESYSTEM: string;
  71486. static readonly NAME_BOUNDINGBOXRENDERER: string;
  71487. static readonly NAME_PARTICLESYSTEM: string;
  71488. static readonly NAME_GAMEPAD: string;
  71489. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  71490. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  71491. static readonly NAME_DEPTHRENDERER: string;
  71492. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  71493. static readonly NAME_SPRITE: string;
  71494. static readonly NAME_OUTLINERENDERER: string;
  71495. static readonly NAME_PROCEDURALTEXTURE: string;
  71496. static readonly NAME_SHADOWGENERATOR: string;
  71497. static readonly NAME_OCTREE: string;
  71498. static readonly NAME_PHYSICSENGINE: string;
  71499. static readonly NAME_AUDIO: string;
  71500. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  71501. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71502. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  71503. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71504. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  71505. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  71506. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  71507. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  71508. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  71509. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  71510. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  71511. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  71512. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  71513. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  71514. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  71515. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  71516. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  71517. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  71518. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  71519. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  71520. static readonly STEP_AFTERRENDER_AUDIO: number;
  71521. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  71522. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  71523. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  71524. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  71525. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  71526. static readonly STEP_POINTERMOVE_SPRITE: number;
  71527. static readonly STEP_POINTERDOWN_SPRITE: number;
  71528. static readonly STEP_POINTERUP_SPRITE: number;
  71529. }
  71530. /**
  71531. * This represents a scene component.
  71532. *
  71533. * This is used to decouple the dependency the scene is having on the different workloads like
  71534. * layers, post processes...
  71535. */
  71536. export interface ISceneComponent {
  71537. /**
  71538. * The name of the component. Each component must have a unique name.
  71539. */
  71540. name: string;
  71541. /**
  71542. * The scene the component belongs to.
  71543. */
  71544. scene: Scene;
  71545. /**
  71546. * Register the component to one instance of a scene.
  71547. */
  71548. register(): void;
  71549. /**
  71550. * Rebuilds the elements related to this component in case of
  71551. * context lost for instance.
  71552. */
  71553. rebuild(): void;
  71554. /**
  71555. * Disposes the component and the associated ressources.
  71556. */
  71557. dispose(): void;
  71558. }
  71559. /**
  71560. * This represents a SERIALIZABLE scene component.
  71561. *
  71562. * This extends Scene Component to add Serialization methods on top.
  71563. */
  71564. export interface ISceneSerializableComponent extends ISceneComponent {
  71565. /**
  71566. * Adds all the element from the container to the scene
  71567. * @param container the container holding the elements
  71568. */
  71569. addFromContainer(container: AbstractScene): void;
  71570. /**
  71571. * Removes all the elements in the container from the scene
  71572. * @param container contains the elements to remove
  71573. * @param dispose if the removed element should be disposed (default: false)
  71574. */
  71575. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71576. /**
  71577. * Serializes the component data to the specified json object
  71578. * @param serializationObject The object to serialize to
  71579. */
  71580. serialize(serializationObject: any): void;
  71581. }
  71582. /**
  71583. * Strong typing of a Mesh related stage step action
  71584. */
  71585. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  71586. /**
  71587. * Strong typing of a Evaluate Sub Mesh related stage step action
  71588. */
  71589. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  71590. /**
  71591. * Strong typing of a Active Mesh related stage step action
  71592. */
  71593. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  71594. /**
  71595. * Strong typing of a Camera related stage step action
  71596. */
  71597. export type CameraStageAction = (camera: Camera) => void;
  71598. /**
  71599. * Strong typing of a Camera Frame buffer related stage step action
  71600. */
  71601. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  71602. /**
  71603. * Strong typing of a Render Target related stage step action
  71604. */
  71605. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  71606. /**
  71607. * Strong typing of a RenderingGroup related stage step action
  71608. */
  71609. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  71610. /**
  71611. * Strong typing of a Mesh Render related stage step action
  71612. */
  71613. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  71614. /**
  71615. * Strong typing of a simple stage step action
  71616. */
  71617. export type SimpleStageAction = () => void;
  71618. /**
  71619. * Strong typing of a render target action.
  71620. */
  71621. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  71622. /**
  71623. * Strong typing of a pointer move action.
  71624. */
  71625. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  71626. /**
  71627. * Strong typing of a pointer up/down action.
  71628. */
  71629. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  71630. /**
  71631. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  71632. * @hidden
  71633. */
  71634. export class Stage<T extends Function> extends Array<{
  71635. index: number;
  71636. component: ISceneComponent;
  71637. action: T;
  71638. }> {
  71639. /**
  71640. * Hide ctor from the rest of the world.
  71641. * @param items The items to add.
  71642. */
  71643. private constructor();
  71644. /**
  71645. * Creates a new Stage.
  71646. * @returns A new instance of a Stage
  71647. */
  71648. static Create<T extends Function>(): Stage<T>;
  71649. /**
  71650. * Registers a step in an ordered way in the targeted stage.
  71651. * @param index Defines the position to register the step in
  71652. * @param component Defines the component attached to the step
  71653. * @param action Defines the action to launch during the step
  71654. */
  71655. registerStep(index: number, component: ISceneComponent, action: T): void;
  71656. /**
  71657. * Clears all the steps from the stage.
  71658. */
  71659. clear(): void;
  71660. }
  71661. }
  71662. declare module BABYLON {
  71663. interface Scene {
  71664. /** @hidden */
  71665. _pointerOverSprite: Nullable<Sprite>;
  71666. /** @hidden */
  71667. _pickedDownSprite: Nullable<Sprite>;
  71668. /** @hidden */
  71669. _tempSpritePickingRay: Nullable<Ray>;
  71670. /**
  71671. * All of the sprite managers added to this scene
  71672. * @see http://doc.babylonjs.com/babylon101/sprites
  71673. */
  71674. spriteManagers: Array<ISpriteManager>;
  71675. /**
  71676. * An event triggered when sprites rendering is about to start
  71677. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71678. */
  71679. onBeforeSpritesRenderingObservable: Observable<Scene>;
  71680. /**
  71681. * An event triggered when sprites rendering is done
  71682. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71683. */
  71684. onAfterSpritesRenderingObservable: Observable<Scene>;
  71685. /** @hidden */
  71686. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71687. /** Launch a ray to try to pick a sprite in the scene
  71688. * @param x position on screen
  71689. * @param y position on screen
  71690. * @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
  71691. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71692. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71693. * @returns a PickingInfo
  71694. */
  71695. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71696. /** Use the given ray to pick a sprite in the scene
  71697. * @param ray The ray (in world space) to use to pick meshes
  71698. * @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
  71699. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71700. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71701. * @returns a PickingInfo
  71702. */
  71703. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71704. /**
  71705. * Force the sprite under the pointer
  71706. * @param sprite defines the sprite to use
  71707. */
  71708. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71709. /**
  71710. * Gets the sprite under the pointer
  71711. * @returns a Sprite or null if no sprite is under the pointer
  71712. */
  71713. getPointerOverSprite(): Nullable<Sprite>;
  71714. }
  71715. /**
  71716. * Defines the sprite scene component responsible to manage sprites
  71717. * in a given scene.
  71718. */
  71719. export class SpriteSceneComponent implements ISceneComponent {
  71720. /**
  71721. * The component name helpfull to identify the component in the list of scene components.
  71722. */
  71723. readonly name: string;
  71724. /**
  71725. * The scene the component belongs to.
  71726. */
  71727. scene: Scene;
  71728. /** @hidden */
  71729. private _spritePredicate;
  71730. /**
  71731. * Creates a new instance of the component for the given scene
  71732. * @param scene Defines the scene to register the component in
  71733. */
  71734. constructor(scene: Scene);
  71735. /**
  71736. * Registers the component in a given scene
  71737. */
  71738. register(): void;
  71739. /**
  71740. * Rebuilds the elements related to this component in case of
  71741. * context lost for instance.
  71742. */
  71743. rebuild(): void;
  71744. /**
  71745. * Disposes the component and the associated ressources.
  71746. */
  71747. dispose(): void;
  71748. private _pickSpriteButKeepRay;
  71749. private _pointerMove;
  71750. private _pointerDown;
  71751. private _pointerUp;
  71752. }
  71753. }
  71754. declare module BABYLON {
  71755. /** @hidden */
  71756. export var fogFragmentDeclaration: {
  71757. name: string;
  71758. shader: string;
  71759. };
  71760. }
  71761. declare module BABYLON {
  71762. /** @hidden */
  71763. export var fogFragment: {
  71764. name: string;
  71765. shader: string;
  71766. };
  71767. }
  71768. declare module BABYLON {
  71769. /** @hidden */
  71770. export var spritesPixelShader: {
  71771. name: string;
  71772. shader: string;
  71773. };
  71774. }
  71775. declare module BABYLON {
  71776. /** @hidden */
  71777. export var fogVertexDeclaration: {
  71778. name: string;
  71779. shader: string;
  71780. };
  71781. }
  71782. declare module BABYLON {
  71783. /** @hidden */
  71784. export var spritesVertexShader: {
  71785. name: string;
  71786. shader: string;
  71787. };
  71788. }
  71789. declare module BABYLON {
  71790. /**
  71791. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71792. */
  71793. export interface ISpriteManager extends IDisposable {
  71794. /**
  71795. * Restricts the camera to viewing objects with the same layerMask.
  71796. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71797. */
  71798. layerMask: number;
  71799. /**
  71800. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71801. */
  71802. isPickable: boolean;
  71803. /**
  71804. * Specifies the rendering group id for this mesh (0 by default)
  71805. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71806. */
  71807. renderingGroupId: number;
  71808. /**
  71809. * Defines the list of sprites managed by the manager.
  71810. */
  71811. sprites: Array<Sprite>;
  71812. /**
  71813. * Tests the intersection of a sprite with a specific ray.
  71814. * @param ray The ray we are sending to test the collision
  71815. * @param camera The camera space we are sending rays in
  71816. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71817. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71818. * @returns picking info or null.
  71819. */
  71820. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71821. /**
  71822. * Renders the list of sprites on screen.
  71823. */
  71824. render(): void;
  71825. }
  71826. /**
  71827. * Class used to manage multiple sprites on the same spritesheet
  71828. * @see http://doc.babylonjs.com/babylon101/sprites
  71829. */
  71830. export class SpriteManager implements ISpriteManager {
  71831. /** defines the manager's name */
  71832. name: string;
  71833. /** Gets the list of sprites */
  71834. sprites: Sprite[];
  71835. /** Gets or sets the rendering group id (0 by default) */
  71836. renderingGroupId: number;
  71837. /** Gets or sets camera layer mask */
  71838. layerMask: number;
  71839. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71840. fogEnabled: boolean;
  71841. /** Gets or sets a boolean indicating if the sprites are pickable */
  71842. isPickable: boolean;
  71843. /** Defines the default width of a cell in the spritesheet */
  71844. cellWidth: number;
  71845. /** Defines the default height of a cell in the spritesheet */
  71846. cellHeight: number;
  71847. /**
  71848. * An event triggered when the manager is disposed.
  71849. */
  71850. onDisposeObservable: Observable<SpriteManager>;
  71851. private _onDisposeObserver;
  71852. /**
  71853. * Callback called when the manager is disposed
  71854. */
  71855. onDispose: () => void;
  71856. private _capacity;
  71857. private _spriteTexture;
  71858. private _epsilon;
  71859. private _scene;
  71860. private _vertexData;
  71861. private _buffer;
  71862. private _vertexBuffers;
  71863. private _indexBuffer;
  71864. private _effectBase;
  71865. private _effectFog;
  71866. /**
  71867. * Gets or sets the spritesheet texture
  71868. */
  71869. texture: Texture;
  71870. /**
  71871. * Creates a new sprite manager
  71872. * @param name defines the manager's name
  71873. * @param imgUrl defines the sprite sheet url
  71874. * @param capacity defines the maximum allowed number of sprites
  71875. * @param cellSize defines the size of a sprite cell
  71876. * @param scene defines the hosting scene
  71877. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71878. * @param samplingMode defines the smapling mode to use with spritesheet
  71879. */
  71880. constructor(
  71881. /** defines the manager's name */
  71882. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71883. private _appendSpriteVertex;
  71884. /**
  71885. * Intersects the sprites with a ray
  71886. * @param ray defines the ray to intersect with
  71887. * @param camera defines the current active camera
  71888. * @param predicate defines a predicate used to select candidate sprites
  71889. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71890. * @returns null if no hit or a PickingInfo
  71891. */
  71892. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71893. /**
  71894. * Render all child sprites
  71895. */
  71896. render(): void;
  71897. /**
  71898. * Release associated resources
  71899. */
  71900. dispose(): void;
  71901. }
  71902. }
  71903. declare module BABYLON {
  71904. /**
  71905. * Class used to represent a sprite
  71906. * @see http://doc.babylonjs.com/babylon101/sprites
  71907. */
  71908. export class Sprite {
  71909. /** defines the name */
  71910. name: string;
  71911. /** Gets or sets the current world position */
  71912. position: Vector3;
  71913. /** Gets or sets the main color */
  71914. color: Color4;
  71915. /** Gets or sets the width */
  71916. width: number;
  71917. /** Gets or sets the height */
  71918. height: number;
  71919. /** Gets or sets rotation angle */
  71920. angle: number;
  71921. /** Gets or sets the cell index in the sprite sheet */
  71922. cellIndex: number;
  71923. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71924. invertU: number;
  71925. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71926. invertV: number;
  71927. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71928. disposeWhenFinishedAnimating: boolean;
  71929. /** Gets the list of attached animations */
  71930. animations: Animation[];
  71931. /** Gets or sets a boolean indicating if the sprite can be picked */
  71932. isPickable: boolean;
  71933. /**
  71934. * Gets or sets the associated action manager
  71935. */
  71936. actionManager: Nullable<ActionManager>;
  71937. private _animationStarted;
  71938. private _loopAnimation;
  71939. private _fromIndex;
  71940. private _toIndex;
  71941. private _delay;
  71942. private _direction;
  71943. private _manager;
  71944. private _time;
  71945. private _onAnimationEnd;
  71946. /**
  71947. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71948. */
  71949. isVisible: boolean;
  71950. /**
  71951. * Gets or sets the sprite size
  71952. */
  71953. size: number;
  71954. /**
  71955. * Creates a new Sprite
  71956. * @param name defines the name
  71957. * @param manager defines the manager
  71958. */
  71959. constructor(
  71960. /** defines the name */
  71961. name: string, manager: ISpriteManager);
  71962. /**
  71963. * Starts an animation
  71964. * @param from defines the initial key
  71965. * @param to defines the end key
  71966. * @param loop defines if the animation must loop
  71967. * @param delay defines the start delay (in ms)
  71968. * @param onAnimationEnd defines a callback to call when animation ends
  71969. */
  71970. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71971. /** Stops current animation (if any) */
  71972. stopAnimation(): void;
  71973. /** @hidden */
  71974. _animate(deltaTime: number): void;
  71975. /** Release associated resources */
  71976. dispose(): void;
  71977. }
  71978. }
  71979. declare module BABYLON {
  71980. /**
  71981. * Information about the result of picking within a scene
  71982. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71983. */
  71984. export class PickingInfo {
  71985. /** @hidden */
  71986. _pickingUnavailable: boolean;
  71987. /**
  71988. * If the pick collided with an object
  71989. */
  71990. hit: boolean;
  71991. /**
  71992. * Distance away where the pick collided
  71993. */
  71994. distance: number;
  71995. /**
  71996. * The location of pick collision
  71997. */
  71998. pickedPoint: Nullable<Vector3>;
  71999. /**
  72000. * The mesh corresponding the the pick collision
  72001. */
  72002. pickedMesh: Nullable<AbstractMesh>;
  72003. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  72004. bu: number;
  72005. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  72006. bv: number;
  72007. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  72008. faceId: number;
  72009. /** Id of the the submesh that was picked */
  72010. subMeshId: number;
  72011. /** If a sprite was picked, this will be the sprite the pick collided with */
  72012. pickedSprite: Nullable<Sprite>;
  72013. /**
  72014. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  72015. */
  72016. originMesh: Nullable<AbstractMesh>;
  72017. /**
  72018. * The ray that was used to perform the picking.
  72019. */
  72020. ray: Nullable<Ray>;
  72021. /**
  72022. * Gets the normal correspodning to the face the pick collided with
  72023. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  72024. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  72025. * @returns The normal correspodning to the face the pick collided with
  72026. */
  72027. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  72028. /**
  72029. * Gets the texture coordinates of where the pick occured
  72030. * @returns the vector containing the coordnates of the texture
  72031. */
  72032. getTextureCoordinates(): Nullable<Vector2>;
  72033. }
  72034. }
  72035. declare module BABYLON {
  72036. /**
  72037. * Gather the list of pointer event types as constants.
  72038. */
  72039. export class PointerEventTypes {
  72040. /**
  72041. * 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.
  72042. */
  72043. static readonly POINTERDOWN: number;
  72044. /**
  72045. * The pointerup event is fired when a pointer is no longer active.
  72046. */
  72047. static readonly POINTERUP: number;
  72048. /**
  72049. * The pointermove event is fired when a pointer changes coordinates.
  72050. */
  72051. static readonly POINTERMOVE: number;
  72052. /**
  72053. * The pointerwheel event is fired when a mouse wheel has been rotated.
  72054. */
  72055. static readonly POINTERWHEEL: number;
  72056. /**
  72057. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  72058. */
  72059. static readonly POINTERPICK: number;
  72060. /**
  72061. * The pointertap event is fired when a the object has been touched and released without drag.
  72062. */
  72063. static readonly POINTERTAP: number;
  72064. /**
  72065. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  72066. */
  72067. static readonly POINTERDOUBLETAP: number;
  72068. }
  72069. /**
  72070. * Base class of pointer info types.
  72071. */
  72072. export class PointerInfoBase {
  72073. /**
  72074. * Defines the type of event (PointerEventTypes)
  72075. */
  72076. type: number;
  72077. /**
  72078. * Defines the related dom event
  72079. */
  72080. event: PointerEvent | MouseWheelEvent;
  72081. /**
  72082. * Instantiates the base class of pointers info.
  72083. * @param type Defines the type of event (PointerEventTypes)
  72084. * @param event Defines the related dom event
  72085. */
  72086. constructor(
  72087. /**
  72088. * Defines the type of event (PointerEventTypes)
  72089. */
  72090. type: number,
  72091. /**
  72092. * Defines the related dom event
  72093. */
  72094. event: PointerEvent | MouseWheelEvent);
  72095. }
  72096. /**
  72097. * This class is used to store pointer related info for the onPrePointerObservable event.
  72098. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  72099. */
  72100. export class PointerInfoPre extends PointerInfoBase {
  72101. /**
  72102. * Ray from a pointer if availible (eg. 6dof controller)
  72103. */
  72104. ray: Nullable<Ray>;
  72105. /**
  72106. * Defines the local position of the pointer on the canvas.
  72107. */
  72108. localPosition: Vector2;
  72109. /**
  72110. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  72111. */
  72112. skipOnPointerObservable: boolean;
  72113. /**
  72114. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  72115. * @param type Defines the type of event (PointerEventTypes)
  72116. * @param event Defines the related dom event
  72117. * @param localX Defines the local x coordinates of the pointer when the event occured
  72118. * @param localY Defines the local y coordinates of the pointer when the event occured
  72119. */
  72120. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  72121. }
  72122. /**
  72123. * This type contains all the data related to a pointer event in Babylon.js.
  72124. * 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.
  72125. */
  72126. export class PointerInfo extends PointerInfoBase {
  72127. /**
  72128. * Defines the picking info associated to the info (if any)\
  72129. */
  72130. pickInfo: Nullable<PickingInfo>;
  72131. /**
  72132. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  72133. * @param type Defines the type of event (PointerEventTypes)
  72134. * @param event Defines the related dom event
  72135. * @param pickInfo Defines the picking info associated to the info (if any)\
  72136. */
  72137. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  72138. /**
  72139. * Defines the picking info associated to the info (if any)\
  72140. */
  72141. pickInfo: Nullable<PickingInfo>);
  72142. }
  72143. /**
  72144. * Data relating to a touch event on the screen.
  72145. */
  72146. export interface PointerTouch {
  72147. /**
  72148. * X coordinate of touch.
  72149. */
  72150. x: number;
  72151. /**
  72152. * Y coordinate of touch.
  72153. */
  72154. y: number;
  72155. /**
  72156. * Id of touch. Unique for each finger.
  72157. */
  72158. pointerId: number;
  72159. /**
  72160. * Event type passed from DOM.
  72161. */
  72162. type: any;
  72163. }
  72164. }
  72165. declare module BABYLON {
  72166. /**
  72167. * Manage the mouse inputs to control the movement of a free camera.
  72168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72169. */
  72170. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  72171. /**
  72172. * Define if touch is enabled in the mouse input
  72173. */
  72174. touchEnabled: boolean;
  72175. /**
  72176. * Defines the camera the input is attached to.
  72177. */
  72178. camera: FreeCamera;
  72179. /**
  72180. * Defines the buttons associated with the input to handle camera move.
  72181. */
  72182. buttons: number[];
  72183. /**
  72184. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  72185. */
  72186. angularSensibility: number;
  72187. private _pointerInput;
  72188. private _onMouseMove;
  72189. private _observer;
  72190. private previousPosition;
  72191. /**
  72192. * Observable for when a pointer move event occurs containing the move offset
  72193. */
  72194. onPointerMovedObservable: Observable<{
  72195. offsetX: number;
  72196. offsetY: number;
  72197. }>;
  72198. /**
  72199. * @hidden
  72200. * If the camera should be rotated automatically based on pointer movement
  72201. */
  72202. _allowCameraRotation: boolean;
  72203. /**
  72204. * Manage the mouse inputs to control the movement of a free camera.
  72205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72206. * @param touchEnabled Defines if touch is enabled or not
  72207. */
  72208. constructor(
  72209. /**
  72210. * Define if touch is enabled in the mouse input
  72211. */
  72212. touchEnabled?: boolean);
  72213. /**
  72214. * Attach the input controls to a specific dom element to get the input from.
  72215. * @param element Defines the element the controls should be listened from
  72216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72217. */
  72218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72219. /**
  72220. * Called on JS contextmenu event.
  72221. * Override this method to provide functionality.
  72222. */
  72223. protected onContextMenu(evt: PointerEvent): void;
  72224. /**
  72225. * Detach the current controls from the specified dom element.
  72226. * @param element Defines the element to stop listening the inputs from
  72227. */
  72228. detachControl(element: Nullable<HTMLElement>): void;
  72229. /**
  72230. * Gets the class name of the current intput.
  72231. * @returns the class name
  72232. */
  72233. getClassName(): string;
  72234. /**
  72235. * Get the friendly name associated with the input class.
  72236. * @returns the input friendly name
  72237. */
  72238. getSimpleName(): string;
  72239. }
  72240. }
  72241. declare module BABYLON {
  72242. /**
  72243. * Manage the touch inputs to control the movement of a free camera.
  72244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72245. */
  72246. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  72247. /**
  72248. * Defines the camera the input is attached to.
  72249. */
  72250. camera: FreeCamera;
  72251. /**
  72252. * Defines the touch sensibility for rotation.
  72253. * The higher the faster.
  72254. */
  72255. touchAngularSensibility: number;
  72256. /**
  72257. * Defines the touch sensibility for move.
  72258. * The higher the faster.
  72259. */
  72260. touchMoveSensibility: number;
  72261. private _offsetX;
  72262. private _offsetY;
  72263. private _pointerPressed;
  72264. private _pointerInput;
  72265. private _observer;
  72266. private _onLostFocus;
  72267. /**
  72268. * Attach the input controls to a specific dom element to get the input from.
  72269. * @param element Defines the element the controls should be listened from
  72270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72271. */
  72272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72273. /**
  72274. * Detach the current controls from the specified dom element.
  72275. * @param element Defines the element to stop listening the inputs from
  72276. */
  72277. detachControl(element: Nullable<HTMLElement>): void;
  72278. /**
  72279. * Update the current camera state depending on the inputs that have been used this frame.
  72280. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72281. */
  72282. checkInputs(): void;
  72283. /**
  72284. * Gets the class name of the current intput.
  72285. * @returns the class name
  72286. */
  72287. getClassName(): string;
  72288. /**
  72289. * Get the friendly name associated with the input class.
  72290. * @returns the input friendly name
  72291. */
  72292. getSimpleName(): string;
  72293. }
  72294. }
  72295. declare module BABYLON {
  72296. /**
  72297. * Default Inputs manager for the FreeCamera.
  72298. * It groups all the default supported inputs for ease of use.
  72299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72300. */
  72301. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  72302. /**
  72303. * @hidden
  72304. */
  72305. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  72306. /**
  72307. * @hidden
  72308. */
  72309. _mouseInput: Nullable<FreeCameraMouseInput>;
  72310. /**
  72311. * Instantiates a new FreeCameraInputsManager.
  72312. * @param camera Defines the camera the inputs belong to
  72313. */
  72314. constructor(camera: FreeCamera);
  72315. /**
  72316. * Add keyboard input support to the input manager.
  72317. * @returns the current input manager
  72318. */
  72319. addKeyboard(): FreeCameraInputsManager;
  72320. /**
  72321. * Add mouse input support to the input manager.
  72322. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  72323. * @returns the current input manager
  72324. */
  72325. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  72326. /**
  72327. * Removes the mouse input support from the manager
  72328. * @returns the current input manager
  72329. */
  72330. removeMouse(): FreeCameraInputsManager;
  72331. /**
  72332. * Add touch input support to the input manager.
  72333. * @returns the current input manager
  72334. */
  72335. addTouch(): FreeCameraInputsManager;
  72336. }
  72337. }
  72338. declare module BABYLON {
  72339. /**
  72340. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72341. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  72342. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72343. */
  72344. export class FreeCamera extends TargetCamera {
  72345. /**
  72346. * Define the collision ellipsoid of the camera.
  72347. * This is helpful to simulate a camera body like the player body around the camera
  72348. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  72349. */
  72350. ellipsoid: Vector3;
  72351. /**
  72352. * Define an offset for the position of the ellipsoid around the camera.
  72353. * This can be helpful to determine the center of the body near the gravity center of the body
  72354. * instead of its head.
  72355. */
  72356. ellipsoidOffset: Vector3;
  72357. /**
  72358. * Enable or disable collisions of the camera with the rest of the scene objects.
  72359. */
  72360. checkCollisions: boolean;
  72361. /**
  72362. * Enable or disable gravity on the camera.
  72363. */
  72364. applyGravity: boolean;
  72365. /**
  72366. * Define the input manager associated to the camera.
  72367. */
  72368. inputs: FreeCameraInputsManager;
  72369. /**
  72370. * Gets the input sensibility for a mouse input. (default is 2000.0)
  72371. * Higher values reduce sensitivity.
  72372. */
  72373. /**
  72374. * Sets the input sensibility for a mouse input. (default is 2000.0)
  72375. * Higher values reduce sensitivity.
  72376. */
  72377. angularSensibility: number;
  72378. /**
  72379. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72380. */
  72381. keysUp: number[];
  72382. /**
  72383. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72384. */
  72385. keysDown: number[];
  72386. /**
  72387. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72388. */
  72389. keysLeft: number[];
  72390. /**
  72391. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72392. */
  72393. keysRight: number[];
  72394. /**
  72395. * Event raised when the camera collide with a mesh in the scene.
  72396. */
  72397. onCollide: (collidedMesh: AbstractMesh) => void;
  72398. private _collider;
  72399. private _needMoveForGravity;
  72400. private _oldPosition;
  72401. private _diffPosition;
  72402. private _newPosition;
  72403. /** @hidden */
  72404. _localDirection: Vector3;
  72405. /** @hidden */
  72406. _transformedDirection: Vector3;
  72407. /**
  72408. * Instantiates a Free Camera.
  72409. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72410. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  72411. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72412. * @param name Define the name of the camera in the scene
  72413. * @param position Define the start position of the camera in the scene
  72414. * @param scene Define the scene the camera belongs to
  72415. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72416. */
  72417. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72418. /**
  72419. * Attached controls to the current camera.
  72420. * @param element Defines the element the controls should be listened from
  72421. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72422. */
  72423. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72424. /**
  72425. * Detach the current controls from the camera.
  72426. * The camera will stop reacting to inputs.
  72427. * @param element Defines the element to stop listening the inputs from
  72428. */
  72429. detachControl(element: HTMLElement): void;
  72430. private _collisionMask;
  72431. /**
  72432. * Define a collision mask to limit the list of object the camera can collide with
  72433. */
  72434. collisionMask: number;
  72435. /** @hidden */
  72436. _collideWithWorld(displacement: Vector3): void;
  72437. private _onCollisionPositionChange;
  72438. /** @hidden */
  72439. _checkInputs(): void;
  72440. /** @hidden */
  72441. _decideIfNeedsToMove(): boolean;
  72442. /** @hidden */
  72443. _updatePosition(): void;
  72444. /**
  72445. * Destroy the camera and release the current resources hold by it.
  72446. */
  72447. dispose(): void;
  72448. /**
  72449. * Gets the current object class name.
  72450. * @return the class name
  72451. */
  72452. getClassName(): string;
  72453. }
  72454. }
  72455. declare module BABYLON {
  72456. /**
  72457. * Represents a gamepad control stick position
  72458. */
  72459. export class StickValues {
  72460. /**
  72461. * The x component of the control stick
  72462. */
  72463. x: number;
  72464. /**
  72465. * The y component of the control stick
  72466. */
  72467. y: number;
  72468. /**
  72469. * Initializes the gamepad x and y control stick values
  72470. * @param x The x component of the gamepad control stick value
  72471. * @param y The y component of the gamepad control stick value
  72472. */
  72473. constructor(
  72474. /**
  72475. * The x component of the control stick
  72476. */
  72477. x: number,
  72478. /**
  72479. * The y component of the control stick
  72480. */
  72481. y: number);
  72482. }
  72483. /**
  72484. * An interface which manages callbacks for gamepad button changes
  72485. */
  72486. export interface GamepadButtonChanges {
  72487. /**
  72488. * Called when a gamepad has been changed
  72489. */
  72490. changed: boolean;
  72491. /**
  72492. * Called when a gamepad press event has been triggered
  72493. */
  72494. pressChanged: boolean;
  72495. /**
  72496. * Called when a touch event has been triggered
  72497. */
  72498. touchChanged: boolean;
  72499. /**
  72500. * Called when a value has changed
  72501. */
  72502. valueChanged: boolean;
  72503. }
  72504. /**
  72505. * Represents a gamepad
  72506. */
  72507. export class Gamepad {
  72508. /**
  72509. * The id of the gamepad
  72510. */
  72511. id: string;
  72512. /**
  72513. * The index of the gamepad
  72514. */
  72515. index: number;
  72516. /**
  72517. * The browser gamepad
  72518. */
  72519. browserGamepad: any;
  72520. /**
  72521. * Specifies what type of gamepad this represents
  72522. */
  72523. type: number;
  72524. private _leftStick;
  72525. private _rightStick;
  72526. /** @hidden */
  72527. _isConnected: boolean;
  72528. private _leftStickAxisX;
  72529. private _leftStickAxisY;
  72530. private _rightStickAxisX;
  72531. private _rightStickAxisY;
  72532. /**
  72533. * Triggered when the left control stick has been changed
  72534. */
  72535. private _onleftstickchanged;
  72536. /**
  72537. * Triggered when the right control stick has been changed
  72538. */
  72539. private _onrightstickchanged;
  72540. /**
  72541. * Represents a gamepad controller
  72542. */
  72543. static GAMEPAD: number;
  72544. /**
  72545. * Represents a generic controller
  72546. */
  72547. static GENERIC: number;
  72548. /**
  72549. * Represents an XBox controller
  72550. */
  72551. static XBOX: number;
  72552. /**
  72553. * Represents a pose-enabled controller
  72554. */
  72555. static POSE_ENABLED: number;
  72556. /**
  72557. * Specifies whether the left control stick should be Y-inverted
  72558. */
  72559. protected _invertLeftStickY: boolean;
  72560. /**
  72561. * Specifies if the gamepad has been connected
  72562. */
  72563. readonly isConnected: boolean;
  72564. /**
  72565. * Initializes the gamepad
  72566. * @param id The id of the gamepad
  72567. * @param index The index of the gamepad
  72568. * @param browserGamepad The browser gamepad
  72569. * @param leftStickX The x component of the left joystick
  72570. * @param leftStickY The y component of the left joystick
  72571. * @param rightStickX The x component of the right joystick
  72572. * @param rightStickY The y component of the right joystick
  72573. */
  72574. constructor(
  72575. /**
  72576. * The id of the gamepad
  72577. */
  72578. id: string,
  72579. /**
  72580. * The index of the gamepad
  72581. */
  72582. index: number,
  72583. /**
  72584. * The browser gamepad
  72585. */
  72586. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  72587. /**
  72588. * Callback triggered when the left joystick has changed
  72589. * @param callback
  72590. */
  72591. onleftstickchanged(callback: (values: StickValues) => void): void;
  72592. /**
  72593. * Callback triggered when the right joystick has changed
  72594. * @param callback
  72595. */
  72596. onrightstickchanged(callback: (values: StickValues) => void): void;
  72597. /**
  72598. * Gets the left joystick
  72599. */
  72600. /**
  72601. * Sets the left joystick values
  72602. */
  72603. leftStick: StickValues;
  72604. /**
  72605. * Gets the right joystick
  72606. */
  72607. /**
  72608. * Sets the right joystick value
  72609. */
  72610. rightStick: StickValues;
  72611. /**
  72612. * Updates the gamepad joystick positions
  72613. */
  72614. update(): void;
  72615. /**
  72616. * Disposes the gamepad
  72617. */
  72618. dispose(): void;
  72619. }
  72620. /**
  72621. * Represents a generic gamepad
  72622. */
  72623. export class GenericPad extends Gamepad {
  72624. private _buttons;
  72625. private _onbuttondown;
  72626. private _onbuttonup;
  72627. /**
  72628. * Observable triggered when a button has been pressed
  72629. */
  72630. onButtonDownObservable: Observable<number>;
  72631. /**
  72632. * Observable triggered when a button has been released
  72633. */
  72634. onButtonUpObservable: Observable<number>;
  72635. /**
  72636. * Callback triggered when a button has been pressed
  72637. * @param callback Called when a button has been pressed
  72638. */
  72639. onbuttondown(callback: (buttonPressed: number) => void): void;
  72640. /**
  72641. * Callback triggered when a button has been released
  72642. * @param callback Called when a button has been released
  72643. */
  72644. onbuttonup(callback: (buttonReleased: number) => void): void;
  72645. /**
  72646. * Initializes the generic gamepad
  72647. * @param id The id of the generic gamepad
  72648. * @param index The index of the generic gamepad
  72649. * @param browserGamepad The browser gamepad
  72650. */
  72651. constructor(id: string, index: number, browserGamepad: any);
  72652. private _setButtonValue;
  72653. /**
  72654. * Updates the generic gamepad
  72655. */
  72656. update(): void;
  72657. /**
  72658. * Disposes the generic gamepad
  72659. */
  72660. dispose(): void;
  72661. }
  72662. }
  72663. declare module BABYLON {
  72664. /**
  72665. * Defines the types of pose enabled controllers that are supported
  72666. */
  72667. export enum PoseEnabledControllerType {
  72668. /**
  72669. * HTC Vive
  72670. */
  72671. VIVE = 0,
  72672. /**
  72673. * Oculus Rift
  72674. */
  72675. OCULUS = 1,
  72676. /**
  72677. * Windows mixed reality
  72678. */
  72679. WINDOWS = 2,
  72680. /**
  72681. * Samsung gear VR
  72682. */
  72683. GEAR_VR = 3,
  72684. /**
  72685. * Google Daydream
  72686. */
  72687. DAYDREAM = 4,
  72688. /**
  72689. * Generic
  72690. */
  72691. GENERIC = 5
  72692. }
  72693. /**
  72694. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72695. */
  72696. export interface MutableGamepadButton {
  72697. /**
  72698. * Value of the button/trigger
  72699. */
  72700. value: number;
  72701. /**
  72702. * If the button/trigger is currently touched
  72703. */
  72704. touched: boolean;
  72705. /**
  72706. * If the button/trigger is currently pressed
  72707. */
  72708. pressed: boolean;
  72709. }
  72710. /**
  72711. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72712. * @hidden
  72713. */
  72714. export interface ExtendedGamepadButton extends GamepadButton {
  72715. /**
  72716. * If the button/trigger is currently pressed
  72717. */
  72718. readonly pressed: boolean;
  72719. /**
  72720. * If the button/trigger is currently touched
  72721. */
  72722. readonly touched: boolean;
  72723. /**
  72724. * Value of the button/trigger
  72725. */
  72726. readonly value: number;
  72727. }
  72728. /** @hidden */
  72729. export interface _GamePadFactory {
  72730. /**
  72731. * Returns wether or not the current gamepad can be created for this type of controller.
  72732. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72733. * @returns true if it can be created, otherwise false
  72734. */
  72735. canCreate(gamepadInfo: any): boolean;
  72736. /**
  72737. * Creates a new instance of the Gamepad.
  72738. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72739. * @returns the new gamepad instance
  72740. */
  72741. create(gamepadInfo: any): Gamepad;
  72742. }
  72743. /**
  72744. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72745. */
  72746. export class PoseEnabledControllerHelper {
  72747. /** @hidden */
  72748. static _ControllerFactories: _GamePadFactory[];
  72749. /** @hidden */
  72750. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72751. /**
  72752. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72753. * @param vrGamepad the gamepad to initialized
  72754. * @returns a vr controller of the type the gamepad identified as
  72755. */
  72756. static InitiateController(vrGamepad: any): Gamepad;
  72757. }
  72758. /**
  72759. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72760. */
  72761. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72762. private _deviceRoomPosition;
  72763. private _deviceRoomRotationQuaternion;
  72764. /**
  72765. * The device position in babylon space
  72766. */
  72767. devicePosition: Vector3;
  72768. /**
  72769. * The device rotation in babylon space
  72770. */
  72771. deviceRotationQuaternion: Quaternion;
  72772. /**
  72773. * The scale factor of the device in babylon space
  72774. */
  72775. deviceScaleFactor: number;
  72776. /**
  72777. * (Likely devicePosition should be used instead) The device position in its room space
  72778. */
  72779. position: Vector3;
  72780. /**
  72781. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72782. */
  72783. rotationQuaternion: Quaternion;
  72784. /**
  72785. * The type of controller (Eg. Windows mixed reality)
  72786. */
  72787. controllerType: PoseEnabledControllerType;
  72788. protected _calculatedPosition: Vector3;
  72789. private _calculatedRotation;
  72790. /**
  72791. * The raw pose from the device
  72792. */
  72793. rawPose: DevicePose;
  72794. private _trackPosition;
  72795. private _maxRotationDistFromHeadset;
  72796. private _draggedRoomRotation;
  72797. /**
  72798. * @hidden
  72799. */
  72800. _disableTrackPosition(fixedPosition: Vector3): void;
  72801. /**
  72802. * Internal, the mesh attached to the controller
  72803. * @hidden
  72804. */
  72805. _mesh: Nullable<AbstractMesh>;
  72806. private _poseControlledCamera;
  72807. private _leftHandSystemQuaternion;
  72808. /**
  72809. * Internal, matrix used to convert room space to babylon space
  72810. * @hidden
  72811. */
  72812. _deviceToWorld: Matrix;
  72813. /**
  72814. * Node to be used when casting a ray from the controller
  72815. * @hidden
  72816. */
  72817. _pointingPoseNode: Nullable<TransformNode>;
  72818. /**
  72819. * Name of the child mesh that can be used to cast a ray from the controller
  72820. */
  72821. static readonly POINTING_POSE: string;
  72822. /**
  72823. * Creates a new PoseEnabledController from a gamepad
  72824. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72825. */
  72826. constructor(browserGamepad: any);
  72827. private _workingMatrix;
  72828. /**
  72829. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72830. */
  72831. update(): void;
  72832. /**
  72833. * Updates only the pose device and mesh without doing any button event checking
  72834. */
  72835. protected _updatePoseAndMesh(): void;
  72836. /**
  72837. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72838. * @param poseData raw pose fromthe device
  72839. */
  72840. updateFromDevice(poseData: DevicePose): void;
  72841. /**
  72842. * @hidden
  72843. */
  72844. _meshAttachedObservable: Observable<AbstractMesh>;
  72845. /**
  72846. * Attaches a mesh to the controller
  72847. * @param mesh the mesh to be attached
  72848. */
  72849. attachToMesh(mesh: AbstractMesh): void;
  72850. /**
  72851. * Attaches the controllers mesh to a camera
  72852. * @param camera the camera the mesh should be attached to
  72853. */
  72854. attachToPoseControlledCamera(camera: TargetCamera): void;
  72855. /**
  72856. * Disposes of the controller
  72857. */
  72858. dispose(): void;
  72859. /**
  72860. * The mesh that is attached to the controller
  72861. */
  72862. readonly mesh: Nullable<AbstractMesh>;
  72863. /**
  72864. * Gets the ray of the controller in the direction the controller is pointing
  72865. * @param length the length the resulting ray should be
  72866. * @returns a ray in the direction the controller is pointing
  72867. */
  72868. getForwardRay(length?: number): Ray;
  72869. }
  72870. }
  72871. declare module BABYLON {
  72872. /**
  72873. * Defines the WebVRController object that represents controllers tracked in 3D space
  72874. */
  72875. export abstract class WebVRController extends PoseEnabledController {
  72876. /**
  72877. * Internal, the default controller model for the controller
  72878. */
  72879. protected _defaultModel: AbstractMesh;
  72880. /**
  72881. * Fired when the trigger state has changed
  72882. */
  72883. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72884. /**
  72885. * Fired when the main button state has changed
  72886. */
  72887. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72888. /**
  72889. * Fired when the secondary button state has changed
  72890. */
  72891. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72892. /**
  72893. * Fired when the pad state has changed
  72894. */
  72895. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72896. /**
  72897. * Fired when controllers stick values have changed
  72898. */
  72899. onPadValuesChangedObservable: Observable<StickValues>;
  72900. /**
  72901. * Array of button availible on the controller
  72902. */
  72903. protected _buttons: Array<MutableGamepadButton>;
  72904. private _onButtonStateChange;
  72905. /**
  72906. * Fired when a controller button's state has changed
  72907. * @param callback the callback containing the button that was modified
  72908. */
  72909. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72910. /**
  72911. * X and Y axis corrisponding to the controllers joystick
  72912. */
  72913. pad: StickValues;
  72914. /**
  72915. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72916. */
  72917. hand: string;
  72918. /**
  72919. * The default controller model for the controller
  72920. */
  72921. readonly defaultModel: AbstractMesh;
  72922. /**
  72923. * Creates a new WebVRController from a gamepad
  72924. * @param vrGamepad the gamepad that the WebVRController should be created from
  72925. */
  72926. constructor(vrGamepad: any);
  72927. /**
  72928. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72929. */
  72930. update(): void;
  72931. /**
  72932. * Function to be called when a button is modified
  72933. */
  72934. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72935. /**
  72936. * Loads a mesh and attaches it to the controller
  72937. * @param scene the scene the mesh should be added to
  72938. * @param meshLoaded callback for when the mesh has been loaded
  72939. */
  72940. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72941. private _setButtonValue;
  72942. private _changes;
  72943. private _checkChanges;
  72944. /**
  72945. * Disposes of th webVRCOntroller
  72946. */
  72947. dispose(): void;
  72948. }
  72949. }
  72950. declare module BABYLON {
  72951. /**
  72952. * The HemisphericLight simulates the ambient environment light,
  72953. * so the passed direction is the light reflection direction, not the incoming direction.
  72954. */
  72955. export class HemisphericLight extends Light {
  72956. /**
  72957. * The groundColor is the light in the opposite direction to the one specified during creation.
  72958. * 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.
  72959. */
  72960. groundColor: Color3;
  72961. /**
  72962. * The light reflection direction, not the incoming direction.
  72963. */
  72964. direction: Vector3;
  72965. /**
  72966. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72967. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72968. * The HemisphericLight can't cast shadows.
  72969. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72970. * @param name The friendly name of the light
  72971. * @param direction The direction of the light reflection
  72972. * @param scene The scene the light belongs to
  72973. */
  72974. constructor(name: string, direction: Vector3, scene: Scene);
  72975. protected _buildUniformLayout(): void;
  72976. /**
  72977. * Returns the string "HemisphericLight".
  72978. * @return The class name
  72979. */
  72980. getClassName(): string;
  72981. /**
  72982. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72983. * Returns the updated direction.
  72984. * @param target The target the direction should point to
  72985. * @return The computed direction
  72986. */
  72987. setDirectionToTarget(target: Vector3): Vector3;
  72988. /**
  72989. * Returns the shadow generator associated to the light.
  72990. * @returns Always null for hemispheric lights because it does not support shadows.
  72991. */
  72992. getShadowGenerator(): Nullable<IShadowGenerator>;
  72993. /**
  72994. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72995. * @param effect The effect to update
  72996. * @param lightIndex The index of the light in the effect to update
  72997. * @returns The hemispheric light
  72998. */
  72999. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  73000. /**
  73001. * Computes the world matrix of the node
  73002. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73003. * @param useWasUpdatedFlag defines a reserved property
  73004. * @returns the world matrix
  73005. */
  73006. computeWorldMatrix(): Matrix;
  73007. /**
  73008. * Returns the integer 3.
  73009. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73010. */
  73011. getTypeID(): number;
  73012. /**
  73013. * Prepares the list of defines specific to the light type.
  73014. * @param defines the list of defines
  73015. * @param lightIndex defines the index of the light for the effect
  73016. */
  73017. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73018. }
  73019. }
  73020. declare module BABYLON {
  73021. /** @hidden */
  73022. export var vrMultiviewToSingleviewPixelShader: {
  73023. name: string;
  73024. shader: string;
  73025. };
  73026. }
  73027. declare module BABYLON {
  73028. /**
  73029. * Renders to multiple views with a single draw call
  73030. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  73031. */
  73032. export class MultiviewRenderTarget extends RenderTargetTexture {
  73033. /**
  73034. * Creates a multiview render target
  73035. * @param scene scene used with the render target
  73036. * @param size the size of the render target (used for each view)
  73037. */
  73038. constructor(scene: Scene, size?: number | {
  73039. width: number;
  73040. height: number;
  73041. } | {
  73042. ratio: number;
  73043. });
  73044. /**
  73045. * @hidden
  73046. * @param faceIndex the face index, if its a cube texture
  73047. */
  73048. _bindFrameBuffer(faceIndex?: number): void;
  73049. /**
  73050. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  73051. * @returns the view count
  73052. */
  73053. getViewCount(): number;
  73054. }
  73055. }
  73056. declare module BABYLON {
  73057. interface Engine {
  73058. /**
  73059. * Creates a new multiview render target
  73060. * @param width defines the width of the texture
  73061. * @param height defines the height of the texture
  73062. * @returns the created multiview texture
  73063. */
  73064. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  73065. /**
  73066. * Binds a multiview framebuffer to be drawn to
  73067. * @param multiviewTexture texture to bind
  73068. */
  73069. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  73070. }
  73071. interface Camera {
  73072. /**
  73073. * @hidden
  73074. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  73075. */
  73076. _useMultiviewToSingleView: boolean;
  73077. /**
  73078. * @hidden
  73079. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  73080. */
  73081. _multiviewTexture: Nullable<RenderTargetTexture>;
  73082. /**
  73083. * @hidden
  73084. * ensures the multiview texture of the camera exists and has the specified width/height
  73085. * @param width height to set on the multiview texture
  73086. * @param height width to set on the multiview texture
  73087. */
  73088. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  73089. }
  73090. interface Scene {
  73091. /** @hidden */
  73092. _transformMatrixR: Matrix;
  73093. /** @hidden */
  73094. _multiviewSceneUbo: Nullable<UniformBuffer>;
  73095. /** @hidden */
  73096. _createMultiviewUbo(): void;
  73097. /** @hidden */
  73098. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  73099. /** @hidden */
  73100. _renderMultiviewToSingleView(camera: Camera): void;
  73101. }
  73102. }
  73103. declare module BABYLON {
  73104. /**
  73105. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  73106. * This will not be used for webXR as it supports displaying texture arrays directly
  73107. */
  73108. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  73109. /**
  73110. * Initializes a VRMultiviewToSingleview
  73111. * @param name name of the post process
  73112. * @param camera camera to be applied to
  73113. * @param scaleFactor scaling factor to the size of the output texture
  73114. */
  73115. constructor(name: string, camera: Camera, scaleFactor: number);
  73116. }
  73117. }
  73118. declare module BABYLON {
  73119. /**
  73120. * Defines the interface used by display changed events
  73121. */
  73122. interface IDisplayChangedEventArgs {
  73123. /** Gets the vrDisplay object (if any) */
  73124. vrDisplay: Nullable<any>;
  73125. /** Gets a boolean indicating if webVR is supported */
  73126. vrSupported: boolean;
  73127. }
  73128. interface Engine {
  73129. /** @hidden */
  73130. _vrDisplay: any;
  73131. /** @hidden */
  73132. _vrSupported: boolean;
  73133. /** @hidden */
  73134. _oldSize: Size;
  73135. /** @hidden */
  73136. _oldHardwareScaleFactor: number;
  73137. /** @hidden */
  73138. _vrExclusivePointerMode: boolean;
  73139. /** @hidden */
  73140. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  73141. /** @hidden */
  73142. _onVRDisplayPointerRestricted: () => void;
  73143. /** @hidden */
  73144. _onVRDisplayPointerUnrestricted: () => void;
  73145. /** @hidden */
  73146. _onVrDisplayConnect: Nullable<(display: any) => void>;
  73147. /** @hidden */
  73148. _onVrDisplayDisconnect: Nullable<() => void>;
  73149. /** @hidden */
  73150. _onVrDisplayPresentChange: Nullable<() => void>;
  73151. /**
  73152. * Observable signaled when VR display mode changes
  73153. */
  73154. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  73155. /**
  73156. * Observable signaled when VR request present is complete
  73157. */
  73158. onVRRequestPresentComplete: Observable<boolean>;
  73159. /**
  73160. * Observable signaled when VR request present starts
  73161. */
  73162. onVRRequestPresentStart: Observable<Engine>;
  73163. /**
  73164. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  73165. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  73166. */
  73167. isInVRExclusivePointerMode: boolean;
  73168. /**
  73169. * Gets a boolean indicating if a webVR device was detected
  73170. * @returns true if a webVR device was detected
  73171. */
  73172. isVRDevicePresent(): boolean;
  73173. /**
  73174. * Gets the current webVR device
  73175. * @returns the current webVR device (or null)
  73176. */
  73177. getVRDevice(): any;
  73178. /**
  73179. * Initializes a webVR display and starts listening to display change events
  73180. * The onVRDisplayChangedObservable will be notified upon these changes
  73181. * @returns A promise containing a VRDisplay and if vr is supported
  73182. */
  73183. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  73184. /** @hidden */
  73185. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  73186. /**
  73187. * Call this function to switch to webVR mode
  73188. * Will do nothing if webVR is not supported or if there is no webVR device
  73189. * @see http://doc.babylonjs.com/how_to/webvr_camera
  73190. */
  73191. enableVR(): void;
  73192. /** @hidden */
  73193. _onVRFullScreenTriggered(): void;
  73194. }
  73195. }
  73196. declare module BABYLON {
  73197. /**
  73198. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  73199. * IMPORTANT!! The data is right-hand data.
  73200. * @export
  73201. * @interface DevicePose
  73202. */
  73203. export interface DevicePose {
  73204. /**
  73205. * The position of the device, values in array are [x,y,z].
  73206. */
  73207. readonly position: Nullable<Float32Array>;
  73208. /**
  73209. * The linearVelocity of the device, values in array are [x,y,z].
  73210. */
  73211. readonly linearVelocity: Nullable<Float32Array>;
  73212. /**
  73213. * The linearAcceleration of the device, values in array are [x,y,z].
  73214. */
  73215. readonly linearAcceleration: Nullable<Float32Array>;
  73216. /**
  73217. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  73218. */
  73219. readonly orientation: Nullable<Float32Array>;
  73220. /**
  73221. * The angularVelocity of the device, values in array are [x,y,z].
  73222. */
  73223. readonly angularVelocity: Nullable<Float32Array>;
  73224. /**
  73225. * The angularAcceleration of the device, values in array are [x,y,z].
  73226. */
  73227. readonly angularAcceleration: Nullable<Float32Array>;
  73228. }
  73229. /**
  73230. * Interface representing a pose controlled object in Babylon.
  73231. * A pose controlled object has both regular pose values as well as pose values
  73232. * from an external device such as a VR head mounted display
  73233. */
  73234. export interface PoseControlled {
  73235. /**
  73236. * The position of the object in babylon space.
  73237. */
  73238. position: Vector3;
  73239. /**
  73240. * The rotation quaternion of the object in babylon space.
  73241. */
  73242. rotationQuaternion: Quaternion;
  73243. /**
  73244. * The position of the device in babylon space.
  73245. */
  73246. devicePosition?: Vector3;
  73247. /**
  73248. * The rotation quaternion of the device in babylon space.
  73249. */
  73250. deviceRotationQuaternion: Quaternion;
  73251. /**
  73252. * The raw pose coming from the device.
  73253. */
  73254. rawPose: Nullable<DevicePose>;
  73255. /**
  73256. * The scale of the device to be used when translating from device space to babylon space.
  73257. */
  73258. deviceScaleFactor: number;
  73259. /**
  73260. * Updates the poseControlled values based on the input device pose.
  73261. * @param poseData the pose data to update the object with
  73262. */
  73263. updateFromDevice(poseData: DevicePose): void;
  73264. }
  73265. /**
  73266. * Set of options to customize the webVRCamera
  73267. */
  73268. export interface WebVROptions {
  73269. /**
  73270. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  73271. */
  73272. trackPosition?: boolean;
  73273. /**
  73274. * Sets the scale of the vrDevice in babylon space. (default: 1)
  73275. */
  73276. positionScale?: number;
  73277. /**
  73278. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  73279. */
  73280. displayName?: string;
  73281. /**
  73282. * Should the native controller meshes be initialized. (default: true)
  73283. */
  73284. controllerMeshes?: boolean;
  73285. /**
  73286. * Creating a default HemiLight only on controllers. (default: true)
  73287. */
  73288. defaultLightingOnControllers?: boolean;
  73289. /**
  73290. * If you don't want to use the default VR button of the helper. (default: false)
  73291. */
  73292. useCustomVRButton?: boolean;
  73293. /**
  73294. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  73295. */
  73296. customVRButton?: HTMLButtonElement;
  73297. /**
  73298. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  73299. */
  73300. rayLength?: number;
  73301. /**
  73302. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  73303. */
  73304. defaultHeight?: number;
  73305. /**
  73306. * If multiview should be used if availible (default: false)
  73307. */
  73308. useMultiview?: boolean;
  73309. }
  73310. /**
  73311. * This represents a WebVR camera.
  73312. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  73313. * @example http://doc.babylonjs.com/how_to/webvr_camera
  73314. */
  73315. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  73316. private webVROptions;
  73317. /**
  73318. * @hidden
  73319. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  73320. */
  73321. _vrDevice: any;
  73322. /**
  73323. * The rawPose of the vrDevice.
  73324. */
  73325. rawPose: Nullable<DevicePose>;
  73326. private _onVREnabled;
  73327. private _specsVersion;
  73328. private _attached;
  73329. private _frameData;
  73330. protected _descendants: Array<Node>;
  73331. private _deviceRoomPosition;
  73332. /** @hidden */
  73333. _deviceRoomRotationQuaternion: Quaternion;
  73334. private _standingMatrix;
  73335. /**
  73336. * Represents device position in babylon space.
  73337. */
  73338. devicePosition: Vector3;
  73339. /**
  73340. * Represents device rotation in babylon space.
  73341. */
  73342. deviceRotationQuaternion: Quaternion;
  73343. /**
  73344. * The scale of the device to be used when translating from device space to babylon space.
  73345. */
  73346. deviceScaleFactor: number;
  73347. private _deviceToWorld;
  73348. private _worldToDevice;
  73349. /**
  73350. * References to the webVR controllers for the vrDevice.
  73351. */
  73352. controllers: Array<WebVRController>;
  73353. /**
  73354. * Emits an event when a controller is attached.
  73355. */
  73356. onControllersAttachedObservable: Observable<WebVRController[]>;
  73357. /**
  73358. * Emits an event when a controller's mesh has been loaded;
  73359. */
  73360. onControllerMeshLoadedObservable: Observable<WebVRController>;
  73361. /**
  73362. * Emits an event when the HMD's pose has been updated.
  73363. */
  73364. onPoseUpdatedFromDeviceObservable: Observable<any>;
  73365. private _poseSet;
  73366. /**
  73367. * If the rig cameras be used as parent instead of this camera.
  73368. */
  73369. rigParenting: boolean;
  73370. private _lightOnControllers;
  73371. private _defaultHeight?;
  73372. /**
  73373. * Instantiates a WebVRFreeCamera.
  73374. * @param name The name of the WebVRFreeCamera
  73375. * @param position The starting anchor position for the camera
  73376. * @param scene The scene the camera belongs to
  73377. * @param webVROptions a set of customizable options for the webVRCamera
  73378. */
  73379. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  73380. /**
  73381. * Gets the device distance from the ground in meters.
  73382. * @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.
  73383. */
  73384. deviceDistanceToRoomGround(): number;
  73385. /**
  73386. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73387. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  73388. */
  73389. useStandingMatrix(callback?: (bool: boolean) => void): void;
  73390. /**
  73391. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73392. * @returns A promise with a boolean set to if the standing matrix is supported.
  73393. */
  73394. useStandingMatrixAsync(): Promise<boolean>;
  73395. /**
  73396. * Disposes the camera
  73397. */
  73398. dispose(): void;
  73399. /**
  73400. * Gets a vrController by name.
  73401. * @param name The name of the controller to retreive
  73402. * @returns the controller matching the name specified or null if not found
  73403. */
  73404. getControllerByName(name: string): Nullable<WebVRController>;
  73405. private _leftController;
  73406. /**
  73407. * The controller corrisponding to the users left hand.
  73408. */
  73409. readonly leftController: Nullable<WebVRController>;
  73410. private _rightController;
  73411. /**
  73412. * The controller corrisponding to the users right hand.
  73413. */
  73414. readonly rightController: Nullable<WebVRController>;
  73415. /**
  73416. * Casts a ray forward from the vrCamera's gaze.
  73417. * @param length Length of the ray (default: 100)
  73418. * @returns the ray corrisponding to the gaze
  73419. */
  73420. getForwardRay(length?: number): Ray;
  73421. /**
  73422. * @hidden
  73423. * Updates the camera based on device's frame data
  73424. */
  73425. _checkInputs(): void;
  73426. /**
  73427. * Updates the poseControlled values based on the input device pose.
  73428. * @param poseData Pose coming from the device
  73429. */
  73430. updateFromDevice(poseData: DevicePose): void;
  73431. private _htmlElementAttached;
  73432. private _detachIfAttached;
  73433. /**
  73434. * WebVR's attach control will start broadcasting frames to the device.
  73435. * Note that in certain browsers (chrome for example) this function must be called
  73436. * within a user-interaction callback. Example:
  73437. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  73438. *
  73439. * @param element html element to attach the vrDevice to
  73440. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  73441. */
  73442. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73443. /**
  73444. * Detaches the camera from the html element and disables VR
  73445. *
  73446. * @param element html element to detach from
  73447. */
  73448. detachControl(element: HTMLElement): void;
  73449. /**
  73450. * @returns the name of this class
  73451. */
  73452. getClassName(): string;
  73453. /**
  73454. * Calls resetPose on the vrDisplay
  73455. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  73456. */
  73457. resetToCurrentRotation(): void;
  73458. /**
  73459. * @hidden
  73460. * Updates the rig cameras (left and right eye)
  73461. */
  73462. _updateRigCameras(): void;
  73463. private _workingVector;
  73464. private _oneVector;
  73465. private _workingMatrix;
  73466. private updateCacheCalled;
  73467. private _correctPositionIfNotTrackPosition;
  73468. /**
  73469. * @hidden
  73470. * Updates the cached values of the camera
  73471. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  73472. */
  73473. _updateCache(ignoreParentClass?: boolean): void;
  73474. /**
  73475. * @hidden
  73476. * Get current device position in babylon world
  73477. */
  73478. _computeDevicePosition(): void;
  73479. /**
  73480. * Updates the current device position and rotation in the babylon world
  73481. */
  73482. update(): void;
  73483. /**
  73484. * @hidden
  73485. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  73486. * @returns an identity matrix
  73487. */
  73488. _getViewMatrix(): Matrix;
  73489. private _tmpMatrix;
  73490. /**
  73491. * This function is called by the two RIG cameras.
  73492. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  73493. * @hidden
  73494. */
  73495. _getWebVRViewMatrix(): Matrix;
  73496. /** @hidden */
  73497. _getWebVRProjectionMatrix(): Matrix;
  73498. private _onGamepadConnectedObserver;
  73499. private _onGamepadDisconnectedObserver;
  73500. private _updateCacheWhenTrackingDisabledObserver;
  73501. /**
  73502. * Initializes the controllers and their meshes
  73503. */
  73504. initControllers(): void;
  73505. }
  73506. }
  73507. declare module BABYLON {
  73508. /**
  73509. * Size options for a post process
  73510. */
  73511. export type PostProcessOptions = {
  73512. width: number;
  73513. height: number;
  73514. };
  73515. /**
  73516. * PostProcess can be used to apply a shader to a texture after it has been rendered
  73517. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73518. */
  73519. export class PostProcess {
  73520. /** Name of the PostProcess. */
  73521. name: string;
  73522. /**
  73523. * Gets or sets the unique id of the post process
  73524. */
  73525. uniqueId: number;
  73526. /**
  73527. * Width of the texture to apply the post process on
  73528. */
  73529. width: number;
  73530. /**
  73531. * Height of the texture to apply the post process on
  73532. */
  73533. height: number;
  73534. /**
  73535. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  73536. * @hidden
  73537. */
  73538. _outputTexture: Nullable<InternalTexture>;
  73539. /**
  73540. * Sampling mode used by the shader
  73541. * See https://doc.babylonjs.com/classes/3.1/texture
  73542. */
  73543. renderTargetSamplingMode: number;
  73544. /**
  73545. * Clear color to use when screen clearing
  73546. */
  73547. clearColor: Color4;
  73548. /**
  73549. * If the buffer needs to be cleared before applying the post process. (default: true)
  73550. * Should be set to false if shader will overwrite all previous pixels.
  73551. */
  73552. autoClear: boolean;
  73553. /**
  73554. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  73555. */
  73556. alphaMode: number;
  73557. /**
  73558. * Sets the setAlphaBlendConstants of the babylon engine
  73559. */
  73560. alphaConstants: Color4;
  73561. /**
  73562. * Animations to be used for the post processing
  73563. */
  73564. animations: Animation[];
  73565. /**
  73566. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  73567. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  73568. */
  73569. enablePixelPerfectMode: boolean;
  73570. /**
  73571. * Force the postprocess to be applied without taking in account viewport
  73572. */
  73573. forceFullscreenViewport: boolean;
  73574. /**
  73575. * List of inspectable custom properties (used by the Inspector)
  73576. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73577. */
  73578. inspectableCustomProperties: IInspectable[];
  73579. /**
  73580. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  73581. *
  73582. * | Value | Type | Description |
  73583. * | ----- | ----------------------------------- | ----------- |
  73584. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  73585. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  73586. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  73587. *
  73588. */
  73589. scaleMode: number;
  73590. /**
  73591. * Force textures to be a power of two (default: false)
  73592. */
  73593. alwaysForcePOT: boolean;
  73594. private _samples;
  73595. /**
  73596. * Number of sample textures (default: 1)
  73597. */
  73598. samples: number;
  73599. /**
  73600. * Modify the scale of the post process to be the same as the viewport (default: false)
  73601. */
  73602. adaptScaleToCurrentViewport: boolean;
  73603. private _camera;
  73604. private _scene;
  73605. private _engine;
  73606. private _options;
  73607. private _reusable;
  73608. private _textureType;
  73609. /**
  73610. * Smart array of input and output textures for the post process.
  73611. * @hidden
  73612. */
  73613. _textures: SmartArray<InternalTexture>;
  73614. /**
  73615. * The index in _textures that corresponds to the output texture.
  73616. * @hidden
  73617. */
  73618. _currentRenderTextureInd: number;
  73619. private _effect;
  73620. private _samplers;
  73621. private _fragmentUrl;
  73622. private _vertexUrl;
  73623. private _parameters;
  73624. private _scaleRatio;
  73625. protected _indexParameters: any;
  73626. private _shareOutputWithPostProcess;
  73627. private _texelSize;
  73628. private _forcedOutputTexture;
  73629. /**
  73630. * Returns the fragment url or shader name used in the post process.
  73631. * @returns the fragment url or name in the shader store.
  73632. */
  73633. getEffectName(): string;
  73634. /**
  73635. * An event triggered when the postprocess is activated.
  73636. */
  73637. onActivateObservable: Observable<Camera>;
  73638. private _onActivateObserver;
  73639. /**
  73640. * A function that is added to the onActivateObservable
  73641. */
  73642. onActivate: Nullable<(camera: Camera) => void>;
  73643. /**
  73644. * An event triggered when the postprocess changes its size.
  73645. */
  73646. onSizeChangedObservable: Observable<PostProcess>;
  73647. private _onSizeChangedObserver;
  73648. /**
  73649. * A function that is added to the onSizeChangedObservable
  73650. */
  73651. onSizeChanged: (postProcess: PostProcess) => void;
  73652. /**
  73653. * An event triggered when the postprocess applies its effect.
  73654. */
  73655. onApplyObservable: Observable<Effect>;
  73656. private _onApplyObserver;
  73657. /**
  73658. * A function that is added to the onApplyObservable
  73659. */
  73660. onApply: (effect: Effect) => void;
  73661. /**
  73662. * An event triggered before rendering the postprocess
  73663. */
  73664. onBeforeRenderObservable: Observable<Effect>;
  73665. private _onBeforeRenderObserver;
  73666. /**
  73667. * A function that is added to the onBeforeRenderObservable
  73668. */
  73669. onBeforeRender: (effect: Effect) => void;
  73670. /**
  73671. * An event triggered after rendering the postprocess
  73672. */
  73673. onAfterRenderObservable: Observable<Effect>;
  73674. private _onAfterRenderObserver;
  73675. /**
  73676. * A function that is added to the onAfterRenderObservable
  73677. */
  73678. onAfterRender: (efect: Effect) => void;
  73679. /**
  73680. * 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
  73681. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  73682. */
  73683. inputTexture: InternalTexture;
  73684. /**
  73685. * Gets the camera which post process is applied to.
  73686. * @returns The camera the post process is applied to.
  73687. */
  73688. getCamera(): Camera;
  73689. /**
  73690. * Gets the texel size of the postprocess.
  73691. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  73692. */
  73693. readonly texelSize: Vector2;
  73694. /**
  73695. * Creates a new instance PostProcess
  73696. * @param name The name of the PostProcess.
  73697. * @param fragmentUrl The url of the fragment shader to be used.
  73698. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  73699. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  73700. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  73701. * @param camera The camera to apply the render pass to.
  73702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73703. * @param engine The engine which the post process will be applied. (default: current engine)
  73704. * @param reusable If the post process can be reused on the same frame. (default: false)
  73705. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  73706. * @param textureType Type of textures used when performing the post process. (default: 0)
  73707. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  73708. * @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
  73709. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  73710. */
  73711. constructor(
  73712. /** Name of the PostProcess. */
  73713. 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);
  73714. /**
  73715. * Gets a string idenfifying the name of the class
  73716. * @returns "PostProcess" string
  73717. */
  73718. getClassName(): string;
  73719. /**
  73720. * Gets the engine which this post process belongs to.
  73721. * @returns The engine the post process was enabled with.
  73722. */
  73723. getEngine(): Engine;
  73724. /**
  73725. * The effect that is created when initializing the post process.
  73726. * @returns The created effect corrisponding the the postprocess.
  73727. */
  73728. getEffect(): Effect;
  73729. /**
  73730. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  73731. * @param postProcess The post process to share the output with.
  73732. * @returns This post process.
  73733. */
  73734. shareOutputWith(postProcess: PostProcess): PostProcess;
  73735. /**
  73736. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  73737. * This should be called if the post process that shares output with this post process is disabled/disposed.
  73738. */
  73739. useOwnOutput(): void;
  73740. /**
  73741. * Updates the effect with the current post process compile time values and recompiles the shader.
  73742. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73743. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73744. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73745. * @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
  73746. * @param onCompiled Called when the shader has been compiled.
  73747. * @param onError Called if there is an error when compiling a shader.
  73748. */
  73749. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73750. /**
  73751. * The post process is reusable if it can be used multiple times within one frame.
  73752. * @returns If the post process is reusable
  73753. */
  73754. isReusable(): boolean;
  73755. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  73756. markTextureDirty(): void;
  73757. /**
  73758. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  73759. * 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.
  73760. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  73761. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  73762. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  73763. * @returns The target texture that was bound to be written to.
  73764. */
  73765. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73766. /**
  73767. * If the post process is supported.
  73768. */
  73769. readonly isSupported: boolean;
  73770. /**
  73771. * The aspect ratio of the output texture.
  73772. */
  73773. readonly aspectRatio: number;
  73774. /**
  73775. * Get a value indicating if the post-process is ready to be used
  73776. * @returns true if the post-process is ready (shader is compiled)
  73777. */
  73778. isReady(): boolean;
  73779. /**
  73780. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73781. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73782. */
  73783. apply(): Nullable<Effect>;
  73784. private _disposeTextures;
  73785. /**
  73786. * Disposes the post process.
  73787. * @param camera The camera to dispose the post process on.
  73788. */
  73789. dispose(camera?: Camera): void;
  73790. }
  73791. }
  73792. declare module BABYLON {
  73793. /**
  73794. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73795. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73796. */
  73797. export class PostProcessManager {
  73798. private _scene;
  73799. private _indexBuffer;
  73800. private _vertexBuffers;
  73801. /**
  73802. * Creates a new instance PostProcess
  73803. * @param scene The scene that the post process is associated with.
  73804. */
  73805. constructor(scene: Scene);
  73806. private _prepareBuffers;
  73807. private _buildIndexBuffer;
  73808. /**
  73809. * Rebuilds the vertex buffers of the manager.
  73810. * @hidden
  73811. */
  73812. _rebuild(): void;
  73813. /**
  73814. * Prepares a frame to be run through a post process.
  73815. * @param sourceTexture The input texture to the post procesess. (default: null)
  73816. * @param postProcesses An array of post processes to be run. (default: null)
  73817. * @returns True if the post processes were able to be run.
  73818. * @hidden
  73819. */
  73820. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73821. /**
  73822. * Manually render a set of post processes to a texture.
  73823. * @param postProcesses An array of post processes to be run.
  73824. * @param targetTexture The target texture to render to.
  73825. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73826. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73827. * @param lodLevel defines which lod of the texture to render to
  73828. */
  73829. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73830. /**
  73831. * Finalize the result of the output of the postprocesses.
  73832. * @param doNotPresent If true the result will not be displayed to the screen.
  73833. * @param targetTexture The target texture to render to.
  73834. * @param faceIndex The index of the face to bind the target texture to.
  73835. * @param postProcesses The array of post processes to render.
  73836. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73837. * @hidden
  73838. */
  73839. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73840. /**
  73841. * Disposes of the post process manager.
  73842. */
  73843. dispose(): void;
  73844. }
  73845. }
  73846. declare module BABYLON {
  73847. interface AbstractScene {
  73848. /**
  73849. * The list of layers (background and foreground) of the scene
  73850. */
  73851. layers: Array<Layer>;
  73852. }
  73853. /**
  73854. * Defines the layer scene component responsible to manage any layers
  73855. * in a given scene.
  73856. */
  73857. export class LayerSceneComponent implements ISceneComponent {
  73858. /**
  73859. * The component name helpfull to identify the component in the list of scene components.
  73860. */
  73861. readonly name: string;
  73862. /**
  73863. * The scene the component belongs to.
  73864. */
  73865. scene: Scene;
  73866. private _engine;
  73867. /**
  73868. * Creates a new instance of the component for the given scene
  73869. * @param scene Defines the scene to register the component in
  73870. */
  73871. constructor(scene: Scene);
  73872. /**
  73873. * Registers the component in a given scene
  73874. */
  73875. register(): void;
  73876. /**
  73877. * Rebuilds the elements related to this component in case of
  73878. * context lost for instance.
  73879. */
  73880. rebuild(): void;
  73881. /**
  73882. * Disposes the component and the associated ressources.
  73883. */
  73884. dispose(): void;
  73885. private _draw;
  73886. private _drawCameraPredicate;
  73887. private _drawCameraBackground;
  73888. private _drawCameraForeground;
  73889. private _drawRenderTargetPredicate;
  73890. private _drawRenderTargetBackground;
  73891. private _drawRenderTargetForeground;
  73892. }
  73893. }
  73894. declare module BABYLON {
  73895. /** @hidden */
  73896. export var layerPixelShader: {
  73897. name: string;
  73898. shader: string;
  73899. };
  73900. }
  73901. declare module BABYLON {
  73902. /** @hidden */
  73903. export var layerVertexShader: {
  73904. name: string;
  73905. shader: string;
  73906. };
  73907. }
  73908. declare module BABYLON {
  73909. /**
  73910. * This represents a full screen 2d layer.
  73911. * This can be useful to display a picture in the background of your scene for instance.
  73912. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73913. */
  73914. export class Layer {
  73915. /**
  73916. * Define the name of the layer.
  73917. */
  73918. name: string;
  73919. /**
  73920. * Define the texture the layer should display.
  73921. */
  73922. texture: Nullable<Texture>;
  73923. /**
  73924. * Is the layer in background or foreground.
  73925. */
  73926. isBackground: boolean;
  73927. /**
  73928. * Define the color of the layer (instead of texture).
  73929. */
  73930. color: Color4;
  73931. /**
  73932. * Define the scale of the layer in order to zoom in out of the texture.
  73933. */
  73934. scale: Vector2;
  73935. /**
  73936. * Define an offset for the layer in order to shift the texture.
  73937. */
  73938. offset: Vector2;
  73939. /**
  73940. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73941. */
  73942. alphaBlendingMode: number;
  73943. /**
  73944. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73945. * Alpha test will not mix with the background color in case of transparency.
  73946. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73947. */
  73948. alphaTest: boolean;
  73949. /**
  73950. * Define a mask to restrict the layer to only some of the scene cameras.
  73951. */
  73952. layerMask: number;
  73953. /**
  73954. * Define the list of render target the layer is visible into.
  73955. */
  73956. renderTargetTextures: RenderTargetTexture[];
  73957. /**
  73958. * Define if the layer is only used in renderTarget or if it also
  73959. * renders in the main frame buffer of the canvas.
  73960. */
  73961. renderOnlyInRenderTargetTextures: boolean;
  73962. private _scene;
  73963. private _vertexBuffers;
  73964. private _indexBuffer;
  73965. private _effect;
  73966. private _alphaTestEffect;
  73967. /**
  73968. * An event triggered when the layer is disposed.
  73969. */
  73970. onDisposeObservable: Observable<Layer>;
  73971. private _onDisposeObserver;
  73972. /**
  73973. * Back compatibility with callback before the onDisposeObservable existed.
  73974. * The set callback will be triggered when the layer has been disposed.
  73975. */
  73976. onDispose: () => void;
  73977. /**
  73978. * An event triggered before rendering the scene
  73979. */
  73980. onBeforeRenderObservable: Observable<Layer>;
  73981. private _onBeforeRenderObserver;
  73982. /**
  73983. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73984. * The set callback will be triggered just before rendering the layer.
  73985. */
  73986. onBeforeRender: () => void;
  73987. /**
  73988. * An event triggered after rendering the scene
  73989. */
  73990. onAfterRenderObservable: Observable<Layer>;
  73991. private _onAfterRenderObserver;
  73992. /**
  73993. * Back compatibility with callback before the onAfterRenderObservable existed.
  73994. * The set callback will be triggered just after rendering the layer.
  73995. */
  73996. onAfterRender: () => void;
  73997. /**
  73998. * Instantiates a new layer.
  73999. * This represents a full screen 2d layer.
  74000. * This can be useful to display a picture in the background of your scene for instance.
  74001. * @see https://www.babylonjs-playground.com/#08A2BS#1
  74002. * @param name Define the name of the layer in the scene
  74003. * @param imgUrl Define the url of the texture to display in the layer
  74004. * @param scene Define the scene the layer belongs to
  74005. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  74006. * @param color Defines a color for the layer
  74007. */
  74008. constructor(
  74009. /**
  74010. * Define the name of the layer.
  74011. */
  74012. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  74013. private _createIndexBuffer;
  74014. /** @hidden */
  74015. _rebuild(): void;
  74016. /**
  74017. * Renders the layer in the scene.
  74018. */
  74019. render(): void;
  74020. /**
  74021. * Disposes and releases the associated ressources.
  74022. */
  74023. dispose(): void;
  74024. }
  74025. }
  74026. declare module BABYLON {
  74027. interface AbstractScene {
  74028. /**
  74029. * The list of procedural textures added to the scene
  74030. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74031. */
  74032. proceduralTextures: Array<ProceduralTexture>;
  74033. }
  74034. /**
  74035. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  74036. * in a given scene.
  74037. */
  74038. export class ProceduralTextureSceneComponent implements ISceneComponent {
  74039. /**
  74040. * The component name helpfull to identify the component in the list of scene components.
  74041. */
  74042. readonly name: string;
  74043. /**
  74044. * The scene the component belongs to.
  74045. */
  74046. scene: Scene;
  74047. /**
  74048. * Creates a new instance of the component for the given scene
  74049. * @param scene Defines the scene to register the component in
  74050. */
  74051. constructor(scene: Scene);
  74052. /**
  74053. * Registers the component in a given scene
  74054. */
  74055. register(): void;
  74056. /**
  74057. * Rebuilds the elements related to this component in case of
  74058. * context lost for instance.
  74059. */
  74060. rebuild(): void;
  74061. /**
  74062. * Disposes the component and the associated ressources.
  74063. */
  74064. dispose(): void;
  74065. private _beforeClear;
  74066. }
  74067. }
  74068. declare module BABYLON {
  74069. interface Engine {
  74070. /**
  74071. * Creates a new render target cube texture
  74072. * @param size defines the size of the texture
  74073. * @param options defines the options used to create the texture
  74074. * @returns a new render target cube texture stored in an InternalTexture
  74075. */
  74076. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  74077. }
  74078. }
  74079. declare module BABYLON {
  74080. /** @hidden */
  74081. export var proceduralVertexShader: {
  74082. name: string;
  74083. shader: string;
  74084. };
  74085. }
  74086. declare module BABYLON {
  74087. /**
  74088. * 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.
  74089. * This is the base class of any Procedural texture and contains most of the shareable code.
  74090. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74091. */
  74092. export class ProceduralTexture extends Texture {
  74093. isCube: boolean;
  74094. /**
  74095. * Define if the texture is enabled or not (disabled texture will not render)
  74096. */
  74097. isEnabled: boolean;
  74098. /**
  74099. * Define if the texture must be cleared before rendering (default is true)
  74100. */
  74101. autoClear: boolean;
  74102. /**
  74103. * Callback called when the texture is generated
  74104. */
  74105. onGenerated: () => void;
  74106. /**
  74107. * Event raised when the texture is generated
  74108. */
  74109. onGeneratedObservable: Observable<ProceduralTexture>;
  74110. /** @hidden */
  74111. _generateMipMaps: boolean;
  74112. /** @hidden **/
  74113. _effect: Effect;
  74114. /** @hidden */
  74115. _textures: {
  74116. [key: string]: Texture;
  74117. };
  74118. private _size;
  74119. private _currentRefreshId;
  74120. private _refreshRate;
  74121. private _vertexBuffers;
  74122. private _indexBuffer;
  74123. private _uniforms;
  74124. private _samplers;
  74125. private _fragment;
  74126. private _floats;
  74127. private _ints;
  74128. private _floatsArrays;
  74129. private _colors3;
  74130. private _colors4;
  74131. private _vectors2;
  74132. private _vectors3;
  74133. private _matrices;
  74134. private _fallbackTexture;
  74135. private _fallbackTextureUsed;
  74136. private _engine;
  74137. private _cachedDefines;
  74138. private _contentUpdateId;
  74139. private _contentData;
  74140. /**
  74141. * Instantiates a new procedural texture.
  74142. * 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.
  74143. * This is the base class of any Procedural texture and contains most of the shareable code.
  74144. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74145. * @param name Define the name of the texture
  74146. * @param size Define the size of the texture to create
  74147. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  74148. * @param scene Define the scene the texture belongs to
  74149. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  74150. * @param generateMipMaps Define if the texture should creates mip maps or not
  74151. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  74152. */
  74153. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  74154. /**
  74155. * The effect that is created when initializing the post process.
  74156. * @returns The created effect corrisponding the the postprocess.
  74157. */
  74158. getEffect(): Effect;
  74159. /**
  74160. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  74161. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  74162. */
  74163. getContent(): Nullable<ArrayBufferView>;
  74164. private _createIndexBuffer;
  74165. /** @hidden */
  74166. _rebuild(): void;
  74167. /**
  74168. * Resets the texture in order to recreate its associated resources.
  74169. * This can be called in case of context loss
  74170. */
  74171. reset(): void;
  74172. protected _getDefines(): string;
  74173. /**
  74174. * Is the texture ready to be used ? (rendered at least once)
  74175. * @returns true if ready, otherwise, false.
  74176. */
  74177. isReady(): boolean;
  74178. /**
  74179. * Resets the refresh counter of the texture and start bak from scratch.
  74180. * Could be useful to regenerate the texture if it is setup to render only once.
  74181. */
  74182. resetRefreshCounter(): void;
  74183. /**
  74184. * Set the fragment shader to use in order to render the texture.
  74185. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  74186. */
  74187. setFragment(fragment: any): void;
  74188. /**
  74189. * Define the refresh rate of the texture or the rendering frequency.
  74190. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74191. */
  74192. refreshRate: number;
  74193. /** @hidden */
  74194. _shouldRender(): boolean;
  74195. /**
  74196. * Get the size the texture is rendering at.
  74197. * @returns the size (texture is always squared)
  74198. */
  74199. getRenderSize(): number;
  74200. /**
  74201. * Resize the texture to new value.
  74202. * @param size Define the new size the texture should have
  74203. * @param generateMipMaps Define whether the new texture should create mip maps
  74204. */
  74205. resize(size: number, generateMipMaps: boolean): void;
  74206. private _checkUniform;
  74207. /**
  74208. * Set a texture in the shader program used to render.
  74209. * @param name Define the name of the uniform samplers as defined in the shader
  74210. * @param texture Define the texture to bind to this sampler
  74211. * @return the texture itself allowing "fluent" like uniform updates
  74212. */
  74213. setTexture(name: string, texture: Texture): ProceduralTexture;
  74214. /**
  74215. * Set a float in the shader.
  74216. * @param name Define the name of the uniform as defined in the shader
  74217. * @param value Define the value to give to the uniform
  74218. * @return the texture itself allowing "fluent" like uniform updates
  74219. */
  74220. setFloat(name: string, value: number): ProceduralTexture;
  74221. /**
  74222. * Set a int in the shader.
  74223. * @param name Define the name of the uniform as defined in the shader
  74224. * @param value Define the value to give to the uniform
  74225. * @return the texture itself allowing "fluent" like uniform updates
  74226. */
  74227. setInt(name: string, value: number): ProceduralTexture;
  74228. /**
  74229. * Set an array of floats in the shader.
  74230. * @param name Define the name of the uniform as defined in the shader
  74231. * @param value Define the value to give to the uniform
  74232. * @return the texture itself allowing "fluent" like uniform updates
  74233. */
  74234. setFloats(name: string, value: number[]): ProceduralTexture;
  74235. /**
  74236. * Set a vec3 in the shader from a Color3.
  74237. * @param name Define the name of the uniform as defined in the shader
  74238. * @param value Define the value to give to the uniform
  74239. * @return the texture itself allowing "fluent" like uniform updates
  74240. */
  74241. setColor3(name: string, value: Color3): ProceduralTexture;
  74242. /**
  74243. * Set a vec4 in the shader from a Color4.
  74244. * @param name Define the name of the uniform as defined in the shader
  74245. * @param value Define the value to give to the uniform
  74246. * @return the texture itself allowing "fluent" like uniform updates
  74247. */
  74248. setColor4(name: string, value: Color4): ProceduralTexture;
  74249. /**
  74250. * Set a vec2 in the shader from a Vector2.
  74251. * @param name Define the name of the uniform as defined in the shader
  74252. * @param value Define the value to give to the uniform
  74253. * @return the texture itself allowing "fluent" like uniform updates
  74254. */
  74255. setVector2(name: string, value: Vector2): ProceduralTexture;
  74256. /**
  74257. * Set a vec3 in the shader from a Vector3.
  74258. * @param name Define the name of the uniform as defined in the shader
  74259. * @param value Define the value to give to the uniform
  74260. * @return the texture itself allowing "fluent" like uniform updates
  74261. */
  74262. setVector3(name: string, value: Vector3): ProceduralTexture;
  74263. /**
  74264. * Set a mat4 in the shader from a MAtrix.
  74265. * @param name Define the name of the uniform as defined in the shader
  74266. * @param value Define the value to give to the uniform
  74267. * @return the texture itself allowing "fluent" like uniform updates
  74268. */
  74269. setMatrix(name: string, value: Matrix): ProceduralTexture;
  74270. /**
  74271. * Render the texture to its associated render target.
  74272. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  74273. */
  74274. render(useCameraPostProcess?: boolean): void;
  74275. /**
  74276. * Clone the texture.
  74277. * @returns the cloned texture
  74278. */
  74279. clone(): ProceduralTexture;
  74280. /**
  74281. * Dispose the texture and release its asoociated resources.
  74282. */
  74283. dispose(): void;
  74284. }
  74285. }
  74286. declare module BABYLON {
  74287. /**
  74288. * This represents the base class for particle system in Babylon.
  74289. * 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.
  74290. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74291. * @example https://doc.babylonjs.com/babylon101/particles
  74292. */
  74293. export class BaseParticleSystem {
  74294. /**
  74295. * Source color is added to the destination color without alpha affecting the result
  74296. */
  74297. static BLENDMODE_ONEONE: number;
  74298. /**
  74299. * Blend current color and particle color using particle’s alpha
  74300. */
  74301. static BLENDMODE_STANDARD: number;
  74302. /**
  74303. * Add current color and particle color multiplied by particle’s alpha
  74304. */
  74305. static BLENDMODE_ADD: number;
  74306. /**
  74307. * Multiply current color with particle color
  74308. */
  74309. static BLENDMODE_MULTIPLY: number;
  74310. /**
  74311. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  74312. */
  74313. static BLENDMODE_MULTIPLYADD: number;
  74314. /**
  74315. * List of animations used by the particle system.
  74316. */
  74317. animations: Animation[];
  74318. /**
  74319. * The id of the Particle system.
  74320. */
  74321. id: string;
  74322. /**
  74323. * The friendly name of the Particle system.
  74324. */
  74325. name: string;
  74326. /**
  74327. * The rendering group used by the Particle system to chose when to render.
  74328. */
  74329. renderingGroupId: number;
  74330. /**
  74331. * The emitter represents the Mesh or position we are attaching the particle system to.
  74332. */
  74333. emitter: Nullable<AbstractMesh | Vector3>;
  74334. /**
  74335. * The maximum number of particles to emit per frame
  74336. */
  74337. emitRate: number;
  74338. /**
  74339. * If you want to launch only a few particles at once, that can be done, as well.
  74340. */
  74341. manualEmitCount: number;
  74342. /**
  74343. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74344. */
  74345. updateSpeed: number;
  74346. /**
  74347. * The amount of time the particle system is running (depends of the overall update speed).
  74348. */
  74349. targetStopDuration: number;
  74350. /**
  74351. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74352. */
  74353. disposeOnStop: boolean;
  74354. /**
  74355. * Minimum power of emitting particles.
  74356. */
  74357. minEmitPower: number;
  74358. /**
  74359. * Maximum power of emitting particles.
  74360. */
  74361. maxEmitPower: number;
  74362. /**
  74363. * Minimum life time of emitting particles.
  74364. */
  74365. minLifeTime: number;
  74366. /**
  74367. * Maximum life time of emitting particles.
  74368. */
  74369. maxLifeTime: number;
  74370. /**
  74371. * Minimum Size of emitting particles.
  74372. */
  74373. minSize: number;
  74374. /**
  74375. * Maximum Size of emitting particles.
  74376. */
  74377. maxSize: number;
  74378. /**
  74379. * Minimum scale of emitting particles on X axis.
  74380. */
  74381. minScaleX: number;
  74382. /**
  74383. * Maximum scale of emitting particles on X axis.
  74384. */
  74385. maxScaleX: number;
  74386. /**
  74387. * Minimum scale of emitting particles on Y axis.
  74388. */
  74389. minScaleY: number;
  74390. /**
  74391. * Maximum scale of emitting particles on Y axis.
  74392. */
  74393. maxScaleY: number;
  74394. /**
  74395. * Gets or sets the minimal initial rotation in radians.
  74396. */
  74397. minInitialRotation: number;
  74398. /**
  74399. * Gets or sets the maximal initial rotation in radians.
  74400. */
  74401. maxInitialRotation: number;
  74402. /**
  74403. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74404. */
  74405. minAngularSpeed: number;
  74406. /**
  74407. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74408. */
  74409. maxAngularSpeed: number;
  74410. /**
  74411. * The texture used to render each particle. (this can be a spritesheet)
  74412. */
  74413. particleTexture: Nullable<Texture>;
  74414. /**
  74415. * The layer mask we are rendering the particles through.
  74416. */
  74417. layerMask: number;
  74418. /**
  74419. * This can help using your own shader to render the particle system.
  74420. * The according effect will be created
  74421. */
  74422. customShader: any;
  74423. /**
  74424. * By default particle system starts as soon as they are created. This prevents the
  74425. * automatic start to happen and let you decide when to start emitting particles.
  74426. */
  74427. preventAutoStart: boolean;
  74428. private _noiseTexture;
  74429. /**
  74430. * Gets or sets a texture used to add random noise to particle positions
  74431. */
  74432. noiseTexture: Nullable<ProceduralTexture>;
  74433. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74434. noiseStrength: Vector3;
  74435. /**
  74436. * Callback triggered when the particle animation is ending.
  74437. */
  74438. onAnimationEnd: Nullable<() => void>;
  74439. /**
  74440. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  74441. */
  74442. blendMode: number;
  74443. /**
  74444. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  74445. * to override the particles.
  74446. */
  74447. forceDepthWrite: boolean;
  74448. /** 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 */
  74449. preWarmCycles: number;
  74450. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  74451. preWarmStepOffset: number;
  74452. /**
  74453. * 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)
  74454. */
  74455. spriteCellChangeSpeed: number;
  74456. /**
  74457. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74458. */
  74459. startSpriteCellID: number;
  74460. /**
  74461. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74462. */
  74463. endSpriteCellID: number;
  74464. /**
  74465. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74466. */
  74467. spriteCellWidth: number;
  74468. /**
  74469. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74470. */
  74471. spriteCellHeight: number;
  74472. /**
  74473. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74474. */
  74475. spriteRandomStartCell: boolean;
  74476. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74477. translationPivot: Vector2;
  74478. /** @hidden */
  74479. protected _isAnimationSheetEnabled: boolean;
  74480. /**
  74481. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74482. */
  74483. beginAnimationOnStart: boolean;
  74484. /**
  74485. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74486. */
  74487. beginAnimationFrom: number;
  74488. /**
  74489. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74490. */
  74491. beginAnimationTo: number;
  74492. /**
  74493. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74494. */
  74495. beginAnimationLoop: boolean;
  74496. /**
  74497. * Gets or sets a world offset applied to all particles
  74498. */
  74499. worldOffset: Vector3;
  74500. /**
  74501. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  74502. */
  74503. isAnimationSheetEnabled: boolean;
  74504. /**
  74505. * Get hosting scene
  74506. * @returns the scene
  74507. */
  74508. getScene(): Scene;
  74509. /**
  74510. * You can use gravity if you want to give an orientation to your particles.
  74511. */
  74512. gravity: Vector3;
  74513. protected _colorGradients: Nullable<Array<ColorGradient>>;
  74514. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  74515. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  74516. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  74517. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  74518. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  74519. protected _dragGradients: Nullable<Array<FactorGradient>>;
  74520. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  74521. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  74522. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  74523. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  74524. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  74525. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  74526. /**
  74527. * Defines the delay in milliseconds before starting the system (0 by default)
  74528. */
  74529. startDelay: number;
  74530. /**
  74531. * Gets the current list of drag gradients.
  74532. * You must use addDragGradient and removeDragGradient to udpate this list
  74533. * @returns the list of drag gradients
  74534. */
  74535. getDragGradients(): Nullable<Array<FactorGradient>>;
  74536. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74537. limitVelocityDamping: number;
  74538. /**
  74539. * Gets the current list of limit velocity gradients.
  74540. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74541. * @returns the list of limit velocity gradients
  74542. */
  74543. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74544. /**
  74545. * Gets the current list of color gradients.
  74546. * You must use addColorGradient and removeColorGradient to udpate this list
  74547. * @returns the list of color gradients
  74548. */
  74549. getColorGradients(): Nullable<Array<ColorGradient>>;
  74550. /**
  74551. * Gets the current list of size gradients.
  74552. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74553. * @returns the list of size gradients
  74554. */
  74555. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74556. /**
  74557. * Gets the current list of color remap gradients.
  74558. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74559. * @returns the list of color remap gradients
  74560. */
  74561. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74562. /**
  74563. * Gets the current list of alpha remap gradients.
  74564. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74565. * @returns the list of alpha remap gradients
  74566. */
  74567. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74568. /**
  74569. * Gets the current list of life time gradients.
  74570. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74571. * @returns the list of life time gradients
  74572. */
  74573. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74574. /**
  74575. * Gets the current list of angular speed gradients.
  74576. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74577. * @returns the list of angular speed gradients
  74578. */
  74579. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74580. /**
  74581. * Gets the current list of velocity gradients.
  74582. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74583. * @returns the list of velocity gradients
  74584. */
  74585. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74586. /**
  74587. * Gets the current list of start size gradients.
  74588. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74589. * @returns the list of start size gradients
  74590. */
  74591. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74592. /**
  74593. * Gets the current list of emit rate gradients.
  74594. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74595. * @returns the list of emit rate gradients
  74596. */
  74597. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74598. /**
  74599. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74600. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74601. */
  74602. direction1: Vector3;
  74603. /**
  74604. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74605. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74606. */
  74607. direction2: Vector3;
  74608. /**
  74609. * 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.
  74610. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74611. */
  74612. minEmitBox: Vector3;
  74613. /**
  74614. * 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.
  74615. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74616. */
  74617. maxEmitBox: Vector3;
  74618. /**
  74619. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74620. */
  74621. color1: Color4;
  74622. /**
  74623. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74624. */
  74625. color2: Color4;
  74626. /**
  74627. * Color the particle will have at the end of its lifetime
  74628. */
  74629. colorDead: Color4;
  74630. /**
  74631. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  74632. */
  74633. textureMask: Color4;
  74634. /**
  74635. * The particle emitter type defines the emitter used by the particle system.
  74636. * It can be for example box, sphere, or cone...
  74637. */
  74638. particleEmitterType: IParticleEmitterType;
  74639. /** @hidden */
  74640. _isSubEmitter: boolean;
  74641. /**
  74642. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74643. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74644. */
  74645. billboardMode: number;
  74646. protected _isBillboardBased: boolean;
  74647. /**
  74648. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74649. */
  74650. isBillboardBased: boolean;
  74651. /**
  74652. * The scene the particle system belongs to.
  74653. */
  74654. protected _scene: Scene;
  74655. /**
  74656. * Local cache of defines for image processing.
  74657. */
  74658. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  74659. /**
  74660. * Default configuration related to image processing available in the standard Material.
  74661. */
  74662. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  74663. /**
  74664. * Gets the image processing configuration used either in this material.
  74665. */
  74666. /**
  74667. * Sets the Default image processing configuration used either in the this material.
  74668. *
  74669. * If sets to null, the scene one is in use.
  74670. */
  74671. imageProcessingConfiguration: ImageProcessingConfiguration;
  74672. /**
  74673. * Attaches a new image processing configuration to the Standard Material.
  74674. * @param configuration
  74675. */
  74676. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  74677. /** @hidden */
  74678. protected _reset(): void;
  74679. /** @hidden */
  74680. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  74681. /**
  74682. * Instantiates a particle system.
  74683. * 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.
  74684. * @param name The name of the particle system
  74685. */
  74686. constructor(name: string);
  74687. /**
  74688. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74689. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74690. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74691. * @returns the emitter
  74692. */
  74693. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74694. /**
  74695. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74696. * @param radius The radius of the hemisphere to emit from
  74697. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74698. * @returns the emitter
  74699. */
  74700. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  74701. /**
  74702. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74703. * @param radius The radius of the sphere to emit from
  74704. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74705. * @returns the emitter
  74706. */
  74707. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  74708. /**
  74709. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74710. * @param radius The radius of the sphere to emit from
  74711. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74712. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74713. * @returns the emitter
  74714. */
  74715. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  74716. /**
  74717. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74718. * @param radius The radius of the emission cylinder
  74719. * @param height The height of the emission cylinder
  74720. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74721. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74722. * @returns the emitter
  74723. */
  74724. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  74725. /**
  74726. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74727. * @param radius The radius of the cylinder to emit from
  74728. * @param height The height of the emission cylinder
  74729. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74730. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74731. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74732. * @returns the emitter
  74733. */
  74734. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  74735. /**
  74736. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74737. * @param radius The radius of the cone to emit from
  74738. * @param angle The base angle of the cone
  74739. * @returns the emitter
  74740. */
  74741. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  74742. /**
  74743. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74744. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74745. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74746. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74747. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74748. * @returns the emitter
  74749. */
  74750. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74751. }
  74752. }
  74753. declare module BABYLON {
  74754. /**
  74755. * Type of sub emitter
  74756. */
  74757. export enum SubEmitterType {
  74758. /**
  74759. * Attached to the particle over it's lifetime
  74760. */
  74761. ATTACHED = 0,
  74762. /**
  74763. * Created when the particle dies
  74764. */
  74765. END = 1
  74766. }
  74767. /**
  74768. * Sub emitter class used to emit particles from an existing particle
  74769. */
  74770. export class SubEmitter {
  74771. /**
  74772. * the particle system to be used by the sub emitter
  74773. */
  74774. particleSystem: ParticleSystem;
  74775. /**
  74776. * Type of the submitter (Default: END)
  74777. */
  74778. type: SubEmitterType;
  74779. /**
  74780. * 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)
  74781. * Note: This only is supported when using an emitter of type Mesh
  74782. */
  74783. inheritDirection: boolean;
  74784. /**
  74785. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74786. */
  74787. inheritedVelocityAmount: number;
  74788. /**
  74789. * Creates a sub emitter
  74790. * @param particleSystem the particle system to be used by the sub emitter
  74791. */
  74792. constructor(
  74793. /**
  74794. * the particle system to be used by the sub emitter
  74795. */
  74796. particleSystem: ParticleSystem);
  74797. /**
  74798. * Clones the sub emitter
  74799. * @returns the cloned sub emitter
  74800. */
  74801. clone(): SubEmitter;
  74802. /**
  74803. * Serialize current object to a JSON object
  74804. * @returns the serialized object
  74805. */
  74806. serialize(): any;
  74807. /** @hidden */
  74808. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74809. /**
  74810. * Creates a new SubEmitter from a serialized JSON version
  74811. * @param serializationObject defines the JSON object to read from
  74812. * @param scene defines the hosting scene
  74813. * @param rootUrl defines the rootUrl for data loading
  74814. * @returns a new SubEmitter
  74815. */
  74816. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74817. /** Release associated resources */
  74818. dispose(): void;
  74819. }
  74820. }
  74821. declare module BABYLON {
  74822. /** @hidden */
  74823. export var clipPlaneFragmentDeclaration: {
  74824. name: string;
  74825. shader: string;
  74826. };
  74827. }
  74828. declare module BABYLON {
  74829. /** @hidden */
  74830. export var imageProcessingDeclaration: {
  74831. name: string;
  74832. shader: string;
  74833. };
  74834. }
  74835. declare module BABYLON {
  74836. /** @hidden */
  74837. export var imageProcessingFunctions: {
  74838. name: string;
  74839. shader: string;
  74840. };
  74841. }
  74842. declare module BABYLON {
  74843. /** @hidden */
  74844. export var clipPlaneFragment: {
  74845. name: string;
  74846. shader: string;
  74847. };
  74848. }
  74849. declare module BABYLON {
  74850. /** @hidden */
  74851. export var particlesPixelShader: {
  74852. name: string;
  74853. shader: string;
  74854. };
  74855. }
  74856. declare module BABYLON {
  74857. /** @hidden */
  74858. export var clipPlaneVertexDeclaration: {
  74859. name: string;
  74860. shader: string;
  74861. };
  74862. }
  74863. declare module BABYLON {
  74864. /** @hidden */
  74865. export var clipPlaneVertex: {
  74866. name: string;
  74867. shader: string;
  74868. };
  74869. }
  74870. declare module BABYLON {
  74871. /** @hidden */
  74872. export var particlesVertexShader: {
  74873. name: string;
  74874. shader: string;
  74875. };
  74876. }
  74877. declare module BABYLON {
  74878. /**
  74879. * This represents a particle system in Babylon.
  74880. * 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.
  74881. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74882. * @example https://doc.babylonjs.com/babylon101/particles
  74883. */
  74884. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74885. /**
  74886. * Billboard mode will only apply to Y axis
  74887. */
  74888. static readonly BILLBOARDMODE_Y: number;
  74889. /**
  74890. * Billboard mode will apply to all axes
  74891. */
  74892. static readonly BILLBOARDMODE_ALL: number;
  74893. /**
  74894. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74895. */
  74896. static readonly BILLBOARDMODE_STRETCHED: number;
  74897. /**
  74898. * This function can be defined to provide custom update for active particles.
  74899. * This function will be called instead of regular update (age, position, color, etc.).
  74900. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74901. */
  74902. updateFunction: (particles: Particle[]) => void;
  74903. private _emitterWorldMatrix;
  74904. /**
  74905. * This function can be defined to specify initial direction for every new particle.
  74906. * It by default use the emitterType defined function
  74907. */
  74908. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74909. /**
  74910. * This function can be defined to specify initial position for every new particle.
  74911. * It by default use the emitterType defined function
  74912. */
  74913. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74914. /**
  74915. * @hidden
  74916. */
  74917. _inheritedVelocityOffset: Vector3;
  74918. /**
  74919. * An event triggered when the system is disposed
  74920. */
  74921. onDisposeObservable: Observable<ParticleSystem>;
  74922. private _onDisposeObserver;
  74923. /**
  74924. * Sets a callback that will be triggered when the system is disposed
  74925. */
  74926. onDispose: () => void;
  74927. private _particles;
  74928. private _epsilon;
  74929. private _capacity;
  74930. private _stockParticles;
  74931. private _newPartsExcess;
  74932. private _vertexData;
  74933. private _vertexBuffer;
  74934. private _vertexBuffers;
  74935. private _spriteBuffer;
  74936. private _indexBuffer;
  74937. private _effect;
  74938. private _customEffect;
  74939. private _cachedDefines;
  74940. private _scaledColorStep;
  74941. private _colorDiff;
  74942. private _scaledDirection;
  74943. private _scaledGravity;
  74944. private _currentRenderId;
  74945. private _alive;
  74946. private _useInstancing;
  74947. private _started;
  74948. private _stopped;
  74949. private _actualFrame;
  74950. private _scaledUpdateSpeed;
  74951. private _vertexBufferSize;
  74952. /** @hidden */
  74953. _currentEmitRateGradient: Nullable<FactorGradient>;
  74954. /** @hidden */
  74955. _currentEmitRate1: number;
  74956. /** @hidden */
  74957. _currentEmitRate2: number;
  74958. /** @hidden */
  74959. _currentStartSizeGradient: Nullable<FactorGradient>;
  74960. /** @hidden */
  74961. _currentStartSize1: number;
  74962. /** @hidden */
  74963. _currentStartSize2: number;
  74964. private readonly _rawTextureWidth;
  74965. private _rampGradientsTexture;
  74966. private _useRampGradients;
  74967. /** Gets or sets a boolean indicating that ramp gradients must be used
  74968. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74969. */
  74970. useRampGradients: boolean;
  74971. /**
  74972. * 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.
  74973. * 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: [])
  74974. */
  74975. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74976. private _subEmitters;
  74977. /**
  74978. * @hidden
  74979. * If the particle systems emitter should be disposed when the particle system is disposed
  74980. */
  74981. _disposeEmitterOnDispose: boolean;
  74982. /**
  74983. * The current active Sub-systems, this property is used by the root particle system only.
  74984. */
  74985. activeSubSystems: Array<ParticleSystem>;
  74986. private _rootParticleSystem;
  74987. /**
  74988. * Gets the current list of active particles
  74989. */
  74990. readonly particles: Particle[];
  74991. /**
  74992. * Returns the string "ParticleSystem"
  74993. * @returns a string containing the class name
  74994. */
  74995. getClassName(): string;
  74996. /**
  74997. * Instantiates a particle system.
  74998. * 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.
  74999. * @param name The name of the particle system
  75000. * @param capacity The max number of particles alive at the same time
  75001. * @param scene The scene the particle system belongs to
  75002. * @param customEffect a custom effect used to change the way particles are rendered by default
  75003. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  75004. * @param epsilon Offset used to render the particles
  75005. */
  75006. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  75007. private _addFactorGradient;
  75008. private _removeFactorGradient;
  75009. /**
  75010. * Adds a new life time gradient
  75011. * @param gradient defines the gradient to use (between 0 and 1)
  75012. * @param factor defines the life time factor to affect to the specified gradient
  75013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75014. * @returns the current particle system
  75015. */
  75016. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75017. /**
  75018. * Remove a specific life time gradient
  75019. * @param gradient defines the gradient to remove
  75020. * @returns the current particle system
  75021. */
  75022. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75023. /**
  75024. * Adds a new size gradient
  75025. * @param gradient defines the gradient to use (between 0 and 1)
  75026. * @param factor defines the size factor to affect to the specified gradient
  75027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75028. * @returns the current particle system
  75029. */
  75030. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75031. /**
  75032. * Remove a specific size gradient
  75033. * @param gradient defines the gradient to remove
  75034. * @returns the current particle system
  75035. */
  75036. removeSizeGradient(gradient: number): IParticleSystem;
  75037. /**
  75038. * Adds a new color remap gradient
  75039. * @param gradient defines the gradient to use (between 0 and 1)
  75040. * @param min defines the color remap minimal range
  75041. * @param max defines the color remap maximal range
  75042. * @returns the current particle system
  75043. */
  75044. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75045. /**
  75046. * Remove a specific color remap gradient
  75047. * @param gradient defines the gradient to remove
  75048. * @returns the current particle system
  75049. */
  75050. removeColorRemapGradient(gradient: number): IParticleSystem;
  75051. /**
  75052. * Adds a new alpha remap gradient
  75053. * @param gradient defines the gradient to use (between 0 and 1)
  75054. * @param min defines the alpha remap minimal range
  75055. * @param max defines the alpha remap maximal range
  75056. * @returns the current particle system
  75057. */
  75058. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75059. /**
  75060. * Remove a specific alpha remap gradient
  75061. * @param gradient defines the gradient to remove
  75062. * @returns the current particle system
  75063. */
  75064. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  75065. /**
  75066. * Adds a new angular speed gradient
  75067. * @param gradient defines the gradient to use (between 0 and 1)
  75068. * @param factor defines the angular speed to affect to the specified gradient
  75069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75070. * @returns the current particle system
  75071. */
  75072. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75073. /**
  75074. * Remove a specific angular speed gradient
  75075. * @param gradient defines the gradient to remove
  75076. * @returns the current particle system
  75077. */
  75078. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75079. /**
  75080. * Adds a new velocity gradient
  75081. * @param gradient defines the gradient to use (between 0 and 1)
  75082. * @param factor defines the velocity to affect to the specified gradient
  75083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75084. * @returns the current particle system
  75085. */
  75086. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75087. /**
  75088. * Remove a specific velocity gradient
  75089. * @param gradient defines the gradient to remove
  75090. * @returns the current particle system
  75091. */
  75092. removeVelocityGradient(gradient: number): IParticleSystem;
  75093. /**
  75094. * Adds a new limit velocity gradient
  75095. * @param gradient defines the gradient to use (between 0 and 1)
  75096. * @param factor defines the limit velocity value to affect to the specified gradient
  75097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75098. * @returns the current particle system
  75099. */
  75100. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75101. /**
  75102. * Remove a specific limit velocity gradient
  75103. * @param gradient defines the gradient to remove
  75104. * @returns the current particle system
  75105. */
  75106. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75107. /**
  75108. * Adds a new drag gradient
  75109. * @param gradient defines the gradient to use (between 0 and 1)
  75110. * @param factor defines the drag value to affect to the specified gradient
  75111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75112. * @returns the current particle system
  75113. */
  75114. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75115. /**
  75116. * Remove a specific drag gradient
  75117. * @param gradient defines the gradient to remove
  75118. * @returns the current particle system
  75119. */
  75120. removeDragGradient(gradient: number): IParticleSystem;
  75121. /**
  75122. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75123. * @param gradient defines the gradient to use (between 0 and 1)
  75124. * @param factor defines the emit rate value to affect to the specified gradient
  75125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75126. * @returns the current particle system
  75127. */
  75128. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75129. /**
  75130. * Remove a specific emit rate gradient
  75131. * @param gradient defines the gradient to remove
  75132. * @returns the current particle system
  75133. */
  75134. removeEmitRateGradient(gradient: number): IParticleSystem;
  75135. /**
  75136. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75137. * @param gradient defines the gradient to use (between 0 and 1)
  75138. * @param factor defines the start size value to affect to the specified gradient
  75139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75140. * @returns the current particle system
  75141. */
  75142. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75143. /**
  75144. * Remove a specific start size gradient
  75145. * @param gradient defines the gradient to remove
  75146. * @returns the current particle system
  75147. */
  75148. removeStartSizeGradient(gradient: number): IParticleSystem;
  75149. private _createRampGradientTexture;
  75150. /**
  75151. * Gets the current list of ramp gradients.
  75152. * You must use addRampGradient and removeRampGradient to udpate this list
  75153. * @returns the list of ramp gradients
  75154. */
  75155. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75156. /**
  75157. * Adds a new ramp gradient used to remap particle colors
  75158. * @param gradient defines the gradient to use (between 0 and 1)
  75159. * @param color defines the color to affect to the specified gradient
  75160. * @returns the current particle system
  75161. */
  75162. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  75163. /**
  75164. * Remove a specific ramp gradient
  75165. * @param gradient defines the gradient to remove
  75166. * @returns the current particle system
  75167. */
  75168. removeRampGradient(gradient: number): ParticleSystem;
  75169. /**
  75170. * Adds a new color gradient
  75171. * @param gradient defines the gradient to use (between 0 and 1)
  75172. * @param color1 defines the color to affect to the specified gradient
  75173. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75174. * @returns this particle system
  75175. */
  75176. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75177. /**
  75178. * Remove a specific color gradient
  75179. * @param gradient defines the gradient to remove
  75180. * @returns this particle system
  75181. */
  75182. removeColorGradient(gradient: number): IParticleSystem;
  75183. private _fetchR;
  75184. protected _reset(): void;
  75185. private _resetEffect;
  75186. private _createVertexBuffers;
  75187. private _createIndexBuffer;
  75188. /**
  75189. * Gets the maximum number of particles active at the same time.
  75190. * @returns The max number of active particles.
  75191. */
  75192. getCapacity(): number;
  75193. /**
  75194. * Gets whether there are still active particles in the system.
  75195. * @returns True if it is alive, otherwise false.
  75196. */
  75197. isAlive(): boolean;
  75198. /**
  75199. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75200. * @returns True if it has been started, otherwise false.
  75201. */
  75202. isStarted(): boolean;
  75203. private _prepareSubEmitterInternalArray;
  75204. /**
  75205. * Starts the particle system and begins to emit
  75206. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  75207. */
  75208. start(delay?: number): void;
  75209. /**
  75210. * Stops the particle system.
  75211. * @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.
  75212. */
  75213. stop(stopSubEmitters?: boolean): void;
  75214. /**
  75215. * Remove all active particles
  75216. */
  75217. reset(): void;
  75218. /**
  75219. * @hidden (for internal use only)
  75220. */
  75221. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  75222. /**
  75223. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  75224. * Its lifetime will start back at 0.
  75225. */
  75226. recycleParticle: (particle: Particle) => void;
  75227. private _stopSubEmitters;
  75228. private _createParticle;
  75229. private _removeFromRoot;
  75230. private _emitFromParticle;
  75231. private _update;
  75232. /** @hidden */
  75233. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  75234. /** @hidden */
  75235. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  75236. /** @hidden */
  75237. private _getEffect;
  75238. /**
  75239. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  75240. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  75241. */
  75242. animate(preWarmOnly?: boolean): void;
  75243. private _appendParticleVertices;
  75244. /**
  75245. * Rebuilds the particle system.
  75246. */
  75247. rebuild(): void;
  75248. /**
  75249. * Is this system ready to be used/rendered
  75250. * @return true if the system is ready
  75251. */
  75252. isReady(): boolean;
  75253. private _render;
  75254. /**
  75255. * Renders the particle system in its current state.
  75256. * @returns the current number of particles
  75257. */
  75258. render(): number;
  75259. /**
  75260. * Disposes the particle system and free the associated resources
  75261. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75262. */
  75263. dispose(disposeTexture?: boolean): void;
  75264. /**
  75265. * Clones the particle system.
  75266. * @param name The name of the cloned object
  75267. * @param newEmitter The new emitter to use
  75268. * @returns the cloned particle system
  75269. */
  75270. clone(name: string, newEmitter: any): ParticleSystem;
  75271. /**
  75272. * Serializes the particle system to a JSON object.
  75273. * @returns the JSON object
  75274. */
  75275. serialize(): any;
  75276. /** @hidden */
  75277. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  75278. /** @hidden */
  75279. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  75280. /**
  75281. * Parses a JSON object to create a particle system.
  75282. * @param parsedParticleSystem The JSON object to parse
  75283. * @param scene The scene to create the particle system in
  75284. * @param rootUrl The root url to use to load external dependencies like texture
  75285. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  75286. * @returns the Parsed particle system
  75287. */
  75288. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  75289. }
  75290. }
  75291. declare module BABYLON {
  75292. /**
  75293. * A particle represents one of the element emitted by a particle system.
  75294. * This is mainly define by its coordinates, direction, velocity and age.
  75295. */
  75296. export class Particle {
  75297. /**
  75298. * The particle system the particle belongs to.
  75299. */
  75300. particleSystem: ParticleSystem;
  75301. private static _Count;
  75302. /**
  75303. * Unique ID of the particle
  75304. */
  75305. id: number;
  75306. /**
  75307. * The world position of the particle in the scene.
  75308. */
  75309. position: Vector3;
  75310. /**
  75311. * The world direction of the particle in the scene.
  75312. */
  75313. direction: Vector3;
  75314. /**
  75315. * The color of the particle.
  75316. */
  75317. color: Color4;
  75318. /**
  75319. * The color change of the particle per step.
  75320. */
  75321. colorStep: Color4;
  75322. /**
  75323. * Defines how long will the life of the particle be.
  75324. */
  75325. lifeTime: number;
  75326. /**
  75327. * The current age of the particle.
  75328. */
  75329. age: number;
  75330. /**
  75331. * The current size of the particle.
  75332. */
  75333. size: number;
  75334. /**
  75335. * The current scale of the particle.
  75336. */
  75337. scale: Vector2;
  75338. /**
  75339. * The current angle of the particle.
  75340. */
  75341. angle: number;
  75342. /**
  75343. * Defines how fast is the angle changing.
  75344. */
  75345. angularSpeed: number;
  75346. /**
  75347. * Defines the cell index used by the particle to be rendered from a sprite.
  75348. */
  75349. cellIndex: number;
  75350. /**
  75351. * The information required to support color remapping
  75352. */
  75353. remapData: Vector4;
  75354. /** @hidden */
  75355. _randomCellOffset?: number;
  75356. /** @hidden */
  75357. _initialDirection: Nullable<Vector3>;
  75358. /** @hidden */
  75359. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  75360. /** @hidden */
  75361. _initialStartSpriteCellID: number;
  75362. /** @hidden */
  75363. _initialEndSpriteCellID: number;
  75364. /** @hidden */
  75365. _currentColorGradient: Nullable<ColorGradient>;
  75366. /** @hidden */
  75367. _currentColor1: Color4;
  75368. /** @hidden */
  75369. _currentColor2: Color4;
  75370. /** @hidden */
  75371. _currentSizeGradient: Nullable<FactorGradient>;
  75372. /** @hidden */
  75373. _currentSize1: number;
  75374. /** @hidden */
  75375. _currentSize2: number;
  75376. /** @hidden */
  75377. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  75378. /** @hidden */
  75379. _currentAngularSpeed1: number;
  75380. /** @hidden */
  75381. _currentAngularSpeed2: number;
  75382. /** @hidden */
  75383. _currentVelocityGradient: Nullable<FactorGradient>;
  75384. /** @hidden */
  75385. _currentVelocity1: number;
  75386. /** @hidden */
  75387. _currentVelocity2: number;
  75388. /** @hidden */
  75389. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  75390. /** @hidden */
  75391. _currentLimitVelocity1: number;
  75392. /** @hidden */
  75393. _currentLimitVelocity2: number;
  75394. /** @hidden */
  75395. _currentDragGradient: Nullable<FactorGradient>;
  75396. /** @hidden */
  75397. _currentDrag1: number;
  75398. /** @hidden */
  75399. _currentDrag2: number;
  75400. /** @hidden */
  75401. _randomNoiseCoordinates1: Vector3;
  75402. /** @hidden */
  75403. _randomNoiseCoordinates2: Vector3;
  75404. /**
  75405. * Creates a new instance Particle
  75406. * @param particleSystem the particle system the particle belongs to
  75407. */
  75408. constructor(
  75409. /**
  75410. * The particle system the particle belongs to.
  75411. */
  75412. particleSystem: ParticleSystem);
  75413. private updateCellInfoFromSystem;
  75414. /**
  75415. * Defines how the sprite cell index is updated for the particle
  75416. */
  75417. updateCellIndex(): void;
  75418. /** @hidden */
  75419. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  75420. /** @hidden */
  75421. _inheritParticleInfoToSubEmitters(): void;
  75422. /** @hidden */
  75423. _reset(): void;
  75424. /**
  75425. * Copy the properties of particle to another one.
  75426. * @param other the particle to copy the information to.
  75427. */
  75428. copyTo(other: Particle): void;
  75429. }
  75430. }
  75431. declare module BABYLON {
  75432. /**
  75433. * Particle emitter represents a volume emitting particles.
  75434. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  75435. */
  75436. export interface IParticleEmitterType {
  75437. /**
  75438. * Called by the particle System when the direction is computed for the created particle.
  75439. * @param worldMatrix is the world matrix of the particle system
  75440. * @param directionToUpdate is the direction vector to update with the result
  75441. * @param particle is the particle we are computed the direction for
  75442. */
  75443. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75444. /**
  75445. * Called by the particle System when the position is computed for the created particle.
  75446. * @param worldMatrix is the world matrix of the particle system
  75447. * @param positionToUpdate is the position vector to update with the result
  75448. * @param particle is the particle we are computed the position for
  75449. */
  75450. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75451. /**
  75452. * Clones the current emitter and returns a copy of it
  75453. * @returns the new emitter
  75454. */
  75455. clone(): IParticleEmitterType;
  75456. /**
  75457. * Called by the GPUParticleSystem to setup the update shader
  75458. * @param effect defines the update shader
  75459. */
  75460. applyToShader(effect: Effect): void;
  75461. /**
  75462. * Returns a string to use to update the GPU particles update shader
  75463. * @returns the effect defines string
  75464. */
  75465. getEffectDefines(): string;
  75466. /**
  75467. * Returns a string representing the class name
  75468. * @returns a string containing the class name
  75469. */
  75470. getClassName(): string;
  75471. /**
  75472. * Serializes the particle system to a JSON object.
  75473. * @returns the JSON object
  75474. */
  75475. serialize(): any;
  75476. /**
  75477. * Parse properties from a JSON object
  75478. * @param serializationObject defines the JSON object
  75479. */
  75480. parse(serializationObject: any): void;
  75481. }
  75482. }
  75483. declare module BABYLON {
  75484. /**
  75485. * Particle emitter emitting particles from the inside of a box.
  75486. * It emits the particles randomly between 2 given directions.
  75487. */
  75488. export class BoxParticleEmitter implements IParticleEmitterType {
  75489. /**
  75490. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75491. */
  75492. direction1: Vector3;
  75493. /**
  75494. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75495. */
  75496. direction2: Vector3;
  75497. /**
  75498. * 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.
  75499. */
  75500. minEmitBox: Vector3;
  75501. /**
  75502. * 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.
  75503. */
  75504. maxEmitBox: Vector3;
  75505. /**
  75506. * Creates a new instance BoxParticleEmitter
  75507. */
  75508. constructor();
  75509. /**
  75510. * Called by the particle System when the direction is computed for the created particle.
  75511. * @param worldMatrix is the world matrix of the particle system
  75512. * @param directionToUpdate is the direction vector to update with the result
  75513. * @param particle is the particle we are computed the direction for
  75514. */
  75515. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75516. /**
  75517. * Called by the particle System when the position is computed for the created particle.
  75518. * @param worldMatrix is the world matrix of the particle system
  75519. * @param positionToUpdate is the position vector to update with the result
  75520. * @param particle is the particle we are computed the position for
  75521. */
  75522. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75523. /**
  75524. * Clones the current emitter and returns a copy of it
  75525. * @returns the new emitter
  75526. */
  75527. clone(): BoxParticleEmitter;
  75528. /**
  75529. * Called by the GPUParticleSystem to setup the update shader
  75530. * @param effect defines the update shader
  75531. */
  75532. applyToShader(effect: Effect): void;
  75533. /**
  75534. * Returns a string to use to update the GPU particles update shader
  75535. * @returns a string containng the defines string
  75536. */
  75537. getEffectDefines(): string;
  75538. /**
  75539. * Returns the string "BoxParticleEmitter"
  75540. * @returns a string containing the class name
  75541. */
  75542. getClassName(): string;
  75543. /**
  75544. * Serializes the particle system to a JSON object.
  75545. * @returns the JSON object
  75546. */
  75547. serialize(): any;
  75548. /**
  75549. * Parse properties from a JSON object
  75550. * @param serializationObject defines the JSON object
  75551. */
  75552. parse(serializationObject: any): void;
  75553. }
  75554. }
  75555. declare module BABYLON {
  75556. /**
  75557. * Particle emitter emitting particles from the inside of a cone.
  75558. * It emits the particles alongside the cone volume from the base to the particle.
  75559. * The emission direction might be randomized.
  75560. */
  75561. export class ConeParticleEmitter implements IParticleEmitterType {
  75562. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75563. directionRandomizer: number;
  75564. private _radius;
  75565. private _angle;
  75566. private _height;
  75567. /**
  75568. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  75569. */
  75570. radiusRange: number;
  75571. /**
  75572. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  75573. */
  75574. heightRange: number;
  75575. /**
  75576. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  75577. */
  75578. emitFromSpawnPointOnly: boolean;
  75579. /**
  75580. * Gets or sets the radius of the emission cone
  75581. */
  75582. radius: number;
  75583. /**
  75584. * Gets or sets the angle of the emission cone
  75585. */
  75586. angle: number;
  75587. private _buildHeight;
  75588. /**
  75589. * Creates a new instance ConeParticleEmitter
  75590. * @param radius the radius of the emission cone (1 by default)
  75591. * @param angle the cone base angle (PI by default)
  75592. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  75593. */
  75594. constructor(radius?: number, angle?: number,
  75595. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75596. directionRandomizer?: number);
  75597. /**
  75598. * Called by the particle System when the direction is computed for the created particle.
  75599. * @param worldMatrix is the world matrix of the particle system
  75600. * @param directionToUpdate is the direction vector to update with the result
  75601. * @param particle is the particle we are computed the direction for
  75602. */
  75603. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75604. /**
  75605. * Called by the particle System when the position is computed for the created particle.
  75606. * @param worldMatrix is the world matrix of the particle system
  75607. * @param positionToUpdate is the position vector to update with the result
  75608. * @param particle is the particle we are computed the position for
  75609. */
  75610. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75611. /**
  75612. * Clones the current emitter and returns a copy of it
  75613. * @returns the new emitter
  75614. */
  75615. clone(): ConeParticleEmitter;
  75616. /**
  75617. * Called by the GPUParticleSystem to setup the update shader
  75618. * @param effect defines the update shader
  75619. */
  75620. applyToShader(effect: Effect): void;
  75621. /**
  75622. * Returns a string to use to update the GPU particles update shader
  75623. * @returns a string containng the defines string
  75624. */
  75625. getEffectDefines(): string;
  75626. /**
  75627. * Returns the string "ConeParticleEmitter"
  75628. * @returns a string containing the class name
  75629. */
  75630. getClassName(): string;
  75631. /**
  75632. * Serializes the particle system to a JSON object.
  75633. * @returns the JSON object
  75634. */
  75635. serialize(): any;
  75636. /**
  75637. * Parse properties from a JSON object
  75638. * @param serializationObject defines the JSON object
  75639. */
  75640. parse(serializationObject: any): void;
  75641. }
  75642. }
  75643. declare module BABYLON {
  75644. /**
  75645. * Particle emitter emitting particles from the inside of a cylinder.
  75646. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  75647. */
  75648. export class CylinderParticleEmitter implements IParticleEmitterType {
  75649. /**
  75650. * The radius of the emission cylinder.
  75651. */
  75652. radius: number;
  75653. /**
  75654. * The height of the emission cylinder.
  75655. */
  75656. height: number;
  75657. /**
  75658. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75659. */
  75660. radiusRange: number;
  75661. /**
  75662. * How much to randomize the particle direction [0-1].
  75663. */
  75664. directionRandomizer: number;
  75665. /**
  75666. * Creates a new instance CylinderParticleEmitter
  75667. * @param radius the radius of the emission cylinder (1 by default)
  75668. * @param height the height of the emission cylinder (1 by default)
  75669. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75670. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75671. */
  75672. constructor(
  75673. /**
  75674. * The radius of the emission cylinder.
  75675. */
  75676. radius?: number,
  75677. /**
  75678. * The height of the emission cylinder.
  75679. */
  75680. height?: number,
  75681. /**
  75682. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75683. */
  75684. radiusRange?: number,
  75685. /**
  75686. * How much to randomize the particle direction [0-1].
  75687. */
  75688. directionRandomizer?: number);
  75689. /**
  75690. * Called by the particle System when the direction is computed for the created particle.
  75691. * @param worldMatrix is the world matrix of the particle system
  75692. * @param directionToUpdate is the direction vector to update with the result
  75693. * @param particle is the particle we are computed the direction for
  75694. */
  75695. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75696. /**
  75697. * Called by the particle System when the position is computed for the created particle.
  75698. * @param worldMatrix is the world matrix of the particle system
  75699. * @param positionToUpdate is the position vector to update with the result
  75700. * @param particle is the particle we are computed the position for
  75701. */
  75702. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75703. /**
  75704. * Clones the current emitter and returns a copy of it
  75705. * @returns the new emitter
  75706. */
  75707. clone(): CylinderParticleEmitter;
  75708. /**
  75709. * Called by the GPUParticleSystem to setup the update shader
  75710. * @param effect defines the update shader
  75711. */
  75712. applyToShader(effect: Effect): void;
  75713. /**
  75714. * Returns a string to use to update the GPU particles update shader
  75715. * @returns a string containng the defines string
  75716. */
  75717. getEffectDefines(): string;
  75718. /**
  75719. * Returns the string "CylinderParticleEmitter"
  75720. * @returns a string containing the class name
  75721. */
  75722. getClassName(): string;
  75723. /**
  75724. * Serializes the particle system to a JSON object.
  75725. * @returns the JSON object
  75726. */
  75727. serialize(): any;
  75728. /**
  75729. * Parse properties from a JSON object
  75730. * @param serializationObject defines the JSON object
  75731. */
  75732. parse(serializationObject: any): void;
  75733. }
  75734. /**
  75735. * Particle emitter emitting particles from the inside of a cylinder.
  75736. * It emits the particles randomly between two vectors.
  75737. */
  75738. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  75739. /**
  75740. * The min limit of the emission direction.
  75741. */
  75742. direction1: Vector3;
  75743. /**
  75744. * The max limit of the emission direction.
  75745. */
  75746. direction2: Vector3;
  75747. /**
  75748. * Creates a new instance CylinderDirectedParticleEmitter
  75749. * @param radius the radius of the emission cylinder (1 by default)
  75750. * @param height the height of the emission cylinder (1 by default)
  75751. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75752. * @param direction1 the min limit of the emission direction (up vector by default)
  75753. * @param direction2 the max limit of the emission direction (up vector by default)
  75754. */
  75755. constructor(radius?: number, height?: number, radiusRange?: number,
  75756. /**
  75757. * The min limit of the emission direction.
  75758. */
  75759. direction1?: Vector3,
  75760. /**
  75761. * The max limit of the emission direction.
  75762. */
  75763. direction2?: Vector3);
  75764. /**
  75765. * Called by the particle System when the direction is computed for the created particle.
  75766. * @param worldMatrix is the world matrix of the particle system
  75767. * @param directionToUpdate is the direction vector to update with the result
  75768. * @param particle is the particle we are computed the direction for
  75769. */
  75770. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75771. /**
  75772. * Clones the current emitter and returns a copy of it
  75773. * @returns the new emitter
  75774. */
  75775. clone(): CylinderDirectedParticleEmitter;
  75776. /**
  75777. * Called by the GPUParticleSystem to setup the update shader
  75778. * @param effect defines the update shader
  75779. */
  75780. applyToShader(effect: Effect): void;
  75781. /**
  75782. * Returns a string to use to update the GPU particles update shader
  75783. * @returns a string containng the defines string
  75784. */
  75785. getEffectDefines(): string;
  75786. /**
  75787. * Returns the string "CylinderDirectedParticleEmitter"
  75788. * @returns a string containing the class name
  75789. */
  75790. getClassName(): string;
  75791. /**
  75792. * Serializes the particle system to a JSON object.
  75793. * @returns the JSON object
  75794. */
  75795. serialize(): any;
  75796. /**
  75797. * Parse properties from a JSON object
  75798. * @param serializationObject defines the JSON object
  75799. */
  75800. parse(serializationObject: any): void;
  75801. }
  75802. }
  75803. declare module BABYLON {
  75804. /**
  75805. * Particle emitter emitting particles from the inside of a hemisphere.
  75806. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75807. */
  75808. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75809. /**
  75810. * The radius of the emission hemisphere.
  75811. */
  75812. radius: number;
  75813. /**
  75814. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75815. */
  75816. radiusRange: number;
  75817. /**
  75818. * How much to randomize the particle direction [0-1].
  75819. */
  75820. directionRandomizer: number;
  75821. /**
  75822. * Creates a new instance HemisphericParticleEmitter
  75823. * @param radius the radius of the emission hemisphere (1 by default)
  75824. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75825. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75826. */
  75827. constructor(
  75828. /**
  75829. * The radius of the emission hemisphere.
  75830. */
  75831. radius?: number,
  75832. /**
  75833. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75834. */
  75835. radiusRange?: number,
  75836. /**
  75837. * How much to randomize the particle direction [0-1].
  75838. */
  75839. directionRandomizer?: number);
  75840. /**
  75841. * Called by the particle System when the direction is computed for the created particle.
  75842. * @param worldMatrix is the world matrix of the particle system
  75843. * @param directionToUpdate is the direction vector to update with the result
  75844. * @param particle is the particle we are computed the direction for
  75845. */
  75846. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75847. /**
  75848. * Called by the particle System when the position is computed for the created particle.
  75849. * @param worldMatrix is the world matrix of the particle system
  75850. * @param positionToUpdate is the position vector to update with the result
  75851. * @param particle is the particle we are computed the position for
  75852. */
  75853. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75854. /**
  75855. * Clones the current emitter and returns a copy of it
  75856. * @returns the new emitter
  75857. */
  75858. clone(): HemisphericParticleEmitter;
  75859. /**
  75860. * Called by the GPUParticleSystem to setup the update shader
  75861. * @param effect defines the update shader
  75862. */
  75863. applyToShader(effect: Effect): void;
  75864. /**
  75865. * Returns a string to use to update the GPU particles update shader
  75866. * @returns a string containng the defines string
  75867. */
  75868. getEffectDefines(): string;
  75869. /**
  75870. * Returns the string "HemisphericParticleEmitter"
  75871. * @returns a string containing the class name
  75872. */
  75873. getClassName(): string;
  75874. /**
  75875. * Serializes the particle system to a JSON object.
  75876. * @returns the JSON object
  75877. */
  75878. serialize(): any;
  75879. /**
  75880. * Parse properties from a JSON object
  75881. * @param serializationObject defines the JSON object
  75882. */
  75883. parse(serializationObject: any): void;
  75884. }
  75885. }
  75886. declare module BABYLON {
  75887. /**
  75888. * Particle emitter emitting particles from a point.
  75889. * It emits the particles randomly between 2 given directions.
  75890. */
  75891. export class PointParticleEmitter implements IParticleEmitterType {
  75892. /**
  75893. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75894. */
  75895. direction1: Vector3;
  75896. /**
  75897. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75898. */
  75899. direction2: Vector3;
  75900. /**
  75901. * Creates a new instance PointParticleEmitter
  75902. */
  75903. constructor();
  75904. /**
  75905. * Called by the particle System when the direction is computed for the created particle.
  75906. * @param worldMatrix is the world matrix of the particle system
  75907. * @param directionToUpdate is the direction vector to update with the result
  75908. * @param particle is the particle we are computed the direction for
  75909. */
  75910. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75911. /**
  75912. * Called by the particle System when the position is computed for the created particle.
  75913. * @param worldMatrix is the world matrix of the particle system
  75914. * @param positionToUpdate is the position vector to update with the result
  75915. * @param particle is the particle we are computed the position for
  75916. */
  75917. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75918. /**
  75919. * Clones the current emitter and returns a copy of it
  75920. * @returns the new emitter
  75921. */
  75922. clone(): PointParticleEmitter;
  75923. /**
  75924. * Called by the GPUParticleSystem to setup the update shader
  75925. * @param effect defines the update shader
  75926. */
  75927. applyToShader(effect: Effect): void;
  75928. /**
  75929. * Returns a string to use to update the GPU particles update shader
  75930. * @returns a string containng the defines string
  75931. */
  75932. getEffectDefines(): string;
  75933. /**
  75934. * Returns the string "PointParticleEmitter"
  75935. * @returns a string containing the class name
  75936. */
  75937. getClassName(): string;
  75938. /**
  75939. * Serializes the particle system to a JSON object.
  75940. * @returns the JSON object
  75941. */
  75942. serialize(): any;
  75943. /**
  75944. * Parse properties from a JSON object
  75945. * @param serializationObject defines the JSON object
  75946. */
  75947. parse(serializationObject: any): void;
  75948. }
  75949. }
  75950. declare module BABYLON {
  75951. /**
  75952. * Particle emitter emitting particles from the inside of a sphere.
  75953. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75954. */
  75955. export class SphereParticleEmitter implements IParticleEmitterType {
  75956. /**
  75957. * The radius of the emission sphere.
  75958. */
  75959. radius: number;
  75960. /**
  75961. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75962. */
  75963. radiusRange: number;
  75964. /**
  75965. * How much to randomize the particle direction [0-1].
  75966. */
  75967. directionRandomizer: number;
  75968. /**
  75969. * Creates a new instance SphereParticleEmitter
  75970. * @param radius the radius of the emission sphere (1 by default)
  75971. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75972. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75973. */
  75974. constructor(
  75975. /**
  75976. * The radius of the emission sphere.
  75977. */
  75978. radius?: number,
  75979. /**
  75980. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75981. */
  75982. radiusRange?: number,
  75983. /**
  75984. * How much to randomize the particle direction [0-1].
  75985. */
  75986. directionRandomizer?: number);
  75987. /**
  75988. * Called by the particle System when the direction is computed for the created particle.
  75989. * @param worldMatrix is the world matrix of the particle system
  75990. * @param directionToUpdate is the direction vector to update with the result
  75991. * @param particle is the particle we are computed the direction for
  75992. */
  75993. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75994. /**
  75995. * Called by the particle System when the position is computed for the created particle.
  75996. * @param worldMatrix is the world matrix of the particle system
  75997. * @param positionToUpdate is the position vector to update with the result
  75998. * @param particle is the particle we are computed the position for
  75999. */
  76000. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  76001. /**
  76002. * Clones the current emitter and returns a copy of it
  76003. * @returns the new emitter
  76004. */
  76005. clone(): SphereParticleEmitter;
  76006. /**
  76007. * Called by the GPUParticleSystem to setup the update shader
  76008. * @param effect defines the update shader
  76009. */
  76010. applyToShader(effect: Effect): void;
  76011. /**
  76012. * Returns a string to use to update the GPU particles update shader
  76013. * @returns a string containng the defines string
  76014. */
  76015. getEffectDefines(): string;
  76016. /**
  76017. * Returns the string "SphereParticleEmitter"
  76018. * @returns a string containing the class name
  76019. */
  76020. getClassName(): string;
  76021. /**
  76022. * Serializes the particle system to a JSON object.
  76023. * @returns the JSON object
  76024. */
  76025. serialize(): any;
  76026. /**
  76027. * Parse properties from a JSON object
  76028. * @param serializationObject defines the JSON object
  76029. */
  76030. parse(serializationObject: any): void;
  76031. }
  76032. /**
  76033. * Particle emitter emitting particles from the inside of a sphere.
  76034. * It emits the particles randomly between two vectors.
  76035. */
  76036. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  76037. /**
  76038. * The min limit of the emission direction.
  76039. */
  76040. direction1: Vector3;
  76041. /**
  76042. * The max limit of the emission direction.
  76043. */
  76044. direction2: Vector3;
  76045. /**
  76046. * Creates a new instance SphereDirectedParticleEmitter
  76047. * @param radius the radius of the emission sphere (1 by default)
  76048. * @param direction1 the min limit of the emission direction (up vector by default)
  76049. * @param direction2 the max limit of the emission direction (up vector by default)
  76050. */
  76051. constructor(radius?: number,
  76052. /**
  76053. * The min limit of the emission direction.
  76054. */
  76055. direction1?: Vector3,
  76056. /**
  76057. * The max limit of the emission direction.
  76058. */
  76059. direction2?: Vector3);
  76060. /**
  76061. * Called by the particle System when the direction is computed for the created particle.
  76062. * @param worldMatrix is the world matrix of the particle system
  76063. * @param directionToUpdate is the direction vector to update with the result
  76064. * @param particle is the particle we are computed the direction for
  76065. */
  76066. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76067. /**
  76068. * Clones the current emitter and returns a copy of it
  76069. * @returns the new emitter
  76070. */
  76071. clone(): SphereDirectedParticleEmitter;
  76072. /**
  76073. * Called by the GPUParticleSystem to setup the update shader
  76074. * @param effect defines the update shader
  76075. */
  76076. applyToShader(effect: Effect): void;
  76077. /**
  76078. * Returns a string to use to update the GPU particles update shader
  76079. * @returns a string containng the defines string
  76080. */
  76081. getEffectDefines(): string;
  76082. /**
  76083. * Returns the string "SphereDirectedParticleEmitter"
  76084. * @returns a string containing the class name
  76085. */
  76086. getClassName(): string;
  76087. /**
  76088. * Serializes the particle system to a JSON object.
  76089. * @returns the JSON object
  76090. */
  76091. serialize(): any;
  76092. /**
  76093. * Parse properties from a JSON object
  76094. * @param serializationObject defines the JSON object
  76095. */
  76096. parse(serializationObject: any): void;
  76097. }
  76098. }
  76099. declare module BABYLON {
  76100. /**
  76101. * Interface representing a particle system in Babylon.js.
  76102. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  76103. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  76104. */
  76105. export interface IParticleSystem {
  76106. /**
  76107. * List of animations used by the particle system.
  76108. */
  76109. animations: Animation[];
  76110. /**
  76111. * The id of the Particle system.
  76112. */
  76113. id: string;
  76114. /**
  76115. * The name of the Particle system.
  76116. */
  76117. name: string;
  76118. /**
  76119. * The emitter represents the Mesh or position we are attaching the particle system to.
  76120. */
  76121. emitter: Nullable<AbstractMesh | Vector3>;
  76122. /**
  76123. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  76124. */
  76125. isBillboardBased: boolean;
  76126. /**
  76127. * The rendering group used by the Particle system to chose when to render.
  76128. */
  76129. renderingGroupId: number;
  76130. /**
  76131. * The layer mask we are rendering the particles through.
  76132. */
  76133. layerMask: number;
  76134. /**
  76135. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76136. */
  76137. updateSpeed: number;
  76138. /**
  76139. * The amount of time the particle system is running (depends of the overall update speed).
  76140. */
  76141. targetStopDuration: number;
  76142. /**
  76143. * The texture used to render each particle. (this can be a spritesheet)
  76144. */
  76145. particleTexture: Nullable<Texture>;
  76146. /**
  76147. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  76148. */
  76149. blendMode: number;
  76150. /**
  76151. * Minimum life time of emitting particles.
  76152. */
  76153. minLifeTime: number;
  76154. /**
  76155. * Maximum life time of emitting particles.
  76156. */
  76157. maxLifeTime: number;
  76158. /**
  76159. * Minimum Size of emitting particles.
  76160. */
  76161. minSize: number;
  76162. /**
  76163. * Maximum Size of emitting particles.
  76164. */
  76165. maxSize: number;
  76166. /**
  76167. * Minimum scale of emitting particles on X axis.
  76168. */
  76169. minScaleX: number;
  76170. /**
  76171. * Maximum scale of emitting particles on X axis.
  76172. */
  76173. maxScaleX: number;
  76174. /**
  76175. * Minimum scale of emitting particles on Y axis.
  76176. */
  76177. minScaleY: number;
  76178. /**
  76179. * Maximum scale of emitting particles on Y axis.
  76180. */
  76181. maxScaleY: number;
  76182. /**
  76183. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76184. */
  76185. color1: Color4;
  76186. /**
  76187. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76188. */
  76189. color2: Color4;
  76190. /**
  76191. * Color the particle will have at the end of its lifetime.
  76192. */
  76193. colorDead: Color4;
  76194. /**
  76195. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  76196. */
  76197. emitRate: number;
  76198. /**
  76199. * You can use gravity if you want to give an orientation to your particles.
  76200. */
  76201. gravity: Vector3;
  76202. /**
  76203. * Minimum power of emitting particles.
  76204. */
  76205. minEmitPower: number;
  76206. /**
  76207. * Maximum power of emitting particles.
  76208. */
  76209. maxEmitPower: number;
  76210. /**
  76211. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76212. */
  76213. minAngularSpeed: number;
  76214. /**
  76215. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76216. */
  76217. maxAngularSpeed: number;
  76218. /**
  76219. * Gets or sets the minimal initial rotation in radians.
  76220. */
  76221. minInitialRotation: number;
  76222. /**
  76223. * Gets or sets the maximal initial rotation in radians.
  76224. */
  76225. maxInitialRotation: number;
  76226. /**
  76227. * The particle emitter type defines the emitter used by the particle system.
  76228. * It can be for example box, sphere, or cone...
  76229. */
  76230. particleEmitterType: Nullable<IParticleEmitterType>;
  76231. /**
  76232. * Defines the delay in milliseconds before starting the system (0 by default)
  76233. */
  76234. startDelay: number;
  76235. /**
  76236. * 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
  76237. */
  76238. preWarmCycles: number;
  76239. /**
  76240. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  76241. */
  76242. preWarmStepOffset: number;
  76243. /**
  76244. * 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)
  76245. */
  76246. spriteCellChangeSpeed: number;
  76247. /**
  76248. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76249. */
  76250. startSpriteCellID: number;
  76251. /**
  76252. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76253. */
  76254. endSpriteCellID: number;
  76255. /**
  76256. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76257. */
  76258. spriteCellWidth: number;
  76259. /**
  76260. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76261. */
  76262. spriteCellHeight: number;
  76263. /**
  76264. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76265. */
  76266. spriteRandomStartCell: boolean;
  76267. /**
  76268. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  76269. */
  76270. isAnimationSheetEnabled: boolean;
  76271. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76272. translationPivot: Vector2;
  76273. /**
  76274. * Gets or sets a texture used to add random noise to particle positions
  76275. */
  76276. noiseTexture: Nullable<BaseTexture>;
  76277. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76278. noiseStrength: Vector3;
  76279. /**
  76280. * Gets or sets the billboard mode to use when isBillboardBased = true.
  76281. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  76282. */
  76283. billboardMode: number;
  76284. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  76285. limitVelocityDamping: number;
  76286. /**
  76287. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76288. */
  76289. beginAnimationOnStart: boolean;
  76290. /**
  76291. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76292. */
  76293. beginAnimationFrom: number;
  76294. /**
  76295. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76296. */
  76297. beginAnimationTo: number;
  76298. /**
  76299. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76300. */
  76301. beginAnimationLoop: boolean;
  76302. /**
  76303. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76304. */
  76305. disposeOnStop: boolean;
  76306. /**
  76307. * Gets the maximum number of particles active at the same time.
  76308. * @returns The max number of active particles.
  76309. */
  76310. getCapacity(): number;
  76311. /**
  76312. * Gets if the system has been started. (Note: this will still be true after stop is called)
  76313. * @returns True if it has been started, otherwise false.
  76314. */
  76315. isStarted(): boolean;
  76316. /**
  76317. * Animates the particle system for this frame.
  76318. */
  76319. animate(): void;
  76320. /**
  76321. * Renders the particle system in its current state.
  76322. * @returns the current number of particles
  76323. */
  76324. render(): number;
  76325. /**
  76326. * Dispose the particle system and frees its associated resources.
  76327. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  76328. */
  76329. dispose(disposeTexture?: boolean): void;
  76330. /**
  76331. * Clones the particle system.
  76332. * @param name The name of the cloned object
  76333. * @param newEmitter The new emitter to use
  76334. * @returns the cloned particle system
  76335. */
  76336. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  76337. /**
  76338. * Serializes the particle system to a JSON object.
  76339. * @returns the JSON object
  76340. */
  76341. serialize(): any;
  76342. /**
  76343. * Rebuild the particle system
  76344. */
  76345. rebuild(): void;
  76346. /**
  76347. * Starts the particle system and begins to emit
  76348. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  76349. */
  76350. start(delay?: number): void;
  76351. /**
  76352. * Stops the particle system.
  76353. */
  76354. stop(): void;
  76355. /**
  76356. * Remove all active particles
  76357. */
  76358. reset(): void;
  76359. /**
  76360. * Is this system ready to be used/rendered
  76361. * @return true if the system is ready
  76362. */
  76363. isReady(): boolean;
  76364. /**
  76365. * Adds a new color gradient
  76366. * @param gradient defines the gradient to use (between 0 and 1)
  76367. * @param color1 defines the color to affect to the specified gradient
  76368. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  76369. * @returns the current particle system
  76370. */
  76371. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  76372. /**
  76373. * Remove a specific color gradient
  76374. * @param gradient defines the gradient to remove
  76375. * @returns the current particle system
  76376. */
  76377. removeColorGradient(gradient: number): IParticleSystem;
  76378. /**
  76379. * Adds a new size gradient
  76380. * @param gradient defines the gradient to use (between 0 and 1)
  76381. * @param factor defines the size factor to affect to the specified gradient
  76382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76383. * @returns the current particle system
  76384. */
  76385. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76386. /**
  76387. * Remove a specific size gradient
  76388. * @param gradient defines the gradient to remove
  76389. * @returns the current particle system
  76390. */
  76391. removeSizeGradient(gradient: number): IParticleSystem;
  76392. /**
  76393. * Gets the current list of color gradients.
  76394. * You must use addColorGradient and removeColorGradient to udpate this list
  76395. * @returns the list of color gradients
  76396. */
  76397. getColorGradients(): Nullable<Array<ColorGradient>>;
  76398. /**
  76399. * Gets the current list of size gradients.
  76400. * You must use addSizeGradient and removeSizeGradient to udpate this list
  76401. * @returns the list of size gradients
  76402. */
  76403. getSizeGradients(): Nullable<Array<FactorGradient>>;
  76404. /**
  76405. * Gets the current list of angular speed gradients.
  76406. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  76407. * @returns the list of angular speed gradients
  76408. */
  76409. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  76410. /**
  76411. * Adds a new angular speed gradient
  76412. * @param gradient defines the gradient to use (between 0 and 1)
  76413. * @param factor defines the angular speed to affect to the specified gradient
  76414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76415. * @returns the current particle system
  76416. */
  76417. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76418. /**
  76419. * Remove a specific angular speed gradient
  76420. * @param gradient defines the gradient to remove
  76421. * @returns the current particle system
  76422. */
  76423. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  76424. /**
  76425. * Gets the current list of velocity gradients.
  76426. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  76427. * @returns the list of velocity gradients
  76428. */
  76429. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  76430. /**
  76431. * Adds a new velocity gradient
  76432. * @param gradient defines the gradient to use (between 0 and 1)
  76433. * @param factor defines the velocity to affect to the specified gradient
  76434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76435. * @returns the current particle system
  76436. */
  76437. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76438. /**
  76439. * Remove a specific velocity gradient
  76440. * @param gradient defines the gradient to remove
  76441. * @returns the current particle system
  76442. */
  76443. removeVelocityGradient(gradient: number): IParticleSystem;
  76444. /**
  76445. * Gets the current list of limit velocity gradients.
  76446. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76447. * @returns the list of limit velocity gradients
  76448. */
  76449. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76450. /**
  76451. * Adds a new limit velocity gradient
  76452. * @param gradient defines the gradient to use (between 0 and 1)
  76453. * @param factor defines the limit velocity to affect to the specified gradient
  76454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76455. * @returns the current particle system
  76456. */
  76457. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76458. /**
  76459. * Remove a specific limit velocity gradient
  76460. * @param gradient defines the gradient to remove
  76461. * @returns the current particle system
  76462. */
  76463. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  76464. /**
  76465. * Adds a new drag gradient
  76466. * @param gradient defines the gradient to use (between 0 and 1)
  76467. * @param factor defines the drag to affect to the specified gradient
  76468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76469. * @returns the current particle system
  76470. */
  76471. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76472. /**
  76473. * Remove a specific drag gradient
  76474. * @param gradient defines the gradient to remove
  76475. * @returns the current particle system
  76476. */
  76477. removeDragGradient(gradient: number): IParticleSystem;
  76478. /**
  76479. * Gets the current list of drag gradients.
  76480. * You must use addDragGradient and removeDragGradient to udpate this list
  76481. * @returns the list of drag gradients
  76482. */
  76483. getDragGradients(): Nullable<Array<FactorGradient>>;
  76484. /**
  76485. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  76486. * @param gradient defines the gradient to use (between 0 and 1)
  76487. * @param factor defines the emit rate to affect to the specified gradient
  76488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76489. * @returns the current particle system
  76490. */
  76491. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76492. /**
  76493. * Remove a specific emit rate gradient
  76494. * @param gradient defines the gradient to remove
  76495. * @returns the current particle system
  76496. */
  76497. removeEmitRateGradient(gradient: number): IParticleSystem;
  76498. /**
  76499. * Gets the current list of emit rate gradients.
  76500. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  76501. * @returns the list of emit rate gradients
  76502. */
  76503. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  76504. /**
  76505. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  76506. * @param gradient defines the gradient to use (between 0 and 1)
  76507. * @param factor defines the start size to affect to the specified gradient
  76508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76509. * @returns the current particle system
  76510. */
  76511. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76512. /**
  76513. * Remove a specific start size gradient
  76514. * @param gradient defines the gradient to remove
  76515. * @returns the current particle system
  76516. */
  76517. removeStartSizeGradient(gradient: number): IParticleSystem;
  76518. /**
  76519. * Gets the current list of start size gradients.
  76520. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  76521. * @returns the list of start size gradients
  76522. */
  76523. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  76524. /**
  76525. * Adds a new life time gradient
  76526. * @param gradient defines the gradient to use (between 0 and 1)
  76527. * @param factor defines the life time factor to affect to the specified gradient
  76528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76529. * @returns the current particle system
  76530. */
  76531. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76532. /**
  76533. * Remove a specific life time gradient
  76534. * @param gradient defines the gradient to remove
  76535. * @returns the current particle system
  76536. */
  76537. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76538. /**
  76539. * Gets the current list of life time gradients.
  76540. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  76541. * @returns the list of life time gradients
  76542. */
  76543. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  76544. /**
  76545. * Gets the current list of color gradients.
  76546. * You must use addColorGradient and removeColorGradient to udpate this list
  76547. * @returns the list of color gradients
  76548. */
  76549. getColorGradients(): Nullable<Array<ColorGradient>>;
  76550. /**
  76551. * Adds a new ramp gradient used to remap particle colors
  76552. * @param gradient defines the gradient to use (between 0 and 1)
  76553. * @param color defines the color to affect to the specified gradient
  76554. * @returns the current particle system
  76555. */
  76556. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  76557. /**
  76558. * Gets the current list of ramp gradients.
  76559. * You must use addRampGradient and removeRampGradient to udpate this list
  76560. * @returns the list of ramp gradients
  76561. */
  76562. getRampGradients(): Nullable<Array<Color3Gradient>>;
  76563. /** Gets or sets a boolean indicating that ramp gradients must be used
  76564. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76565. */
  76566. useRampGradients: boolean;
  76567. /**
  76568. * Adds a new color remap gradient
  76569. * @param gradient defines the gradient to use (between 0 and 1)
  76570. * @param min defines the color remap minimal range
  76571. * @param max defines the color remap maximal range
  76572. * @returns the current particle system
  76573. */
  76574. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76575. /**
  76576. * Gets the current list of color remap gradients.
  76577. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76578. * @returns the list of color remap gradients
  76579. */
  76580. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76581. /**
  76582. * Adds a new alpha remap gradient
  76583. * @param gradient defines the gradient to use (between 0 and 1)
  76584. * @param min defines the alpha remap minimal range
  76585. * @param max defines the alpha remap maximal range
  76586. * @returns the current particle system
  76587. */
  76588. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76589. /**
  76590. * Gets the current list of alpha remap gradients.
  76591. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76592. * @returns the list of alpha remap gradients
  76593. */
  76594. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  76595. /**
  76596. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  76597. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76598. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76599. * @returns the emitter
  76600. */
  76601. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  76602. /**
  76603. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  76604. * @param radius The radius of the hemisphere to emit from
  76605. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76606. * @returns the emitter
  76607. */
  76608. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  76609. /**
  76610. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  76611. * @param radius The radius of the sphere to emit from
  76612. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76613. * @returns the emitter
  76614. */
  76615. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  76616. /**
  76617. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76618. * @param radius The radius of the sphere to emit from
  76619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  76620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  76621. * @returns the emitter
  76622. */
  76623. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76624. /**
  76625. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  76626. * @param radius The radius of the emission cylinder
  76627. * @param height The height of the emission cylinder
  76628. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  76629. * @param directionRandomizer How much to randomize the particle direction [0-1]
  76630. * @returns the emitter
  76631. */
  76632. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  76633. /**
  76634. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76635. * @param radius The radius of the cylinder to emit from
  76636. * @param height The height of the emission cylinder
  76637. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76638. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76639. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76640. * @returns the emitter
  76641. */
  76642. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76643. /**
  76644. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76645. * @param radius The radius of the cone to emit from
  76646. * @param angle The base angle of the cone
  76647. * @returns the emitter
  76648. */
  76649. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  76650. /**
  76651. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76652. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76653. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76654. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76655. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76656. * @returns the emitter
  76657. */
  76658. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76659. /**
  76660. * Get hosting scene
  76661. * @returns the scene
  76662. */
  76663. getScene(): Scene;
  76664. }
  76665. }
  76666. declare module BABYLON {
  76667. /**
  76668. * Creates an instance based on a source mesh.
  76669. */
  76670. export class InstancedMesh extends AbstractMesh {
  76671. private _sourceMesh;
  76672. private _currentLOD;
  76673. /** @hidden */
  76674. _indexInSourceMeshInstanceArray: number;
  76675. constructor(name: string, source: Mesh);
  76676. /**
  76677. * Returns the string "InstancedMesh".
  76678. */
  76679. getClassName(): string;
  76680. /** Gets the list of lights affecting that mesh */
  76681. readonly lightSources: Light[];
  76682. _resyncLightSources(): void;
  76683. _resyncLighSource(light: Light): void;
  76684. _removeLightSource(light: Light): void;
  76685. /**
  76686. * If the source mesh receives shadows
  76687. */
  76688. readonly receiveShadows: boolean;
  76689. /**
  76690. * The material of the source mesh
  76691. */
  76692. readonly material: Nullable<Material>;
  76693. /**
  76694. * Visibility of the source mesh
  76695. */
  76696. readonly visibility: number;
  76697. /**
  76698. * Skeleton of the source mesh
  76699. */
  76700. readonly skeleton: Nullable<Skeleton>;
  76701. /**
  76702. * Rendering ground id of the source mesh
  76703. */
  76704. renderingGroupId: number;
  76705. /**
  76706. * Returns the total number of vertices (integer).
  76707. */
  76708. getTotalVertices(): number;
  76709. /**
  76710. * Returns a positive integer : the total number of indices in this mesh geometry.
  76711. * @returns the numner of indices or zero if the mesh has no geometry.
  76712. */
  76713. getTotalIndices(): number;
  76714. /**
  76715. * The source mesh of the instance
  76716. */
  76717. readonly sourceMesh: Mesh;
  76718. /**
  76719. * Is this node ready to be used/rendered
  76720. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76721. * @return {boolean} is it ready
  76722. */
  76723. isReady(completeCheck?: boolean): boolean;
  76724. /**
  76725. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76726. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  76727. * @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.
  76728. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  76729. */
  76730. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  76731. /**
  76732. * Sets the vertex data of the mesh geometry for the requested `kind`.
  76733. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  76734. * The `data` are either a numeric array either a Float32Array.
  76735. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  76736. * 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).
  76737. * Note that a new underlying VertexBuffer object is created each call.
  76738. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  76739. *
  76740. * Possible `kind` values :
  76741. * - VertexBuffer.PositionKind
  76742. * - VertexBuffer.UVKind
  76743. * - VertexBuffer.UV2Kind
  76744. * - VertexBuffer.UV3Kind
  76745. * - VertexBuffer.UV4Kind
  76746. * - VertexBuffer.UV5Kind
  76747. * - VertexBuffer.UV6Kind
  76748. * - VertexBuffer.ColorKind
  76749. * - VertexBuffer.MatricesIndicesKind
  76750. * - VertexBuffer.MatricesIndicesExtraKind
  76751. * - VertexBuffer.MatricesWeightsKind
  76752. * - VertexBuffer.MatricesWeightsExtraKind
  76753. *
  76754. * Returns the Mesh.
  76755. */
  76756. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76757. /**
  76758. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  76759. * If the mesh has no geometry, it is simply returned as it is.
  76760. * The `data` are either a numeric array either a Float32Array.
  76761. * No new underlying VertexBuffer object is created.
  76762. * 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.
  76763. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  76764. *
  76765. * Possible `kind` values :
  76766. * - VertexBuffer.PositionKind
  76767. * - VertexBuffer.UVKind
  76768. * - VertexBuffer.UV2Kind
  76769. * - VertexBuffer.UV3Kind
  76770. * - VertexBuffer.UV4Kind
  76771. * - VertexBuffer.UV5Kind
  76772. * - VertexBuffer.UV6Kind
  76773. * - VertexBuffer.ColorKind
  76774. * - VertexBuffer.MatricesIndicesKind
  76775. * - VertexBuffer.MatricesIndicesExtraKind
  76776. * - VertexBuffer.MatricesWeightsKind
  76777. * - VertexBuffer.MatricesWeightsExtraKind
  76778. *
  76779. * Returns the Mesh.
  76780. */
  76781. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76782. /**
  76783. * Sets the mesh indices.
  76784. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76785. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76786. * This method creates a new index buffer each call.
  76787. * Returns the Mesh.
  76788. */
  76789. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76790. /**
  76791. * Boolean : True if the mesh owns the requested kind of data.
  76792. */
  76793. isVerticesDataPresent(kind: string): boolean;
  76794. /**
  76795. * Returns an array of indices (IndicesArray).
  76796. */
  76797. getIndices(): Nullable<IndicesArray>;
  76798. readonly _positions: Nullable<Vector3[]>;
  76799. /**
  76800. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76801. * This means the mesh underlying bounding box and sphere are recomputed.
  76802. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76803. * @returns the current mesh
  76804. */
  76805. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76806. /** @hidden */
  76807. _preActivate(): InstancedMesh;
  76808. /** @hidden */
  76809. _activate(renderId: number): boolean;
  76810. /** @hidden */
  76811. _postActivate(): void;
  76812. getWorldMatrix(): Matrix;
  76813. readonly isAnInstance: boolean;
  76814. /**
  76815. * Returns the current associated LOD AbstractMesh.
  76816. */
  76817. getLOD(camera: Camera): AbstractMesh;
  76818. /** @hidden */
  76819. _syncSubMeshes(): InstancedMesh;
  76820. /** @hidden */
  76821. _generatePointsArray(): boolean;
  76822. /**
  76823. * Creates a new InstancedMesh from the current mesh.
  76824. * - name (string) : the cloned mesh name
  76825. * - newParent (optional Node) : the optional Node to parent the clone to.
  76826. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76827. *
  76828. * Returns the clone.
  76829. */
  76830. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76831. /**
  76832. * Disposes the InstancedMesh.
  76833. * Returns nothing.
  76834. */
  76835. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76836. }
  76837. }
  76838. declare module BABYLON {
  76839. /**
  76840. * Defines the options associated with the creation of a shader material.
  76841. */
  76842. export interface IShaderMaterialOptions {
  76843. /**
  76844. * Does the material work in alpha blend mode
  76845. */
  76846. needAlphaBlending: boolean;
  76847. /**
  76848. * Does the material work in alpha test mode
  76849. */
  76850. needAlphaTesting: boolean;
  76851. /**
  76852. * The list of attribute names used in the shader
  76853. */
  76854. attributes: string[];
  76855. /**
  76856. * The list of unifrom names used in the shader
  76857. */
  76858. uniforms: string[];
  76859. /**
  76860. * The list of UBO names used in the shader
  76861. */
  76862. uniformBuffers: string[];
  76863. /**
  76864. * The list of sampler names used in the shader
  76865. */
  76866. samplers: string[];
  76867. /**
  76868. * The list of defines used in the shader
  76869. */
  76870. defines: string[];
  76871. }
  76872. /**
  76873. * 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.
  76874. *
  76875. * This returned material effects how the mesh will look based on the code in the shaders.
  76876. *
  76877. * @see http://doc.babylonjs.com/how_to/shader_material
  76878. */
  76879. export class ShaderMaterial extends Material {
  76880. private _shaderPath;
  76881. private _options;
  76882. private _textures;
  76883. private _textureArrays;
  76884. private _floats;
  76885. private _ints;
  76886. private _floatsArrays;
  76887. private _colors3;
  76888. private _colors3Arrays;
  76889. private _colors4;
  76890. private _vectors2;
  76891. private _vectors3;
  76892. private _vectors4;
  76893. private _matrices;
  76894. private _matrices3x3;
  76895. private _matrices2x2;
  76896. private _vectors2Arrays;
  76897. private _vectors3Arrays;
  76898. private _cachedWorldViewMatrix;
  76899. private _renderId;
  76900. /**
  76901. * Instantiate a new shader material.
  76902. * 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.
  76903. * This returned material effects how the mesh will look based on the code in the shaders.
  76904. * @see http://doc.babylonjs.com/how_to/shader_material
  76905. * @param name Define the name of the material in the scene
  76906. * @param scene Define the scene the material belongs to
  76907. * @param shaderPath Defines the route to the shader code in one of three ways:
  76908. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76909. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76910. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76911. * @param options Define the options used to create the shader
  76912. */
  76913. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76914. /**
  76915. * Gets the options used to compile the shader.
  76916. * They can be modified to trigger a new compilation
  76917. */
  76918. readonly options: IShaderMaterialOptions;
  76919. /**
  76920. * Gets the current class name of the material e.g. "ShaderMaterial"
  76921. * Mainly use in serialization.
  76922. * @returns the class name
  76923. */
  76924. getClassName(): string;
  76925. /**
  76926. * Specifies if the material will require alpha blending
  76927. * @returns a boolean specifying if alpha blending is needed
  76928. */
  76929. needAlphaBlending(): boolean;
  76930. /**
  76931. * Specifies if this material should be rendered in alpha test mode
  76932. * @returns a boolean specifying if an alpha test is needed.
  76933. */
  76934. needAlphaTesting(): boolean;
  76935. private _checkUniform;
  76936. /**
  76937. * Set a texture in the shader.
  76938. * @param name Define the name of the uniform samplers as defined in the shader
  76939. * @param texture Define the texture to bind to this sampler
  76940. * @return the material itself allowing "fluent" like uniform updates
  76941. */
  76942. setTexture(name: string, texture: Texture): ShaderMaterial;
  76943. /**
  76944. * Set a texture array in the shader.
  76945. * @param name Define the name of the uniform sampler array as defined in the shader
  76946. * @param textures Define the list of textures to bind to this sampler
  76947. * @return the material itself allowing "fluent" like uniform updates
  76948. */
  76949. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76950. /**
  76951. * Set a float in the shader.
  76952. * @param name Define the name of the uniform as defined in the shader
  76953. * @param value Define the value to give to the uniform
  76954. * @return the material itself allowing "fluent" like uniform updates
  76955. */
  76956. setFloat(name: string, value: number): ShaderMaterial;
  76957. /**
  76958. * Set a int in the shader.
  76959. * @param name Define the name of the uniform as defined in the shader
  76960. * @param value Define the value to give to the uniform
  76961. * @return the material itself allowing "fluent" like uniform updates
  76962. */
  76963. setInt(name: string, value: number): ShaderMaterial;
  76964. /**
  76965. * Set an array of floats in the shader.
  76966. * @param name Define the name of the uniform as defined in the shader
  76967. * @param value Define the value to give to the uniform
  76968. * @return the material itself allowing "fluent" like uniform updates
  76969. */
  76970. setFloats(name: string, value: number[]): ShaderMaterial;
  76971. /**
  76972. * Set a vec3 in the shader from a Color3.
  76973. * @param name Define the name of the uniform as defined in the shader
  76974. * @param value Define the value to give to the uniform
  76975. * @return the material itself allowing "fluent" like uniform updates
  76976. */
  76977. setColor3(name: string, value: Color3): ShaderMaterial;
  76978. /**
  76979. * Set a vec3 array in the shader from a Color3 array.
  76980. * @param name Define the name of the uniform as defined in the shader
  76981. * @param value Define the value to give to the uniform
  76982. * @return the material itself allowing "fluent" like uniform updates
  76983. */
  76984. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76985. /**
  76986. * Set a vec4 in the shader from a Color4.
  76987. * @param name Define the name of the uniform as defined in the shader
  76988. * @param value Define the value to give to the uniform
  76989. * @return the material itself allowing "fluent" like uniform updates
  76990. */
  76991. setColor4(name: string, value: Color4): ShaderMaterial;
  76992. /**
  76993. * Set a vec2 in the shader from a Vector2.
  76994. * @param name Define the name of the uniform as defined in the shader
  76995. * @param value Define the value to give to the uniform
  76996. * @return the material itself allowing "fluent" like uniform updates
  76997. */
  76998. setVector2(name: string, value: Vector2): ShaderMaterial;
  76999. /**
  77000. * Set a vec3 in the shader from a Vector3.
  77001. * @param name Define the name of the uniform as defined in the shader
  77002. * @param value Define the value to give to the uniform
  77003. * @return the material itself allowing "fluent" like uniform updates
  77004. */
  77005. setVector3(name: string, value: Vector3): ShaderMaterial;
  77006. /**
  77007. * Set a vec4 in the shader from a Vector4.
  77008. * @param name Define the name of the uniform as defined in the shader
  77009. * @param value Define the value to give to the uniform
  77010. * @return the material itself allowing "fluent" like uniform updates
  77011. */
  77012. setVector4(name: string, value: Vector4): ShaderMaterial;
  77013. /**
  77014. * Set a mat4 in the shader from a Matrix.
  77015. * @param name Define the name of the uniform as defined in the shader
  77016. * @param value Define the value to give to the uniform
  77017. * @return the material itself allowing "fluent" like uniform updates
  77018. */
  77019. setMatrix(name: string, value: Matrix): ShaderMaterial;
  77020. /**
  77021. * Set a mat3 in the shader from a Float32Array.
  77022. * @param name Define the name of the uniform as defined in the shader
  77023. * @param value Define the value to give to the uniform
  77024. * @return the material itself allowing "fluent" like uniform updates
  77025. */
  77026. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  77027. /**
  77028. * Set a mat2 in the shader from a Float32Array.
  77029. * @param name Define the name of the uniform as defined in the shader
  77030. * @param value Define the value to give to the uniform
  77031. * @return the material itself allowing "fluent" like uniform updates
  77032. */
  77033. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  77034. /**
  77035. * Set a vec2 array in the shader from a number array.
  77036. * @param name Define the name of the uniform as defined in the shader
  77037. * @param value Define the value to give to the uniform
  77038. * @return the material itself allowing "fluent" like uniform updates
  77039. */
  77040. setArray2(name: string, value: number[]): ShaderMaterial;
  77041. /**
  77042. * Set a vec3 array in the shader from a number array.
  77043. * @param name Define the name of the uniform as defined in the shader
  77044. * @param value Define the value to give to the uniform
  77045. * @return the material itself allowing "fluent" like uniform updates
  77046. */
  77047. setArray3(name: string, value: number[]): ShaderMaterial;
  77048. private _checkCache;
  77049. /**
  77050. * Specifies that the submesh is ready to be used
  77051. * @param mesh defines the mesh to check
  77052. * @param subMesh defines which submesh to check
  77053. * @param useInstances specifies that instances should be used
  77054. * @returns a boolean indicating that the submesh is ready or not
  77055. */
  77056. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77057. /**
  77058. * Checks if the material is ready to render the requested mesh
  77059. * @param mesh Define the mesh to render
  77060. * @param useInstances Define whether or not the material is used with instances
  77061. * @returns true if ready, otherwise false
  77062. */
  77063. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  77064. /**
  77065. * Binds the world matrix to the material
  77066. * @param world defines the world transformation matrix
  77067. */
  77068. bindOnlyWorldMatrix(world: Matrix): void;
  77069. /**
  77070. * Binds the material to the mesh
  77071. * @param world defines the world transformation matrix
  77072. * @param mesh defines the mesh to bind the material to
  77073. */
  77074. bind(world: Matrix, mesh?: Mesh): void;
  77075. /**
  77076. * Gets the active textures from the material
  77077. * @returns an array of textures
  77078. */
  77079. getActiveTextures(): BaseTexture[];
  77080. /**
  77081. * Specifies if the material uses a texture
  77082. * @param texture defines the texture to check against the material
  77083. * @returns a boolean specifying if the material uses the texture
  77084. */
  77085. hasTexture(texture: BaseTexture): boolean;
  77086. /**
  77087. * Makes a duplicate of the material, and gives it a new name
  77088. * @param name defines the new name for the duplicated material
  77089. * @returns the cloned material
  77090. */
  77091. clone(name: string): ShaderMaterial;
  77092. /**
  77093. * Disposes the material
  77094. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77095. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77096. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77097. */
  77098. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  77099. /**
  77100. * Serializes this material in a JSON representation
  77101. * @returns the serialized material object
  77102. */
  77103. serialize(): any;
  77104. /**
  77105. * Creates a shader material from parsed shader material data
  77106. * @param source defines the JSON represnetation of the material
  77107. * @param scene defines the hosting scene
  77108. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  77109. * @returns a new material
  77110. */
  77111. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  77112. }
  77113. }
  77114. declare module BABYLON {
  77115. /** @hidden */
  77116. export var colorPixelShader: {
  77117. name: string;
  77118. shader: string;
  77119. };
  77120. }
  77121. declare module BABYLON {
  77122. /** @hidden */
  77123. export var colorVertexShader: {
  77124. name: string;
  77125. shader: string;
  77126. };
  77127. }
  77128. declare module BABYLON {
  77129. /**
  77130. * Line mesh
  77131. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  77132. */
  77133. export class LinesMesh extends Mesh {
  77134. /**
  77135. * If vertex color should be applied to the mesh
  77136. */
  77137. useVertexColor?: boolean | undefined;
  77138. /**
  77139. * If vertex alpha should be applied to the mesh
  77140. */
  77141. useVertexAlpha?: boolean | undefined;
  77142. /**
  77143. * Color of the line (Default: White)
  77144. */
  77145. color: Color3;
  77146. /**
  77147. * Alpha of the line (Default: 1)
  77148. */
  77149. alpha: number;
  77150. /**
  77151. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77152. * This margin is expressed in world space coordinates, so its value may vary.
  77153. * Default value is 0.1
  77154. */
  77155. intersectionThreshold: number;
  77156. private _colorShader;
  77157. /**
  77158. * Creates a new LinesMesh
  77159. * @param name defines the name
  77160. * @param scene defines the hosting scene
  77161. * @param parent defines the parent mesh if any
  77162. * @param source defines the optional source LinesMesh used to clone data from
  77163. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77164. * When false, achieved by calling a clone(), also passing False.
  77165. * This will make creation of children, recursive.
  77166. * @param useVertexColor defines if this LinesMesh supports vertex color
  77167. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  77168. */
  77169. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  77170. /**
  77171. * If vertex color should be applied to the mesh
  77172. */
  77173. useVertexColor?: boolean | undefined,
  77174. /**
  77175. * If vertex alpha should be applied to the mesh
  77176. */
  77177. useVertexAlpha?: boolean | undefined);
  77178. private _addClipPlaneDefine;
  77179. private _removeClipPlaneDefine;
  77180. isReady(): boolean;
  77181. /**
  77182. * Returns the string "LineMesh"
  77183. */
  77184. getClassName(): string;
  77185. /**
  77186. * @hidden
  77187. */
  77188. /**
  77189. * @hidden
  77190. */
  77191. material: Material;
  77192. /**
  77193. * @hidden
  77194. */
  77195. readonly checkCollisions: boolean;
  77196. /** @hidden */
  77197. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  77198. /** @hidden */
  77199. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  77200. /**
  77201. * Disposes of the line mesh
  77202. * @param doNotRecurse If children should be disposed
  77203. */
  77204. dispose(doNotRecurse?: boolean): void;
  77205. /**
  77206. * Returns a new LineMesh object cloned from the current one.
  77207. */
  77208. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  77209. /**
  77210. * Creates a new InstancedLinesMesh object from the mesh model.
  77211. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77212. * @param name defines the name of the new instance
  77213. * @returns a new InstancedLinesMesh
  77214. */
  77215. createInstance(name: string): InstancedLinesMesh;
  77216. }
  77217. /**
  77218. * Creates an instance based on a source LinesMesh
  77219. */
  77220. export class InstancedLinesMesh extends InstancedMesh {
  77221. /**
  77222. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77223. * This margin is expressed in world space coordinates, so its value may vary.
  77224. * Initilized with the intersectionThreshold value of the source LinesMesh
  77225. */
  77226. intersectionThreshold: number;
  77227. constructor(name: string, source: LinesMesh);
  77228. /**
  77229. * Returns the string "InstancedLinesMesh".
  77230. */
  77231. getClassName(): string;
  77232. }
  77233. }
  77234. declare module BABYLON {
  77235. /** @hidden */
  77236. export var linePixelShader: {
  77237. name: string;
  77238. shader: string;
  77239. };
  77240. }
  77241. declare module BABYLON {
  77242. /** @hidden */
  77243. export var lineVertexShader: {
  77244. name: string;
  77245. shader: string;
  77246. };
  77247. }
  77248. declare module BABYLON {
  77249. interface AbstractMesh {
  77250. /**
  77251. * Disables the mesh edge rendering mode
  77252. * @returns the currentAbstractMesh
  77253. */
  77254. disableEdgesRendering(): AbstractMesh;
  77255. /**
  77256. * Enables the edge rendering mode on the mesh.
  77257. * This mode makes the mesh edges visible
  77258. * @param epsilon defines the maximal distance between two angles to detect a face
  77259. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77260. * @returns the currentAbstractMesh
  77261. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77262. */
  77263. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77264. /**
  77265. * Gets the edgesRenderer associated with the mesh
  77266. */
  77267. edgesRenderer: Nullable<EdgesRenderer>;
  77268. }
  77269. interface LinesMesh {
  77270. /**
  77271. * Enables the edge rendering mode on the mesh.
  77272. * This mode makes the mesh edges visible
  77273. * @param epsilon defines the maximal distance between two angles to detect a face
  77274. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77275. * @returns the currentAbstractMesh
  77276. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77277. */
  77278. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77279. }
  77280. interface InstancedLinesMesh {
  77281. /**
  77282. * Enables the edge rendering mode on the mesh.
  77283. * This mode makes the mesh edges visible
  77284. * @param epsilon defines the maximal distance between two angles to detect a face
  77285. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77286. * @returns the current InstancedLinesMesh
  77287. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77288. */
  77289. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  77290. }
  77291. /**
  77292. * Defines the minimum contract an Edges renderer should follow.
  77293. */
  77294. export interface IEdgesRenderer extends IDisposable {
  77295. /**
  77296. * Gets or sets a boolean indicating if the edgesRenderer is active
  77297. */
  77298. isEnabled: boolean;
  77299. /**
  77300. * Renders the edges of the attached mesh,
  77301. */
  77302. render(): void;
  77303. /**
  77304. * Checks wether or not the edges renderer is ready to render.
  77305. * @return true if ready, otherwise false.
  77306. */
  77307. isReady(): boolean;
  77308. }
  77309. /**
  77310. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  77311. */
  77312. export class EdgesRenderer implements IEdgesRenderer {
  77313. /**
  77314. * Define the size of the edges with an orthographic camera
  77315. */
  77316. edgesWidthScalerForOrthographic: number;
  77317. /**
  77318. * Define the size of the edges with a perspective camera
  77319. */
  77320. edgesWidthScalerForPerspective: number;
  77321. protected _source: AbstractMesh;
  77322. protected _linesPositions: number[];
  77323. protected _linesNormals: number[];
  77324. protected _linesIndices: number[];
  77325. protected _epsilon: number;
  77326. protected _indicesCount: number;
  77327. protected _lineShader: ShaderMaterial;
  77328. protected _ib: DataBuffer;
  77329. protected _buffers: {
  77330. [key: string]: Nullable<VertexBuffer>;
  77331. };
  77332. protected _checkVerticesInsteadOfIndices: boolean;
  77333. private _meshRebuildObserver;
  77334. private _meshDisposeObserver;
  77335. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  77336. isEnabled: boolean;
  77337. /**
  77338. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  77339. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  77340. * @param source Mesh used to create edges
  77341. * @param epsilon sum of angles in adjacency to check for edge
  77342. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  77343. * @param generateEdgesLines - should generate Lines or only prepare resources.
  77344. */
  77345. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  77346. protected _prepareRessources(): void;
  77347. /** @hidden */
  77348. _rebuild(): void;
  77349. /**
  77350. * Releases the required resources for the edges renderer
  77351. */
  77352. dispose(): void;
  77353. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  77354. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  77355. /**
  77356. * Checks if the pair of p0 and p1 is en edge
  77357. * @param faceIndex
  77358. * @param edge
  77359. * @param faceNormals
  77360. * @param p0
  77361. * @param p1
  77362. * @private
  77363. */
  77364. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  77365. /**
  77366. * push line into the position, normal and index buffer
  77367. * @protected
  77368. */
  77369. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  77370. /**
  77371. * Generates lines edges from adjacencjes
  77372. * @private
  77373. */
  77374. _generateEdgesLines(): void;
  77375. /**
  77376. * Checks wether or not the edges renderer is ready to render.
  77377. * @return true if ready, otherwise false.
  77378. */
  77379. isReady(): boolean;
  77380. /**
  77381. * Renders the edges of the attached mesh,
  77382. */
  77383. render(): void;
  77384. }
  77385. /**
  77386. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  77387. */
  77388. export class LineEdgesRenderer extends EdgesRenderer {
  77389. /**
  77390. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  77391. * @param source LineMesh used to generate edges
  77392. * @param epsilon not important (specified angle for edge detection)
  77393. * @param checkVerticesInsteadOfIndices not important for LineMesh
  77394. */
  77395. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  77396. /**
  77397. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  77398. */
  77399. _generateEdgesLines(): void;
  77400. }
  77401. }
  77402. declare module BABYLON {
  77403. /**
  77404. * This represents the object necessary to create a rendering group.
  77405. * This is exclusively used and created by the rendering manager.
  77406. * To modify the behavior, you use the available helpers in your scene or meshes.
  77407. * @hidden
  77408. */
  77409. export class RenderingGroup {
  77410. index: number;
  77411. private _scene;
  77412. private _opaqueSubMeshes;
  77413. private _transparentSubMeshes;
  77414. private _alphaTestSubMeshes;
  77415. private _depthOnlySubMeshes;
  77416. private _particleSystems;
  77417. private _spriteManagers;
  77418. private _opaqueSortCompareFn;
  77419. private _alphaTestSortCompareFn;
  77420. private _transparentSortCompareFn;
  77421. private _renderOpaque;
  77422. private _renderAlphaTest;
  77423. private _renderTransparent;
  77424. /** @hidden */
  77425. _edgesRenderers: SmartArray<IEdgesRenderer>;
  77426. onBeforeTransparentRendering: () => void;
  77427. /**
  77428. * Set the opaque sort comparison function.
  77429. * If null the sub meshes will be render in the order they were created
  77430. */
  77431. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77432. /**
  77433. * Set the alpha test sort comparison function.
  77434. * If null the sub meshes will be render in the order they were created
  77435. */
  77436. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77437. /**
  77438. * Set the transparent sort comparison function.
  77439. * If null the sub meshes will be render in the order they were created
  77440. */
  77441. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77442. /**
  77443. * Creates a new rendering group.
  77444. * @param index The rendering group index
  77445. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  77446. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  77447. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  77448. */
  77449. 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>);
  77450. /**
  77451. * Render all the sub meshes contained in the group.
  77452. * @param customRenderFunction Used to override the default render behaviour of the group.
  77453. * @returns true if rendered some submeshes.
  77454. */
  77455. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  77456. /**
  77457. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  77458. * @param subMeshes The submeshes to render
  77459. */
  77460. private renderOpaqueSorted;
  77461. /**
  77462. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  77463. * @param subMeshes The submeshes to render
  77464. */
  77465. private renderAlphaTestSorted;
  77466. /**
  77467. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  77468. * @param subMeshes The submeshes to render
  77469. */
  77470. private renderTransparentSorted;
  77471. /**
  77472. * Renders the submeshes in a specified order.
  77473. * @param subMeshes The submeshes to sort before render
  77474. * @param sortCompareFn The comparison function use to sort
  77475. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  77476. * @param transparent Specifies to activate blending if true
  77477. */
  77478. private static renderSorted;
  77479. /**
  77480. * Renders the submeshes in the order they were dispatched (no sort applied).
  77481. * @param subMeshes The submeshes to render
  77482. */
  77483. private static renderUnsorted;
  77484. /**
  77485. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77486. * are rendered back to front if in the same alpha index.
  77487. *
  77488. * @param a The first submesh
  77489. * @param b The second submesh
  77490. * @returns The result of the comparison
  77491. */
  77492. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  77493. /**
  77494. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77495. * are rendered back to front.
  77496. *
  77497. * @param a The first submesh
  77498. * @param b The second submesh
  77499. * @returns The result of the comparison
  77500. */
  77501. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  77502. /**
  77503. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77504. * are rendered front to back (prevent overdraw).
  77505. *
  77506. * @param a The first submesh
  77507. * @param b The second submesh
  77508. * @returns The result of the comparison
  77509. */
  77510. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  77511. /**
  77512. * Resets the different lists of submeshes to prepare a new frame.
  77513. */
  77514. prepare(): void;
  77515. dispose(): void;
  77516. /**
  77517. * Inserts the submesh in its correct queue depending on its material.
  77518. * @param subMesh The submesh to dispatch
  77519. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77520. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77521. */
  77522. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77523. dispatchSprites(spriteManager: ISpriteManager): void;
  77524. dispatchParticles(particleSystem: IParticleSystem): void;
  77525. private _renderParticles;
  77526. private _renderSprites;
  77527. }
  77528. }
  77529. declare module BABYLON {
  77530. /**
  77531. * Interface describing the different options available in the rendering manager
  77532. * regarding Auto Clear between groups.
  77533. */
  77534. export interface IRenderingManagerAutoClearSetup {
  77535. /**
  77536. * Defines whether or not autoclear is enable.
  77537. */
  77538. autoClear: boolean;
  77539. /**
  77540. * Defines whether or not to autoclear the depth buffer.
  77541. */
  77542. depth: boolean;
  77543. /**
  77544. * Defines whether or not to autoclear the stencil buffer.
  77545. */
  77546. stencil: boolean;
  77547. }
  77548. /**
  77549. * This class is used by the onRenderingGroupObservable
  77550. */
  77551. export class RenderingGroupInfo {
  77552. /**
  77553. * The Scene that being rendered
  77554. */
  77555. scene: Scene;
  77556. /**
  77557. * The camera currently used for the rendering pass
  77558. */
  77559. camera: Nullable<Camera>;
  77560. /**
  77561. * The ID of the renderingGroup being processed
  77562. */
  77563. renderingGroupId: number;
  77564. }
  77565. /**
  77566. * This is the manager responsible of all the rendering for meshes sprites and particles.
  77567. * It is enable to manage the different groups as well as the different necessary sort functions.
  77568. * This should not be used directly aside of the few static configurations
  77569. */
  77570. export class RenderingManager {
  77571. /**
  77572. * The max id used for rendering groups (not included)
  77573. */
  77574. static MAX_RENDERINGGROUPS: number;
  77575. /**
  77576. * The min id used for rendering groups (included)
  77577. */
  77578. static MIN_RENDERINGGROUPS: number;
  77579. /**
  77580. * Used to globally prevent autoclearing scenes.
  77581. */
  77582. static AUTOCLEAR: boolean;
  77583. /**
  77584. * @hidden
  77585. */
  77586. _useSceneAutoClearSetup: boolean;
  77587. private _scene;
  77588. private _renderingGroups;
  77589. private _depthStencilBufferAlreadyCleaned;
  77590. private _autoClearDepthStencil;
  77591. private _customOpaqueSortCompareFn;
  77592. private _customAlphaTestSortCompareFn;
  77593. private _customTransparentSortCompareFn;
  77594. private _renderingGroupInfo;
  77595. /**
  77596. * Instantiates a new rendering group for a particular scene
  77597. * @param scene Defines the scene the groups belongs to
  77598. */
  77599. constructor(scene: Scene);
  77600. private _clearDepthStencilBuffer;
  77601. /**
  77602. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  77603. * @hidden
  77604. */
  77605. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  77606. /**
  77607. * Resets the different information of the group to prepare a new frame
  77608. * @hidden
  77609. */
  77610. reset(): void;
  77611. /**
  77612. * Dispose and release the group and its associated resources.
  77613. * @hidden
  77614. */
  77615. dispose(): void;
  77616. /**
  77617. * Clear the info related to rendering groups preventing retention points during dispose.
  77618. */
  77619. freeRenderingGroups(): void;
  77620. private _prepareRenderingGroup;
  77621. /**
  77622. * Add a sprite manager to the rendering manager in order to render it this frame.
  77623. * @param spriteManager Define the sprite manager to render
  77624. */
  77625. dispatchSprites(spriteManager: ISpriteManager): void;
  77626. /**
  77627. * Add a particle system to the rendering manager in order to render it this frame.
  77628. * @param particleSystem Define the particle system to render
  77629. */
  77630. dispatchParticles(particleSystem: IParticleSystem): void;
  77631. /**
  77632. * Add a submesh to the manager in order to render it this frame
  77633. * @param subMesh The submesh to dispatch
  77634. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77635. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77636. */
  77637. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77638. /**
  77639. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77640. * This allowed control for front to back rendering or reversly depending of the special needs.
  77641. *
  77642. * @param renderingGroupId The rendering group id corresponding to its index
  77643. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77644. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77645. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77646. */
  77647. 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;
  77648. /**
  77649. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77650. *
  77651. * @param renderingGroupId The rendering group id corresponding to its index
  77652. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77653. * @param depth Automatically clears depth between groups if true and autoClear is true.
  77654. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  77655. */
  77656. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  77657. /**
  77658. * Gets the current auto clear configuration for one rendering group of the rendering
  77659. * manager.
  77660. * @param index the rendering group index to get the information for
  77661. * @returns The auto clear setup for the requested rendering group
  77662. */
  77663. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  77664. }
  77665. }
  77666. declare module BABYLON {
  77667. /**
  77668. * This Helps creating a texture that will be created from a camera in your scene.
  77669. * It is basically a dynamic texture that could be used to create special effects for instance.
  77670. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  77671. */
  77672. export class RenderTargetTexture extends Texture {
  77673. isCube: boolean;
  77674. /**
  77675. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  77676. */
  77677. static readonly REFRESHRATE_RENDER_ONCE: number;
  77678. /**
  77679. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  77680. */
  77681. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  77682. /**
  77683. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  77684. * the central point of your effect and can save a lot of performances.
  77685. */
  77686. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  77687. /**
  77688. * Use this predicate to dynamically define the list of mesh you want to render.
  77689. * If set, the renderList property will be overwritten.
  77690. */
  77691. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  77692. private _renderList;
  77693. /**
  77694. * Use this list to define the list of mesh you want to render.
  77695. */
  77696. renderList: Nullable<Array<AbstractMesh>>;
  77697. private _hookArray;
  77698. /**
  77699. * Define if particles should be rendered in your texture.
  77700. */
  77701. renderParticles: boolean;
  77702. /**
  77703. * Define if sprites should be rendered in your texture.
  77704. */
  77705. renderSprites: boolean;
  77706. /**
  77707. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  77708. */
  77709. coordinatesMode: number;
  77710. /**
  77711. * Define the camera used to render the texture.
  77712. */
  77713. activeCamera: Nullable<Camera>;
  77714. /**
  77715. * Override the render function of the texture with your own one.
  77716. */
  77717. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  77718. /**
  77719. * Define if camera post processes should be use while rendering the texture.
  77720. */
  77721. useCameraPostProcesses: boolean;
  77722. /**
  77723. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  77724. */
  77725. ignoreCameraViewport: boolean;
  77726. private _postProcessManager;
  77727. private _postProcesses;
  77728. private _resizeObserver;
  77729. /**
  77730. * An event triggered when the texture is unbind.
  77731. */
  77732. onBeforeBindObservable: Observable<RenderTargetTexture>;
  77733. /**
  77734. * An event triggered when the texture is unbind.
  77735. */
  77736. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  77737. private _onAfterUnbindObserver;
  77738. /**
  77739. * Set a after unbind callback in the texture.
  77740. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  77741. */
  77742. onAfterUnbind: () => void;
  77743. /**
  77744. * An event triggered before rendering the texture
  77745. */
  77746. onBeforeRenderObservable: Observable<number>;
  77747. private _onBeforeRenderObserver;
  77748. /**
  77749. * Set a before render callback in the texture.
  77750. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  77751. */
  77752. onBeforeRender: (faceIndex: number) => void;
  77753. /**
  77754. * An event triggered after rendering the texture
  77755. */
  77756. onAfterRenderObservable: Observable<number>;
  77757. private _onAfterRenderObserver;
  77758. /**
  77759. * Set a after render callback in the texture.
  77760. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  77761. */
  77762. onAfterRender: (faceIndex: number) => void;
  77763. /**
  77764. * An event triggered after the texture clear
  77765. */
  77766. onClearObservable: Observable<Engine>;
  77767. private _onClearObserver;
  77768. /**
  77769. * Set a clear callback in the texture.
  77770. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  77771. */
  77772. onClear: (Engine: Engine) => void;
  77773. /**
  77774. * Define the clear color of the Render Target if it should be different from the scene.
  77775. */
  77776. clearColor: Color4;
  77777. protected _size: number | {
  77778. width: number;
  77779. height: number;
  77780. };
  77781. protected _initialSizeParameter: number | {
  77782. width: number;
  77783. height: number;
  77784. } | {
  77785. ratio: number;
  77786. };
  77787. protected _sizeRatio: Nullable<number>;
  77788. /** @hidden */
  77789. _generateMipMaps: boolean;
  77790. protected _renderingManager: RenderingManager;
  77791. /** @hidden */
  77792. _waitingRenderList: string[];
  77793. protected _doNotChangeAspectRatio: boolean;
  77794. protected _currentRefreshId: number;
  77795. protected _refreshRate: number;
  77796. protected _textureMatrix: Matrix;
  77797. protected _samples: number;
  77798. protected _renderTargetOptions: RenderTargetCreationOptions;
  77799. /**
  77800. * Gets render target creation options that were used.
  77801. */
  77802. readonly renderTargetOptions: RenderTargetCreationOptions;
  77803. protected _engine: Engine;
  77804. protected _onRatioRescale(): void;
  77805. /**
  77806. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77807. * It must define where the camera used to render the texture is set
  77808. */
  77809. boundingBoxPosition: Vector3;
  77810. private _boundingBoxSize;
  77811. /**
  77812. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77813. * When defined, the cubemap will switch to local mode
  77814. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77815. * @example https://www.babylonjs-playground.com/#RNASML
  77816. */
  77817. boundingBoxSize: Vector3;
  77818. /**
  77819. * In case the RTT has been created with a depth texture, get the associated
  77820. * depth texture.
  77821. * Otherwise, return null.
  77822. */
  77823. depthStencilTexture: Nullable<InternalTexture>;
  77824. /**
  77825. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77826. * or used a shadow, depth texture...
  77827. * @param name The friendly name of the texture
  77828. * @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)
  77829. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77830. * @param generateMipMaps True if mip maps need to be generated after render.
  77831. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77832. * @param type The type of the buffer in the RTT (int, half float, float...)
  77833. * @param isCube True if a cube texture needs to be created
  77834. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77835. * @param generateDepthBuffer True to generate a depth buffer
  77836. * @param generateStencilBuffer True to generate a stencil buffer
  77837. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77838. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77839. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77840. */
  77841. constructor(name: string, size: number | {
  77842. width: number;
  77843. height: number;
  77844. } | {
  77845. ratio: number;
  77846. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77847. /**
  77848. * Creates a depth stencil texture.
  77849. * This is only available in WebGL 2 or with the depth texture extension available.
  77850. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77851. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77852. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77853. */
  77854. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77855. private _processSizeParameter;
  77856. /**
  77857. * Define the number of samples to use in case of MSAA.
  77858. * It defaults to one meaning no MSAA has been enabled.
  77859. */
  77860. samples: number;
  77861. /**
  77862. * Resets the refresh counter of the texture and start bak from scratch.
  77863. * Could be useful to regenerate the texture if it is setup to render only once.
  77864. */
  77865. resetRefreshCounter(): void;
  77866. /**
  77867. * Define the refresh rate of the texture or the rendering frequency.
  77868. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77869. */
  77870. refreshRate: number;
  77871. /**
  77872. * Adds a post process to the render target rendering passes.
  77873. * @param postProcess define the post process to add
  77874. */
  77875. addPostProcess(postProcess: PostProcess): void;
  77876. /**
  77877. * Clear all the post processes attached to the render target
  77878. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77879. */
  77880. clearPostProcesses(dispose?: boolean): void;
  77881. /**
  77882. * Remove one of the post process from the list of attached post processes to the texture
  77883. * @param postProcess define the post process to remove from the list
  77884. */
  77885. removePostProcess(postProcess: PostProcess): void;
  77886. /** @hidden */
  77887. _shouldRender(): boolean;
  77888. /**
  77889. * Gets the actual render size of the texture.
  77890. * @returns the width of the render size
  77891. */
  77892. getRenderSize(): number;
  77893. /**
  77894. * Gets the actual render width of the texture.
  77895. * @returns the width of the render size
  77896. */
  77897. getRenderWidth(): number;
  77898. /**
  77899. * Gets the actual render height of the texture.
  77900. * @returns the height of the render size
  77901. */
  77902. getRenderHeight(): number;
  77903. /**
  77904. * Get if the texture can be rescaled or not.
  77905. */
  77906. readonly canRescale: boolean;
  77907. /**
  77908. * Resize the texture using a ratio.
  77909. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77910. */
  77911. scale(ratio: number): void;
  77912. /**
  77913. * Get the texture reflection matrix used to rotate/transform the reflection.
  77914. * @returns the reflection matrix
  77915. */
  77916. getReflectionTextureMatrix(): Matrix;
  77917. /**
  77918. * Resize the texture to a new desired size.
  77919. * Be carrefull as it will recreate all the data in the new texture.
  77920. * @param size Define the new size. It can be:
  77921. * - a number for squared texture,
  77922. * - an object containing { width: number, height: number }
  77923. * - or an object containing a ratio { ratio: number }
  77924. */
  77925. resize(size: number | {
  77926. width: number;
  77927. height: number;
  77928. } | {
  77929. ratio: number;
  77930. }): void;
  77931. /**
  77932. * Renders all the objects from the render list into the texture.
  77933. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77934. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77935. */
  77936. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77937. private _bestReflectionRenderTargetDimension;
  77938. /**
  77939. * @hidden
  77940. * @param faceIndex face index to bind to if this is a cubetexture
  77941. */
  77942. _bindFrameBuffer(faceIndex?: number): void;
  77943. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77944. private renderToTarget;
  77945. /**
  77946. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77947. * This allowed control for front to back rendering or reversly depending of the special needs.
  77948. *
  77949. * @param renderingGroupId The rendering group id corresponding to its index
  77950. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77951. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77952. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77953. */
  77954. 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;
  77955. /**
  77956. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77957. *
  77958. * @param renderingGroupId The rendering group id corresponding to its index
  77959. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77960. */
  77961. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77962. /**
  77963. * Clones the texture.
  77964. * @returns the cloned texture
  77965. */
  77966. clone(): RenderTargetTexture;
  77967. /**
  77968. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77969. * @returns The JSON representation of the texture
  77970. */
  77971. serialize(): any;
  77972. /**
  77973. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77974. */
  77975. disposeFramebufferObjects(): void;
  77976. /**
  77977. * Dispose the texture and release its associated resources.
  77978. */
  77979. dispose(): void;
  77980. /** @hidden */
  77981. _rebuild(): void;
  77982. /**
  77983. * Clear the info related to rendering groups preventing retention point in material dispose.
  77984. */
  77985. freeRenderingGroups(): void;
  77986. /**
  77987. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77988. * @returns the view count
  77989. */
  77990. getViewCount(): number;
  77991. }
  77992. }
  77993. declare module BABYLON {
  77994. /**
  77995. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77996. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77997. * You can then easily use it as a reflectionTexture on a flat surface.
  77998. * In case the surface is not a plane, please consider relying on reflection probes.
  77999. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78000. */
  78001. export class MirrorTexture extends RenderTargetTexture {
  78002. private scene;
  78003. /**
  78004. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  78005. * 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.
  78006. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78007. */
  78008. mirrorPlane: Plane;
  78009. /**
  78010. * Define the blur ratio used to blur the reflection if needed.
  78011. */
  78012. blurRatio: number;
  78013. /**
  78014. * Define the adaptive blur kernel used to blur the reflection if needed.
  78015. * This will autocompute the closest best match for the `blurKernel`
  78016. */
  78017. adaptiveBlurKernel: number;
  78018. /**
  78019. * Define the blur kernel used to blur the reflection if needed.
  78020. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78021. */
  78022. blurKernel: number;
  78023. /**
  78024. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  78025. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78026. */
  78027. blurKernelX: number;
  78028. /**
  78029. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  78030. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78031. */
  78032. blurKernelY: number;
  78033. private _autoComputeBlurKernel;
  78034. protected _onRatioRescale(): void;
  78035. private _updateGammaSpace;
  78036. private _imageProcessingConfigChangeObserver;
  78037. private _transformMatrix;
  78038. private _mirrorMatrix;
  78039. private _savedViewMatrix;
  78040. private _blurX;
  78041. private _blurY;
  78042. private _adaptiveBlurKernel;
  78043. private _blurKernelX;
  78044. private _blurKernelY;
  78045. private _blurRatio;
  78046. /**
  78047. * Instantiates a Mirror Texture.
  78048. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78049. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78050. * You can then easily use it as a reflectionTexture on a flat surface.
  78051. * In case the surface is not a plane, please consider relying on reflection probes.
  78052. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78053. * @param name
  78054. * @param size
  78055. * @param scene
  78056. * @param generateMipMaps
  78057. * @param type
  78058. * @param samplingMode
  78059. * @param generateDepthBuffer
  78060. */
  78061. constructor(name: string, size: number | {
  78062. width: number;
  78063. height: number;
  78064. } | {
  78065. ratio: number;
  78066. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  78067. private _preparePostProcesses;
  78068. /**
  78069. * Clone the mirror texture.
  78070. * @returns the cloned texture
  78071. */
  78072. clone(): MirrorTexture;
  78073. /**
  78074. * Serialize the texture to a JSON representation you could use in Parse later on
  78075. * @returns the serialized JSON representation
  78076. */
  78077. serialize(): any;
  78078. /**
  78079. * Dispose the texture and release its associated resources.
  78080. */
  78081. dispose(): void;
  78082. }
  78083. }
  78084. declare module BABYLON {
  78085. /**
  78086. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78087. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78088. */
  78089. export class Texture extends BaseTexture {
  78090. /** @hidden */
  78091. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  78092. /** @hidden */
  78093. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  78094. /** @hidden */
  78095. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  78096. /** nearest is mag = nearest and min = nearest and mip = linear */
  78097. static readonly NEAREST_SAMPLINGMODE: number;
  78098. /** nearest is mag = nearest and min = nearest and mip = linear */
  78099. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  78100. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78101. static readonly BILINEAR_SAMPLINGMODE: number;
  78102. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78103. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  78104. /** Trilinear is mag = linear and min = linear and mip = linear */
  78105. static readonly TRILINEAR_SAMPLINGMODE: number;
  78106. /** Trilinear is mag = linear and min = linear and mip = linear */
  78107. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  78108. /** mag = nearest and min = nearest and mip = nearest */
  78109. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  78110. /** mag = nearest and min = linear and mip = nearest */
  78111. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  78112. /** mag = nearest and min = linear and mip = linear */
  78113. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  78114. /** mag = nearest and min = linear and mip = none */
  78115. static readonly NEAREST_LINEAR: number;
  78116. /** mag = nearest and min = nearest and mip = none */
  78117. static readonly NEAREST_NEAREST: number;
  78118. /** mag = linear and min = nearest and mip = nearest */
  78119. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  78120. /** mag = linear and min = nearest and mip = linear */
  78121. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  78122. /** mag = linear and min = linear and mip = none */
  78123. static readonly LINEAR_LINEAR: number;
  78124. /** mag = linear and min = nearest and mip = none */
  78125. static readonly LINEAR_NEAREST: number;
  78126. /** Explicit coordinates mode */
  78127. static readonly EXPLICIT_MODE: number;
  78128. /** Spherical coordinates mode */
  78129. static readonly SPHERICAL_MODE: number;
  78130. /** Planar coordinates mode */
  78131. static readonly PLANAR_MODE: number;
  78132. /** Cubic coordinates mode */
  78133. static readonly CUBIC_MODE: number;
  78134. /** Projection coordinates mode */
  78135. static readonly PROJECTION_MODE: number;
  78136. /** Inverse Cubic coordinates mode */
  78137. static readonly SKYBOX_MODE: number;
  78138. /** Inverse Cubic coordinates mode */
  78139. static readonly INVCUBIC_MODE: number;
  78140. /** Equirectangular coordinates mode */
  78141. static readonly EQUIRECTANGULAR_MODE: number;
  78142. /** Equirectangular Fixed coordinates mode */
  78143. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  78144. /** Equirectangular Fixed Mirrored coordinates mode */
  78145. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78146. /** Texture is not repeating outside of 0..1 UVs */
  78147. static readonly CLAMP_ADDRESSMODE: number;
  78148. /** Texture is repeating outside of 0..1 UVs */
  78149. static readonly WRAP_ADDRESSMODE: number;
  78150. /** Texture is repeating and mirrored */
  78151. static readonly MIRROR_ADDRESSMODE: number;
  78152. /**
  78153. * 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
  78154. */
  78155. static UseSerializedUrlIfAny: boolean;
  78156. /**
  78157. * Define the url of the texture.
  78158. */
  78159. url: Nullable<string>;
  78160. /**
  78161. * Define an offset on the texture to offset the u coordinates of the UVs
  78162. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78163. */
  78164. uOffset: number;
  78165. /**
  78166. * Define an offset on the texture to offset the v coordinates of the UVs
  78167. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78168. */
  78169. vOffset: number;
  78170. /**
  78171. * Define an offset on the texture to scale the u coordinates of the UVs
  78172. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78173. */
  78174. uScale: number;
  78175. /**
  78176. * Define an offset on the texture to scale the v coordinates of the UVs
  78177. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78178. */
  78179. vScale: number;
  78180. /**
  78181. * Define an offset on the texture to rotate around the u coordinates of the UVs
  78182. * @see http://doc.babylonjs.com/how_to/more_materials
  78183. */
  78184. uAng: number;
  78185. /**
  78186. * Define an offset on the texture to rotate around the v coordinates of the UVs
  78187. * @see http://doc.babylonjs.com/how_to/more_materials
  78188. */
  78189. vAng: number;
  78190. /**
  78191. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  78192. * @see http://doc.babylonjs.com/how_to/more_materials
  78193. */
  78194. wAng: number;
  78195. /**
  78196. * Defines the center of rotation (U)
  78197. */
  78198. uRotationCenter: number;
  78199. /**
  78200. * Defines the center of rotation (V)
  78201. */
  78202. vRotationCenter: number;
  78203. /**
  78204. * Defines the center of rotation (W)
  78205. */
  78206. wRotationCenter: number;
  78207. /**
  78208. * Are mip maps generated for this texture or not.
  78209. */
  78210. readonly noMipmap: boolean;
  78211. /**
  78212. * List of inspectable custom properties (used by the Inspector)
  78213. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78214. */
  78215. inspectableCustomProperties: Nullable<IInspectable[]>;
  78216. private _noMipmap;
  78217. /** @hidden */
  78218. _invertY: boolean;
  78219. private _rowGenerationMatrix;
  78220. private _cachedTextureMatrix;
  78221. private _projectionModeMatrix;
  78222. private _t0;
  78223. private _t1;
  78224. private _t2;
  78225. private _cachedUOffset;
  78226. private _cachedVOffset;
  78227. private _cachedUScale;
  78228. private _cachedVScale;
  78229. private _cachedUAng;
  78230. private _cachedVAng;
  78231. private _cachedWAng;
  78232. private _cachedProjectionMatrixId;
  78233. private _cachedCoordinatesMode;
  78234. /** @hidden */
  78235. protected _initialSamplingMode: number;
  78236. /** @hidden */
  78237. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  78238. private _deleteBuffer;
  78239. protected _format: Nullable<number>;
  78240. private _delayedOnLoad;
  78241. private _delayedOnError;
  78242. /**
  78243. * Observable triggered once the texture has been loaded.
  78244. */
  78245. onLoadObservable: Observable<Texture>;
  78246. protected _isBlocking: boolean;
  78247. /**
  78248. * Is the texture preventing material to render while loading.
  78249. * If false, a default texture will be used instead of the loading one during the preparation step.
  78250. */
  78251. isBlocking: boolean;
  78252. /**
  78253. * Get the current sampling mode associated with the texture.
  78254. */
  78255. readonly samplingMode: number;
  78256. /**
  78257. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  78258. */
  78259. readonly invertY: boolean;
  78260. /**
  78261. * Instantiates a new texture.
  78262. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78263. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78264. * @param url define the url of the picture to load as a texture
  78265. * @param scene define the scene the texture will belong to
  78266. * @param noMipmap define if the texture will require mip maps or not
  78267. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78268. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78269. * @param onLoad define a callback triggered when the texture has been loaded
  78270. * @param onError define a callback triggered when an error occurred during the loading session
  78271. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78272. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78273. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78274. */
  78275. 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);
  78276. /**
  78277. * Update the url (and optional buffer) of this texture if url was null during construction.
  78278. * @param url the url of the texture
  78279. * @param buffer the buffer of the texture (defaults to null)
  78280. * @param onLoad callback called when the texture is loaded (defaults to null)
  78281. */
  78282. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  78283. /**
  78284. * Finish the loading sequence of a texture flagged as delayed load.
  78285. * @hidden
  78286. */
  78287. delayLoad(): void;
  78288. private _prepareRowForTextureGeneration;
  78289. /**
  78290. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  78291. * @returns the transform matrix of the texture.
  78292. */
  78293. getTextureMatrix(): Matrix;
  78294. /**
  78295. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  78296. * @returns The reflection texture transform
  78297. */
  78298. getReflectionTextureMatrix(): Matrix;
  78299. /**
  78300. * Clones the texture.
  78301. * @returns the cloned texture
  78302. */
  78303. clone(): Texture;
  78304. /**
  78305. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  78306. * @returns The JSON representation of the texture
  78307. */
  78308. serialize(): any;
  78309. /**
  78310. * Get the current class name of the texture useful for serialization or dynamic coding.
  78311. * @returns "Texture"
  78312. */
  78313. getClassName(): string;
  78314. /**
  78315. * Dispose the texture and release its associated resources.
  78316. */
  78317. dispose(): void;
  78318. /**
  78319. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  78320. * @param parsedTexture Define the JSON representation of the texture
  78321. * @param scene Define the scene the parsed texture should be instantiated in
  78322. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  78323. * @returns The parsed texture if successful
  78324. */
  78325. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  78326. /**
  78327. * Creates a texture from its base 64 representation.
  78328. * @param data Define the base64 payload without the data: prefix
  78329. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78330. * @param scene Define the scene the texture should belong to
  78331. * @param noMipmap Forces the texture to not create mip map information if true
  78332. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78333. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78334. * @param onLoad define a callback triggered when the texture has been loaded
  78335. * @param onError define a callback triggered when an error occurred during the loading session
  78336. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78337. * @returns the created texture
  78338. */
  78339. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  78340. /**
  78341. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  78342. * @param data Define the base64 payload without the data: prefix
  78343. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78344. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78345. * @param scene Define the scene the texture should belong to
  78346. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78347. * @param noMipmap Forces the texture to not create mip map information if true
  78348. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78349. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78350. * @param onLoad define a callback triggered when the texture has been loaded
  78351. * @param onError define a callback triggered when an error occurred during the loading session
  78352. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78353. * @returns the created texture
  78354. */
  78355. 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;
  78356. }
  78357. }
  78358. declare module BABYLON {
  78359. interface Engine {
  78360. /**
  78361. * Creates a raw texture
  78362. * @param data defines the data to store in the texture
  78363. * @param width defines the width of the texture
  78364. * @param height defines the height of the texture
  78365. * @param format defines the format of the data
  78366. * @param generateMipMaps defines if the engine should generate the mip levels
  78367. * @param invertY defines if data must be stored with Y axis inverted
  78368. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78369. * @param compression defines the compression used (null by default)
  78370. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78371. * @returns the raw texture inside an InternalTexture
  78372. */
  78373. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78374. /**
  78375. * Update a raw texture
  78376. * @param texture defines the texture to update
  78377. * @param data defines the data to store in the texture
  78378. * @param format defines the format of the data
  78379. * @param invertY defines if data must be stored with Y axis inverted
  78380. */
  78381. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78382. /**
  78383. * Update a raw texture
  78384. * @param texture defines the texture to update
  78385. * @param data defines the data to store in the texture
  78386. * @param format defines the format of the data
  78387. * @param invertY defines if data must be stored with Y axis inverted
  78388. * @param compression defines the compression used (null by default)
  78389. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78390. */
  78391. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78392. /**
  78393. * Creates a new raw cube texture
  78394. * @param data defines the array of data to use to create each face
  78395. * @param size defines the size of the textures
  78396. * @param format defines the format of the data
  78397. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78398. * @param generateMipMaps defines if the engine should generate the mip levels
  78399. * @param invertY defines if data must be stored with Y axis inverted
  78400. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78401. * @param compression defines the compression used (null by default)
  78402. * @returns the cube texture as an InternalTexture
  78403. */
  78404. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78405. /**
  78406. * Update a raw cube texture
  78407. * @param texture defines the texture to udpdate
  78408. * @param data defines the data to store
  78409. * @param format defines the data format
  78410. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78411. * @param invertY defines if data must be stored with Y axis inverted
  78412. */
  78413. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78414. /**
  78415. * Update a raw cube texture
  78416. * @param texture defines the texture to udpdate
  78417. * @param data defines the data to store
  78418. * @param format defines the data format
  78419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78420. * @param invertY defines if data must be stored with Y axis inverted
  78421. * @param compression defines the compression used (null by default)
  78422. */
  78423. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78424. /**
  78425. * Update a raw cube texture
  78426. * @param texture defines the texture to udpdate
  78427. * @param data defines the data to store
  78428. * @param format defines the data format
  78429. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78430. * @param invertY defines if data must be stored with Y axis inverted
  78431. * @param compression defines the compression used (null by default)
  78432. * @param level defines which level of the texture to update
  78433. */
  78434. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78435. /**
  78436. * Creates a new raw cube texture from a specified url
  78437. * @param url defines the url where the data is located
  78438. * @param scene defines the current scene
  78439. * @param size defines the size of the textures
  78440. * @param format defines the format of the data
  78441. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78442. * @param noMipmap defines if the engine should avoid generating the mip levels
  78443. * @param callback defines a callback used to extract texture data from loaded data
  78444. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78445. * @param onLoad defines a callback called when texture is loaded
  78446. * @param onError defines a callback called if there is an error
  78447. * @returns the cube texture as an InternalTexture
  78448. */
  78449. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  78450. /**
  78451. * Creates a new raw cube texture from a specified url
  78452. * @param url defines the url where the data is located
  78453. * @param scene defines the current scene
  78454. * @param size defines the size of the textures
  78455. * @param format defines the format of the data
  78456. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78457. * @param noMipmap defines if the engine should avoid generating the mip levels
  78458. * @param callback defines a callback used to extract texture data from loaded data
  78459. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78460. * @param onLoad defines a callback called when texture is loaded
  78461. * @param onError defines a callback called if there is an error
  78462. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78463. * @param invertY defines if data must be stored with Y axis inverted
  78464. * @returns the cube texture as an InternalTexture
  78465. */
  78466. 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;
  78467. /**
  78468. * Creates a new raw 3D texture
  78469. * @param data defines the data used to create the texture
  78470. * @param width defines the width of the texture
  78471. * @param height defines the height of the texture
  78472. * @param depth defines the depth of the texture
  78473. * @param format defines the format of the texture
  78474. * @param generateMipMaps defines if the engine must generate mip levels
  78475. * @param invertY defines if data must be stored with Y axis inverted
  78476. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78477. * @param compression defines the compressed used (can be null)
  78478. * @param textureType defines the compressed used (can be null)
  78479. * @returns a new raw 3D texture (stored in an InternalTexture)
  78480. */
  78481. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78482. /**
  78483. * Update a raw 3D texture
  78484. * @param texture defines the texture to update
  78485. * @param data defines the data to store
  78486. * @param format defines the data format
  78487. * @param invertY defines if data must be stored with Y axis inverted
  78488. */
  78489. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78490. /**
  78491. * Update a raw 3D texture
  78492. * @param texture defines the texture to update
  78493. * @param data defines the data to store
  78494. * @param format defines the data format
  78495. * @param invertY defines if data must be stored with Y axis inverted
  78496. * @param compression defines the used compression (can be null)
  78497. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78498. */
  78499. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78500. }
  78501. }
  78502. declare module BABYLON {
  78503. /**
  78504. * Raw texture can help creating a texture directly from an array of data.
  78505. * This can be super useful if you either get the data from an uncompressed source or
  78506. * if you wish to create your texture pixel by pixel.
  78507. */
  78508. export class RawTexture extends Texture {
  78509. /**
  78510. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78511. */
  78512. format: number;
  78513. private _engine;
  78514. /**
  78515. * Instantiates a new RawTexture.
  78516. * Raw texture can help creating a texture directly from an array of data.
  78517. * This can be super useful if you either get the data from an uncompressed source or
  78518. * if you wish to create your texture pixel by pixel.
  78519. * @param data define the array of data to use to create the texture
  78520. * @param width define the width of the texture
  78521. * @param height define the height of the texture
  78522. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78523. * @param scene define the scene the texture belongs to
  78524. * @param generateMipMaps define whether mip maps should be generated or not
  78525. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78526. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78527. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78528. */
  78529. constructor(data: ArrayBufferView, width: number, height: number,
  78530. /**
  78531. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78532. */
  78533. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78534. /**
  78535. * Updates the texture underlying data.
  78536. * @param data Define the new data of the texture
  78537. */
  78538. update(data: ArrayBufferView): void;
  78539. /**
  78540. * Creates a luminance texture from some data.
  78541. * @param data Define the texture data
  78542. * @param width Define the width of the texture
  78543. * @param height Define the height of the texture
  78544. * @param scene Define the scene the texture belongs to
  78545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78548. * @returns the luminance texture
  78549. */
  78550. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78551. /**
  78552. * Creates a luminance alpha texture from some data.
  78553. * @param data Define the texture data
  78554. * @param width Define the width of the texture
  78555. * @param height Define the height of the texture
  78556. * @param scene Define the scene the texture belongs to
  78557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78560. * @returns the luminance alpha texture
  78561. */
  78562. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78563. /**
  78564. * Creates an alpha texture from some data.
  78565. * @param data Define the texture data
  78566. * @param width Define the width of the texture
  78567. * @param height Define the height of the texture
  78568. * @param scene Define the scene the texture belongs to
  78569. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78572. * @returns the alpha texture
  78573. */
  78574. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78575. /**
  78576. * Creates a RGB texture from some data.
  78577. * @param data Define the texture data
  78578. * @param width Define the width of the texture
  78579. * @param height Define the height of the texture
  78580. * @param scene Define the scene the texture belongs to
  78581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78585. * @returns the RGB alpha texture
  78586. */
  78587. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78588. /**
  78589. * Creates a RGBA texture from some data.
  78590. * @param data Define the texture data
  78591. * @param width Define the width of the texture
  78592. * @param height Define the height of the texture
  78593. * @param scene Define the scene the texture belongs to
  78594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78597. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78598. * @returns the RGBA texture
  78599. */
  78600. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78601. /**
  78602. * Creates a R texture from some data.
  78603. * @param data Define the texture data
  78604. * @param width Define the width of the texture
  78605. * @param height Define the height of the texture
  78606. * @param scene Define the scene the texture belongs to
  78607. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78608. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78609. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78610. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78611. * @returns the R texture
  78612. */
  78613. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78614. }
  78615. }
  78616. declare module BABYLON {
  78617. /**
  78618. * Defines a runtime animation
  78619. */
  78620. export class RuntimeAnimation {
  78621. private _events;
  78622. /**
  78623. * The current frame of the runtime animation
  78624. */
  78625. private _currentFrame;
  78626. /**
  78627. * The animation used by the runtime animation
  78628. */
  78629. private _animation;
  78630. /**
  78631. * The target of the runtime animation
  78632. */
  78633. private _target;
  78634. /**
  78635. * The initiating animatable
  78636. */
  78637. private _host;
  78638. /**
  78639. * The original value of the runtime animation
  78640. */
  78641. private _originalValue;
  78642. /**
  78643. * The original blend value of the runtime animation
  78644. */
  78645. private _originalBlendValue;
  78646. /**
  78647. * The offsets cache of the runtime animation
  78648. */
  78649. private _offsetsCache;
  78650. /**
  78651. * The high limits cache of the runtime animation
  78652. */
  78653. private _highLimitsCache;
  78654. /**
  78655. * Specifies if the runtime animation has been stopped
  78656. */
  78657. private _stopped;
  78658. /**
  78659. * The blending factor of the runtime animation
  78660. */
  78661. private _blendingFactor;
  78662. /**
  78663. * The BabylonJS scene
  78664. */
  78665. private _scene;
  78666. /**
  78667. * The current value of the runtime animation
  78668. */
  78669. private _currentValue;
  78670. /** @hidden */
  78671. _animationState: _IAnimationState;
  78672. /**
  78673. * The active target of the runtime animation
  78674. */
  78675. private _activeTargets;
  78676. private _currentActiveTarget;
  78677. private _directTarget;
  78678. /**
  78679. * The target path of the runtime animation
  78680. */
  78681. private _targetPath;
  78682. /**
  78683. * The weight of the runtime animation
  78684. */
  78685. private _weight;
  78686. /**
  78687. * The ratio offset of the runtime animation
  78688. */
  78689. private _ratioOffset;
  78690. /**
  78691. * The previous delay of the runtime animation
  78692. */
  78693. private _previousDelay;
  78694. /**
  78695. * The previous ratio of the runtime animation
  78696. */
  78697. private _previousRatio;
  78698. private _enableBlending;
  78699. private _keys;
  78700. private _minFrame;
  78701. private _maxFrame;
  78702. private _minValue;
  78703. private _maxValue;
  78704. private _targetIsArray;
  78705. /**
  78706. * Gets the current frame of the runtime animation
  78707. */
  78708. readonly currentFrame: number;
  78709. /**
  78710. * Gets the weight of the runtime animation
  78711. */
  78712. readonly weight: number;
  78713. /**
  78714. * Gets the current value of the runtime animation
  78715. */
  78716. readonly currentValue: any;
  78717. /**
  78718. * Gets the target path of the runtime animation
  78719. */
  78720. readonly targetPath: string;
  78721. /**
  78722. * Gets the actual target of the runtime animation
  78723. */
  78724. readonly target: any;
  78725. /** @hidden */
  78726. _onLoop: () => void;
  78727. /**
  78728. * Create a new RuntimeAnimation object
  78729. * @param target defines the target of the animation
  78730. * @param animation defines the source animation object
  78731. * @param scene defines the hosting scene
  78732. * @param host defines the initiating Animatable
  78733. */
  78734. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78735. private _preparePath;
  78736. /**
  78737. * Gets the animation from the runtime animation
  78738. */
  78739. readonly animation: Animation;
  78740. /**
  78741. * Resets the runtime animation to the beginning
  78742. * @param restoreOriginal defines whether to restore the target property to the original value
  78743. */
  78744. reset(restoreOriginal?: boolean): void;
  78745. /**
  78746. * Specifies if the runtime animation is stopped
  78747. * @returns Boolean specifying if the runtime animation is stopped
  78748. */
  78749. isStopped(): boolean;
  78750. /**
  78751. * Disposes of the runtime animation
  78752. */
  78753. dispose(): void;
  78754. /**
  78755. * Apply the interpolated value to the target
  78756. * @param currentValue defines the value computed by the animation
  78757. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78758. */
  78759. setValue(currentValue: any, weight: number): void;
  78760. private _getOriginalValues;
  78761. private _setValue;
  78762. /**
  78763. * Gets the loop pmode of the runtime animation
  78764. * @returns Loop Mode
  78765. */
  78766. private _getCorrectLoopMode;
  78767. /**
  78768. * Move the current animation to a given frame
  78769. * @param frame defines the frame to move to
  78770. */
  78771. goToFrame(frame: number): void;
  78772. /**
  78773. * @hidden Internal use only
  78774. */
  78775. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78776. /**
  78777. * Execute the current animation
  78778. * @param delay defines the delay to add to the current frame
  78779. * @param from defines the lower bound of the animation range
  78780. * @param to defines the upper bound of the animation range
  78781. * @param loop defines if the current animation must loop
  78782. * @param speedRatio defines the current speed ratio
  78783. * @param weight defines the weight of the animation (default is -1 so no weight)
  78784. * @param onLoop optional callback called when animation loops
  78785. * @returns a boolean indicating if the animation is running
  78786. */
  78787. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78788. }
  78789. }
  78790. declare module BABYLON {
  78791. /**
  78792. * Class used to store an actual running animation
  78793. */
  78794. export class Animatable {
  78795. /** defines the target object */
  78796. target: any;
  78797. /** defines the starting frame number (default is 0) */
  78798. fromFrame: number;
  78799. /** defines the ending frame number (default is 100) */
  78800. toFrame: number;
  78801. /** defines if the animation must loop (default is false) */
  78802. loopAnimation: boolean;
  78803. /** defines a callback to call when animation ends if it is not looping */
  78804. onAnimationEnd?: (() => void) | null | undefined;
  78805. /** defines a callback to call when animation loops */
  78806. onAnimationLoop?: (() => void) | null | undefined;
  78807. private _localDelayOffset;
  78808. private _pausedDelay;
  78809. private _runtimeAnimations;
  78810. private _paused;
  78811. private _scene;
  78812. private _speedRatio;
  78813. private _weight;
  78814. private _syncRoot;
  78815. /**
  78816. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78817. * This will only apply for non looping animation (default is true)
  78818. */
  78819. disposeOnEnd: boolean;
  78820. /**
  78821. * Gets a boolean indicating if the animation has started
  78822. */
  78823. animationStarted: boolean;
  78824. /**
  78825. * Observer raised when the animation ends
  78826. */
  78827. onAnimationEndObservable: Observable<Animatable>;
  78828. /**
  78829. * Observer raised when the animation loops
  78830. */
  78831. onAnimationLoopObservable: Observable<Animatable>;
  78832. /**
  78833. * Gets the root Animatable used to synchronize and normalize animations
  78834. */
  78835. readonly syncRoot: Nullable<Animatable>;
  78836. /**
  78837. * Gets the current frame of the first RuntimeAnimation
  78838. * Used to synchronize Animatables
  78839. */
  78840. readonly masterFrame: number;
  78841. /**
  78842. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78843. */
  78844. weight: number;
  78845. /**
  78846. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78847. */
  78848. speedRatio: number;
  78849. /**
  78850. * Creates a new Animatable
  78851. * @param scene defines the hosting scene
  78852. * @param target defines the target object
  78853. * @param fromFrame defines the starting frame number (default is 0)
  78854. * @param toFrame defines the ending frame number (default is 100)
  78855. * @param loopAnimation defines if the animation must loop (default is false)
  78856. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78857. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78858. * @param animations defines a group of animation to add to the new Animatable
  78859. * @param onAnimationLoop defines a callback to call when animation loops
  78860. */
  78861. constructor(scene: Scene,
  78862. /** defines the target object */
  78863. target: any,
  78864. /** defines the starting frame number (default is 0) */
  78865. fromFrame?: number,
  78866. /** defines the ending frame number (default is 100) */
  78867. toFrame?: number,
  78868. /** defines if the animation must loop (default is false) */
  78869. loopAnimation?: boolean, speedRatio?: number,
  78870. /** defines a callback to call when animation ends if it is not looping */
  78871. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78872. /** defines a callback to call when animation loops */
  78873. onAnimationLoop?: (() => void) | null | undefined);
  78874. /**
  78875. * Synchronize and normalize current Animatable with a source Animatable
  78876. * This is useful when using animation weights and when animations are not of the same length
  78877. * @param root defines the root Animatable to synchronize with
  78878. * @returns the current Animatable
  78879. */
  78880. syncWith(root: Animatable): Animatable;
  78881. /**
  78882. * Gets the list of runtime animations
  78883. * @returns an array of RuntimeAnimation
  78884. */
  78885. getAnimations(): RuntimeAnimation[];
  78886. /**
  78887. * Adds more animations to the current animatable
  78888. * @param target defines the target of the animations
  78889. * @param animations defines the new animations to add
  78890. */
  78891. appendAnimations(target: any, animations: Animation[]): void;
  78892. /**
  78893. * Gets the source animation for a specific property
  78894. * @param property defines the propertyu to look for
  78895. * @returns null or the source animation for the given property
  78896. */
  78897. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78898. /**
  78899. * Gets the runtime animation for a specific property
  78900. * @param property defines the propertyu to look for
  78901. * @returns null or the runtime animation for the given property
  78902. */
  78903. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78904. /**
  78905. * Resets the animatable to its original state
  78906. */
  78907. reset(): void;
  78908. /**
  78909. * Allows the animatable to blend with current running animations
  78910. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78911. * @param blendingSpeed defines the blending speed to use
  78912. */
  78913. enableBlending(blendingSpeed: number): void;
  78914. /**
  78915. * Disable animation blending
  78916. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78917. */
  78918. disableBlending(): void;
  78919. /**
  78920. * Jump directly to a given frame
  78921. * @param frame defines the frame to jump to
  78922. */
  78923. goToFrame(frame: number): void;
  78924. /**
  78925. * Pause the animation
  78926. */
  78927. pause(): void;
  78928. /**
  78929. * Restart the animation
  78930. */
  78931. restart(): void;
  78932. private _raiseOnAnimationEnd;
  78933. /**
  78934. * Stop and delete the current animation
  78935. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78936. * @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)
  78937. */
  78938. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78939. /**
  78940. * Wait asynchronously for the animation to end
  78941. * @returns a promise which will be fullfilled when the animation ends
  78942. */
  78943. waitAsync(): Promise<Animatable>;
  78944. /** @hidden */
  78945. _animate(delay: number): boolean;
  78946. }
  78947. interface Scene {
  78948. /** @hidden */
  78949. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78950. /** @hidden */
  78951. _processLateAnimationBindingsForMatrices(holder: {
  78952. totalWeight: number;
  78953. animations: RuntimeAnimation[];
  78954. originalValue: Matrix;
  78955. }): any;
  78956. /** @hidden */
  78957. _processLateAnimationBindingsForQuaternions(holder: {
  78958. totalWeight: number;
  78959. animations: RuntimeAnimation[];
  78960. originalValue: Quaternion;
  78961. }, refQuaternion: Quaternion): Quaternion;
  78962. /** @hidden */
  78963. _processLateAnimationBindings(): void;
  78964. /**
  78965. * Will start the animation sequence of a given target
  78966. * @param target defines the target
  78967. * @param from defines from which frame should animation start
  78968. * @param to defines until which frame should animation run.
  78969. * @param weight defines the weight to apply to the animation (1.0 by default)
  78970. * @param loop defines if the animation loops
  78971. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78972. * @param onAnimationEnd defines the function to be executed when the animation ends
  78973. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78974. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78975. * @param onAnimationLoop defines the callback to call when an animation loops
  78976. * @returns the animatable object created for this animation
  78977. */
  78978. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78979. /**
  78980. * Will start the animation sequence of a given target
  78981. * @param target defines the target
  78982. * @param from defines from which frame should animation start
  78983. * @param to defines until which frame should animation run.
  78984. * @param loop defines if the animation loops
  78985. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78986. * @param onAnimationEnd defines the function to be executed when the animation ends
  78987. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78988. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78989. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78990. * @param onAnimationLoop defines the callback to call when an animation loops
  78991. * @returns the animatable object created for this animation
  78992. */
  78993. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78994. /**
  78995. * Will start the animation sequence of a given target and its hierarchy
  78996. * @param target defines the target
  78997. * @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.
  78998. * @param from defines from which frame should animation start
  78999. * @param to defines until which frame should animation run.
  79000. * @param loop defines if the animation loops
  79001. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79002. * @param onAnimationEnd defines the function to be executed when the animation ends
  79003. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79004. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79005. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79006. * @param onAnimationLoop defines the callback to call when an animation loops
  79007. * @returns the list of created animatables
  79008. */
  79009. 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[];
  79010. /**
  79011. * Begin a new animation on a given node
  79012. * @param target defines the target where the animation will take place
  79013. * @param animations defines the list of animations to start
  79014. * @param from defines the initial value
  79015. * @param to defines the final value
  79016. * @param loop defines if you want animation to loop (off by default)
  79017. * @param speedRatio defines the speed ratio to apply to all animations
  79018. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79019. * @param onAnimationLoop defines the callback to call when an animation loops
  79020. * @returns the list of created animatables
  79021. */
  79022. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79023. /**
  79024. * Begin a new animation on a given node and its hierarchy
  79025. * @param target defines the root node where the animation will take place
  79026. * @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.
  79027. * @param animations defines the list of animations to start
  79028. * @param from defines the initial value
  79029. * @param to defines the final value
  79030. * @param loop defines if you want animation to loop (off by default)
  79031. * @param speedRatio defines the speed ratio to apply to all animations
  79032. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79033. * @param onAnimationLoop defines the callback to call when an animation loops
  79034. * @returns the list of animatables created for all nodes
  79035. */
  79036. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79037. /**
  79038. * Gets the animatable associated with a specific target
  79039. * @param target defines the target of the animatable
  79040. * @returns the required animatable if found
  79041. */
  79042. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79043. /**
  79044. * Gets all animatables associated with a given target
  79045. * @param target defines the target to look animatables for
  79046. * @returns an array of Animatables
  79047. */
  79048. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79049. /**
  79050. * Stops and removes all animations that have been applied to the scene
  79051. */
  79052. stopAllAnimations(): void;
  79053. }
  79054. interface Bone {
  79055. /**
  79056. * Copy an animation range from another bone
  79057. * @param source defines the source bone
  79058. * @param rangeName defines the range name to copy
  79059. * @param frameOffset defines the frame offset
  79060. * @param rescaleAsRequired defines if rescaling must be applied if required
  79061. * @param skelDimensionsRatio defines the scaling ratio
  79062. * @returns true if operation was successful
  79063. */
  79064. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79065. }
  79066. }
  79067. declare module BABYLON {
  79068. /**
  79069. * Class used to handle skinning animations
  79070. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79071. */
  79072. export class Skeleton implements IAnimatable {
  79073. /** defines the skeleton name */
  79074. name: string;
  79075. /** defines the skeleton Id */
  79076. id: string;
  79077. /**
  79078. * Defines the list of child bones
  79079. */
  79080. bones: Bone[];
  79081. /**
  79082. * Defines an estimate of the dimension of the skeleton at rest
  79083. */
  79084. dimensionsAtRest: Vector3;
  79085. /**
  79086. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79087. */
  79088. needInitialSkinMatrix: boolean;
  79089. /**
  79090. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79091. */
  79092. overrideMesh: Nullable<AbstractMesh>;
  79093. /**
  79094. * Gets the list of animations attached to this skeleton
  79095. */
  79096. animations: Array<Animation>;
  79097. private _scene;
  79098. private _isDirty;
  79099. private _transformMatrices;
  79100. private _transformMatrixTexture;
  79101. private _meshesWithPoseMatrix;
  79102. private _animatables;
  79103. private _identity;
  79104. private _synchronizedWithMesh;
  79105. private _ranges;
  79106. private _lastAbsoluteTransformsUpdateId;
  79107. private _canUseTextureForBones;
  79108. private _uniqueId;
  79109. /** @hidden */
  79110. _numBonesWithLinkedTransformNode: number;
  79111. /**
  79112. * Specifies if the skeleton should be serialized
  79113. */
  79114. doNotSerialize: boolean;
  79115. private _useTextureToStoreBoneMatrices;
  79116. /**
  79117. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79118. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79119. */
  79120. useTextureToStoreBoneMatrices: boolean;
  79121. private _animationPropertiesOverride;
  79122. /**
  79123. * Gets or sets the animation properties override
  79124. */
  79125. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79126. /**
  79127. * List of inspectable custom properties (used by the Inspector)
  79128. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79129. */
  79130. inspectableCustomProperties: IInspectable[];
  79131. /**
  79132. * An observable triggered before computing the skeleton's matrices
  79133. */
  79134. onBeforeComputeObservable: Observable<Skeleton>;
  79135. /**
  79136. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79137. */
  79138. readonly isUsingTextureForMatrices: boolean;
  79139. /**
  79140. * Gets the unique ID of this skeleton
  79141. */
  79142. readonly uniqueId: number;
  79143. /**
  79144. * Creates a new skeleton
  79145. * @param name defines the skeleton name
  79146. * @param id defines the skeleton Id
  79147. * @param scene defines the hosting scene
  79148. */
  79149. constructor(
  79150. /** defines the skeleton name */
  79151. name: string,
  79152. /** defines the skeleton Id */
  79153. id: string, scene: Scene);
  79154. /**
  79155. * Gets the current object class name.
  79156. * @return the class name
  79157. */
  79158. getClassName(): string;
  79159. /**
  79160. * Returns an array containing the root bones
  79161. * @returns an array containing the root bones
  79162. */
  79163. getChildren(): Array<Bone>;
  79164. /**
  79165. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79166. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79167. * @returns a Float32Array containing matrices data
  79168. */
  79169. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79170. /**
  79171. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79172. * @returns a raw texture containing the data
  79173. */
  79174. getTransformMatrixTexture(): Nullable<RawTexture>;
  79175. /**
  79176. * Gets the current hosting scene
  79177. * @returns a scene object
  79178. */
  79179. getScene(): Scene;
  79180. /**
  79181. * Gets a string representing the current skeleton data
  79182. * @param fullDetails defines a boolean indicating if we want a verbose version
  79183. * @returns a string representing the current skeleton data
  79184. */
  79185. toString(fullDetails?: boolean): string;
  79186. /**
  79187. * Get bone's index searching by name
  79188. * @param name defines bone's name to search for
  79189. * @return the indice of the bone. Returns -1 if not found
  79190. */
  79191. getBoneIndexByName(name: string): number;
  79192. /**
  79193. * Creater a new animation range
  79194. * @param name defines the name of the range
  79195. * @param from defines the start key
  79196. * @param to defines the end key
  79197. */
  79198. createAnimationRange(name: string, from: number, to: number): void;
  79199. /**
  79200. * Delete a specific animation range
  79201. * @param name defines the name of the range
  79202. * @param deleteFrames defines if frames must be removed as well
  79203. */
  79204. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79205. /**
  79206. * Gets a specific animation range
  79207. * @param name defines the name of the range to look for
  79208. * @returns the requested animation range or null if not found
  79209. */
  79210. getAnimationRange(name: string): Nullable<AnimationRange>;
  79211. /**
  79212. * Gets the list of all animation ranges defined on this skeleton
  79213. * @returns an array
  79214. */
  79215. getAnimationRanges(): Nullable<AnimationRange>[];
  79216. /**
  79217. * Copy animation range from a source skeleton.
  79218. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79219. * @param source defines the source skeleton
  79220. * @param name defines the name of the range to copy
  79221. * @param rescaleAsRequired defines if rescaling must be applied if required
  79222. * @returns true if operation was successful
  79223. */
  79224. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79225. /**
  79226. * Forces the skeleton to go to rest pose
  79227. */
  79228. returnToRest(): void;
  79229. private _getHighestAnimationFrame;
  79230. /**
  79231. * Begin a specific animation range
  79232. * @param name defines the name of the range to start
  79233. * @param loop defines if looping must be turned on (false by default)
  79234. * @param speedRatio defines the speed ratio to apply (1 by default)
  79235. * @param onAnimationEnd defines a callback which will be called when animation will end
  79236. * @returns a new animatable
  79237. */
  79238. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79239. /** @hidden */
  79240. _markAsDirty(): void;
  79241. /** @hidden */
  79242. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79243. /** @hidden */
  79244. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79245. private _computeTransformMatrices;
  79246. /**
  79247. * Build all resources required to render a skeleton
  79248. */
  79249. prepare(): void;
  79250. /**
  79251. * Gets the list of animatables currently running for this skeleton
  79252. * @returns an array of animatables
  79253. */
  79254. getAnimatables(): IAnimatable[];
  79255. /**
  79256. * Clone the current skeleton
  79257. * @param name defines the name of the new skeleton
  79258. * @param id defines the id of the new skeleton
  79259. * @returns the new skeleton
  79260. */
  79261. clone(name: string, id: string): Skeleton;
  79262. /**
  79263. * Enable animation blending for this skeleton
  79264. * @param blendingSpeed defines the blending speed to apply
  79265. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79266. */
  79267. enableBlending(blendingSpeed?: number): void;
  79268. /**
  79269. * Releases all resources associated with the current skeleton
  79270. */
  79271. dispose(): void;
  79272. /**
  79273. * Serialize the skeleton in a JSON object
  79274. * @returns a JSON object
  79275. */
  79276. serialize(): any;
  79277. /**
  79278. * Creates a new skeleton from serialized data
  79279. * @param parsedSkeleton defines the serialized data
  79280. * @param scene defines the hosting scene
  79281. * @returns a new skeleton
  79282. */
  79283. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79284. /**
  79285. * Compute all node absolute transforms
  79286. * @param forceUpdate defines if computation must be done even if cache is up to date
  79287. */
  79288. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79289. /**
  79290. * Gets the root pose matrix
  79291. * @returns a matrix
  79292. */
  79293. getPoseMatrix(): Nullable<Matrix>;
  79294. /**
  79295. * Sorts bones per internal index
  79296. */
  79297. sortBones(): void;
  79298. private _sortBones;
  79299. }
  79300. }
  79301. declare module BABYLON {
  79302. /**
  79303. * Defines a target to use with MorphTargetManager
  79304. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79305. */
  79306. export class MorphTarget implements IAnimatable {
  79307. /** defines the name of the target */
  79308. name: string;
  79309. /**
  79310. * Gets or sets the list of animations
  79311. */
  79312. animations: Animation[];
  79313. private _scene;
  79314. private _positions;
  79315. private _normals;
  79316. private _tangents;
  79317. private _influence;
  79318. /**
  79319. * Observable raised when the influence changes
  79320. */
  79321. onInfluenceChanged: Observable<boolean>;
  79322. /** @hidden */
  79323. _onDataLayoutChanged: Observable<void>;
  79324. /**
  79325. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  79326. */
  79327. influence: number;
  79328. /**
  79329. * Gets or sets the id of the morph Target
  79330. */
  79331. id: string;
  79332. private _animationPropertiesOverride;
  79333. /**
  79334. * Gets or sets the animation properties override
  79335. */
  79336. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79337. /**
  79338. * Creates a new MorphTarget
  79339. * @param name defines the name of the target
  79340. * @param influence defines the influence to use
  79341. * @param scene defines the scene the morphtarget belongs to
  79342. */
  79343. constructor(
  79344. /** defines the name of the target */
  79345. name: string, influence?: number, scene?: Nullable<Scene>);
  79346. /**
  79347. * Gets a boolean defining if the target contains position data
  79348. */
  79349. readonly hasPositions: boolean;
  79350. /**
  79351. * Gets a boolean defining if the target contains normal data
  79352. */
  79353. readonly hasNormals: boolean;
  79354. /**
  79355. * Gets a boolean defining if the target contains tangent data
  79356. */
  79357. readonly hasTangents: boolean;
  79358. /**
  79359. * Affects position data to this target
  79360. * @param data defines the position data to use
  79361. */
  79362. setPositions(data: Nullable<FloatArray>): void;
  79363. /**
  79364. * Gets the position data stored in this target
  79365. * @returns a FloatArray containing the position data (or null if not present)
  79366. */
  79367. getPositions(): Nullable<FloatArray>;
  79368. /**
  79369. * Affects normal data to this target
  79370. * @param data defines the normal data to use
  79371. */
  79372. setNormals(data: Nullable<FloatArray>): void;
  79373. /**
  79374. * Gets the normal data stored in this target
  79375. * @returns a FloatArray containing the normal data (or null if not present)
  79376. */
  79377. getNormals(): Nullable<FloatArray>;
  79378. /**
  79379. * Affects tangent data to this target
  79380. * @param data defines the tangent data to use
  79381. */
  79382. setTangents(data: Nullable<FloatArray>): void;
  79383. /**
  79384. * Gets the tangent data stored in this target
  79385. * @returns a FloatArray containing the tangent data (or null if not present)
  79386. */
  79387. getTangents(): Nullable<FloatArray>;
  79388. /**
  79389. * Serializes the current target into a Serialization object
  79390. * @returns the serialized object
  79391. */
  79392. serialize(): any;
  79393. /**
  79394. * Returns the string "MorphTarget"
  79395. * @returns "MorphTarget"
  79396. */
  79397. getClassName(): string;
  79398. /**
  79399. * Creates a new target from serialized data
  79400. * @param serializationObject defines the serialized data to use
  79401. * @returns a new MorphTarget
  79402. */
  79403. static Parse(serializationObject: any): MorphTarget;
  79404. /**
  79405. * Creates a MorphTarget from mesh data
  79406. * @param mesh defines the source mesh
  79407. * @param name defines the name to use for the new target
  79408. * @param influence defines the influence to attach to the target
  79409. * @returns a new MorphTarget
  79410. */
  79411. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  79412. }
  79413. }
  79414. declare module BABYLON {
  79415. /**
  79416. * This class is used to deform meshes using morphing between different targets
  79417. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79418. */
  79419. export class MorphTargetManager {
  79420. private _targets;
  79421. private _targetInfluenceChangedObservers;
  79422. private _targetDataLayoutChangedObservers;
  79423. private _activeTargets;
  79424. private _scene;
  79425. private _influences;
  79426. private _supportsNormals;
  79427. private _supportsTangents;
  79428. private _vertexCount;
  79429. private _uniqueId;
  79430. private _tempInfluences;
  79431. /**
  79432. * Creates a new MorphTargetManager
  79433. * @param scene defines the current scene
  79434. */
  79435. constructor(scene?: Nullable<Scene>);
  79436. /**
  79437. * Gets the unique ID of this manager
  79438. */
  79439. readonly uniqueId: number;
  79440. /**
  79441. * Gets the number of vertices handled by this manager
  79442. */
  79443. readonly vertexCount: number;
  79444. /**
  79445. * Gets a boolean indicating if this manager supports morphing of normals
  79446. */
  79447. readonly supportsNormals: boolean;
  79448. /**
  79449. * Gets a boolean indicating if this manager supports morphing of tangents
  79450. */
  79451. readonly supportsTangents: boolean;
  79452. /**
  79453. * Gets the number of targets stored in this manager
  79454. */
  79455. readonly numTargets: number;
  79456. /**
  79457. * Gets the number of influencers (ie. the number of targets with influences > 0)
  79458. */
  79459. readonly numInfluencers: number;
  79460. /**
  79461. * Gets the list of influences (one per target)
  79462. */
  79463. readonly influences: Float32Array;
  79464. /**
  79465. * Gets the active target at specified index. An active target is a target with an influence > 0
  79466. * @param index defines the index to check
  79467. * @returns the requested target
  79468. */
  79469. getActiveTarget(index: number): MorphTarget;
  79470. /**
  79471. * Gets the target at specified index
  79472. * @param index defines the index to check
  79473. * @returns the requested target
  79474. */
  79475. getTarget(index: number): MorphTarget;
  79476. /**
  79477. * Add a new target to this manager
  79478. * @param target defines the target to add
  79479. */
  79480. addTarget(target: MorphTarget): void;
  79481. /**
  79482. * Removes a target from the manager
  79483. * @param target defines the target to remove
  79484. */
  79485. removeTarget(target: MorphTarget): void;
  79486. /**
  79487. * Serializes the current manager into a Serialization object
  79488. * @returns the serialized object
  79489. */
  79490. serialize(): any;
  79491. private _syncActiveTargets;
  79492. /**
  79493. * Syncrhonize the targets with all the meshes using this morph target manager
  79494. */
  79495. synchronize(): void;
  79496. /**
  79497. * Creates a new MorphTargetManager from serialized data
  79498. * @param serializationObject defines the serialized data
  79499. * @param scene defines the hosting scene
  79500. * @returns the new MorphTargetManager
  79501. */
  79502. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  79503. }
  79504. }
  79505. declare module BABYLON {
  79506. /**
  79507. * Class used to represent a specific level of detail of a mesh
  79508. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79509. */
  79510. export class MeshLODLevel {
  79511. /** Defines the distance where this level should star being displayed */
  79512. distance: number;
  79513. /** Defines the mesh to use to render this level */
  79514. mesh: Nullable<Mesh>;
  79515. /**
  79516. * Creates a new LOD level
  79517. * @param distance defines the distance where this level should star being displayed
  79518. * @param mesh defines the mesh to use to render this level
  79519. */
  79520. constructor(
  79521. /** Defines the distance where this level should star being displayed */
  79522. distance: number,
  79523. /** Defines the mesh to use to render this level */
  79524. mesh: Nullable<Mesh>);
  79525. }
  79526. }
  79527. declare module BABYLON {
  79528. /**
  79529. * Mesh representing the gorund
  79530. */
  79531. export class GroundMesh extends Mesh {
  79532. /** If octree should be generated */
  79533. generateOctree: boolean;
  79534. private _heightQuads;
  79535. /** @hidden */
  79536. _subdivisionsX: number;
  79537. /** @hidden */
  79538. _subdivisionsY: number;
  79539. /** @hidden */
  79540. _width: number;
  79541. /** @hidden */
  79542. _height: number;
  79543. /** @hidden */
  79544. _minX: number;
  79545. /** @hidden */
  79546. _maxX: number;
  79547. /** @hidden */
  79548. _minZ: number;
  79549. /** @hidden */
  79550. _maxZ: number;
  79551. constructor(name: string, scene: Scene);
  79552. /**
  79553. * "GroundMesh"
  79554. * @returns "GroundMesh"
  79555. */
  79556. getClassName(): string;
  79557. /**
  79558. * The minimum of x and y subdivisions
  79559. */
  79560. readonly subdivisions: number;
  79561. /**
  79562. * X subdivisions
  79563. */
  79564. readonly subdivisionsX: number;
  79565. /**
  79566. * Y subdivisions
  79567. */
  79568. readonly subdivisionsY: number;
  79569. /**
  79570. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79571. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79572. * @param chunksCount the number of subdivisions for x and y
  79573. * @param octreeBlocksSize (Default: 32)
  79574. */
  79575. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  79576. /**
  79577. * Returns a height (y) value in the Worl system :
  79578. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79579. * @param x x coordinate
  79580. * @param z z coordinate
  79581. * @returns the ground y position if (x, z) are outside the ground surface.
  79582. */
  79583. getHeightAtCoordinates(x: number, z: number): number;
  79584. /**
  79585. * Returns a normalized vector (Vector3) orthogonal to the ground
  79586. * at the ground coordinates (x, z) expressed in the World system.
  79587. * @param x x coordinate
  79588. * @param z z coordinate
  79589. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79590. */
  79591. getNormalAtCoordinates(x: number, z: number): Vector3;
  79592. /**
  79593. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79594. * at the ground coordinates (x, z) expressed in the World system.
  79595. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79596. * @param x x coordinate
  79597. * @param z z coordinate
  79598. * @param ref vector to store the result
  79599. * @returns the GroundMesh.
  79600. */
  79601. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  79602. /**
  79603. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79604. * if the ground has been updated.
  79605. * This can be used in the render loop.
  79606. * @returns the GroundMesh.
  79607. */
  79608. updateCoordinateHeights(): GroundMesh;
  79609. private _getFacetAt;
  79610. private _initHeightQuads;
  79611. private _computeHeightQuads;
  79612. /**
  79613. * Serializes this ground mesh
  79614. * @param serializationObject object to write serialization to
  79615. */
  79616. serialize(serializationObject: any): void;
  79617. /**
  79618. * Parses a serialized ground mesh
  79619. * @param parsedMesh the serialized mesh
  79620. * @param scene the scene to create the ground mesh in
  79621. * @returns the created ground mesh
  79622. */
  79623. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  79624. }
  79625. }
  79626. declare module BABYLON {
  79627. /**
  79628. * Interface for Physics-Joint data
  79629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79630. */
  79631. export interface PhysicsJointData {
  79632. /**
  79633. * The main pivot of the joint
  79634. */
  79635. mainPivot?: Vector3;
  79636. /**
  79637. * The connected pivot of the joint
  79638. */
  79639. connectedPivot?: Vector3;
  79640. /**
  79641. * The main axis of the joint
  79642. */
  79643. mainAxis?: Vector3;
  79644. /**
  79645. * The connected axis of the joint
  79646. */
  79647. connectedAxis?: Vector3;
  79648. /**
  79649. * The collision of the joint
  79650. */
  79651. collision?: boolean;
  79652. /**
  79653. * Native Oimo/Cannon/Energy data
  79654. */
  79655. nativeParams?: any;
  79656. }
  79657. /**
  79658. * This is a holder class for the physics joint created by the physics plugin
  79659. * It holds a set of functions to control the underlying joint
  79660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79661. */
  79662. export class PhysicsJoint {
  79663. /**
  79664. * The type of the physics joint
  79665. */
  79666. type: number;
  79667. /**
  79668. * The data for the physics joint
  79669. */
  79670. jointData: PhysicsJointData;
  79671. private _physicsJoint;
  79672. protected _physicsPlugin: IPhysicsEnginePlugin;
  79673. /**
  79674. * Initializes the physics joint
  79675. * @param type The type of the physics joint
  79676. * @param jointData The data for the physics joint
  79677. */
  79678. constructor(
  79679. /**
  79680. * The type of the physics joint
  79681. */
  79682. type: number,
  79683. /**
  79684. * The data for the physics joint
  79685. */
  79686. jointData: PhysicsJointData);
  79687. /**
  79688. * Gets the physics joint
  79689. */
  79690. /**
  79691. * Sets the physics joint
  79692. */
  79693. physicsJoint: any;
  79694. /**
  79695. * Sets the physics plugin
  79696. */
  79697. physicsPlugin: IPhysicsEnginePlugin;
  79698. /**
  79699. * Execute a function that is physics-plugin specific.
  79700. * @param {Function} func the function that will be executed.
  79701. * It accepts two parameters: the physics world and the physics joint
  79702. */
  79703. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  79704. /**
  79705. * Distance-Joint type
  79706. */
  79707. static DistanceJoint: number;
  79708. /**
  79709. * Hinge-Joint type
  79710. */
  79711. static HingeJoint: number;
  79712. /**
  79713. * Ball-and-Socket joint type
  79714. */
  79715. static BallAndSocketJoint: number;
  79716. /**
  79717. * Wheel-Joint type
  79718. */
  79719. static WheelJoint: number;
  79720. /**
  79721. * Slider-Joint type
  79722. */
  79723. static SliderJoint: number;
  79724. /**
  79725. * Prismatic-Joint type
  79726. */
  79727. static PrismaticJoint: number;
  79728. /**
  79729. * Universal-Joint type
  79730. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  79731. */
  79732. static UniversalJoint: number;
  79733. /**
  79734. * Hinge-Joint 2 type
  79735. */
  79736. static Hinge2Joint: number;
  79737. /**
  79738. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  79739. */
  79740. static PointToPointJoint: number;
  79741. /**
  79742. * Spring-Joint type
  79743. */
  79744. static SpringJoint: number;
  79745. /**
  79746. * Lock-Joint type
  79747. */
  79748. static LockJoint: number;
  79749. }
  79750. /**
  79751. * A class representing a physics distance joint
  79752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79753. */
  79754. export class DistanceJoint extends PhysicsJoint {
  79755. /**
  79756. *
  79757. * @param jointData The data for the Distance-Joint
  79758. */
  79759. constructor(jointData: DistanceJointData);
  79760. /**
  79761. * Update the predefined distance.
  79762. * @param maxDistance The maximum preferred distance
  79763. * @param minDistance The minimum preferred distance
  79764. */
  79765. updateDistance(maxDistance: number, minDistance?: number): void;
  79766. }
  79767. /**
  79768. * Represents a Motor-Enabled Joint
  79769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79770. */
  79771. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  79772. /**
  79773. * Initializes the Motor-Enabled Joint
  79774. * @param type The type of the joint
  79775. * @param jointData The physica joint data for the joint
  79776. */
  79777. constructor(type: number, jointData: PhysicsJointData);
  79778. /**
  79779. * Set the motor values.
  79780. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79781. * @param force the force to apply
  79782. * @param maxForce max force for this motor.
  79783. */
  79784. setMotor(force?: number, maxForce?: number): void;
  79785. /**
  79786. * Set the motor's limits.
  79787. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79788. * @param upperLimit The upper limit of the motor
  79789. * @param lowerLimit The lower limit of the motor
  79790. */
  79791. setLimit(upperLimit: number, lowerLimit?: number): void;
  79792. }
  79793. /**
  79794. * This class represents a single physics Hinge-Joint
  79795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79796. */
  79797. export class HingeJoint extends MotorEnabledJoint {
  79798. /**
  79799. * Initializes the Hinge-Joint
  79800. * @param jointData The joint data for the Hinge-Joint
  79801. */
  79802. constructor(jointData: PhysicsJointData);
  79803. /**
  79804. * Set the motor values.
  79805. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79806. * @param {number} force the force to apply
  79807. * @param {number} maxForce max force for this motor.
  79808. */
  79809. setMotor(force?: number, maxForce?: number): void;
  79810. /**
  79811. * Set the motor's limits.
  79812. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79813. * @param upperLimit The upper limit of the motor
  79814. * @param lowerLimit The lower limit of the motor
  79815. */
  79816. setLimit(upperLimit: number, lowerLimit?: number): void;
  79817. }
  79818. /**
  79819. * This class represents a dual hinge physics joint (same as wheel joint)
  79820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79821. */
  79822. export class Hinge2Joint extends MotorEnabledJoint {
  79823. /**
  79824. * Initializes the Hinge2-Joint
  79825. * @param jointData The joint data for the Hinge2-Joint
  79826. */
  79827. constructor(jointData: PhysicsJointData);
  79828. /**
  79829. * Set the motor values.
  79830. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79831. * @param {number} targetSpeed the speed the motor is to reach
  79832. * @param {number} maxForce max force for this motor.
  79833. * @param {motorIndex} the motor's index, 0 or 1.
  79834. */
  79835. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  79836. /**
  79837. * Set the motor limits.
  79838. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79839. * @param {number} upperLimit the upper limit
  79840. * @param {number} lowerLimit lower limit
  79841. * @param {motorIndex} the motor's index, 0 or 1.
  79842. */
  79843. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79844. }
  79845. /**
  79846. * Interface for a motor enabled joint
  79847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79848. */
  79849. export interface IMotorEnabledJoint {
  79850. /**
  79851. * Physics joint
  79852. */
  79853. physicsJoint: any;
  79854. /**
  79855. * Sets the motor of the motor-enabled joint
  79856. * @param force The force of the motor
  79857. * @param maxForce The maximum force of the motor
  79858. * @param motorIndex The index of the motor
  79859. */
  79860. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  79861. /**
  79862. * Sets the limit of the motor
  79863. * @param upperLimit The upper limit of the motor
  79864. * @param lowerLimit The lower limit of the motor
  79865. * @param motorIndex The index of the motor
  79866. */
  79867. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79868. }
  79869. /**
  79870. * Joint data for a Distance-Joint
  79871. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79872. */
  79873. export interface DistanceJointData extends PhysicsJointData {
  79874. /**
  79875. * Max distance the 2 joint objects can be apart
  79876. */
  79877. maxDistance: number;
  79878. }
  79879. /**
  79880. * Joint data from a spring joint
  79881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79882. */
  79883. export interface SpringJointData extends PhysicsJointData {
  79884. /**
  79885. * Length of the spring
  79886. */
  79887. length: number;
  79888. /**
  79889. * Stiffness of the spring
  79890. */
  79891. stiffness: number;
  79892. /**
  79893. * Damping of the spring
  79894. */
  79895. damping: number;
  79896. /** this callback will be called when applying the force to the impostors. */
  79897. forceApplicationCallback: () => void;
  79898. }
  79899. }
  79900. declare module BABYLON {
  79901. /**
  79902. * Holds the data for the raycast result
  79903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79904. */
  79905. export class PhysicsRaycastResult {
  79906. private _hasHit;
  79907. private _hitDistance;
  79908. private _hitNormalWorld;
  79909. private _hitPointWorld;
  79910. private _rayFromWorld;
  79911. private _rayToWorld;
  79912. /**
  79913. * Gets if there was a hit
  79914. */
  79915. readonly hasHit: boolean;
  79916. /**
  79917. * Gets the distance from the hit
  79918. */
  79919. readonly hitDistance: number;
  79920. /**
  79921. * Gets the hit normal/direction in the world
  79922. */
  79923. readonly hitNormalWorld: Vector3;
  79924. /**
  79925. * Gets the hit point in the world
  79926. */
  79927. readonly hitPointWorld: Vector3;
  79928. /**
  79929. * Gets the ray "start point" of the ray in the world
  79930. */
  79931. readonly rayFromWorld: Vector3;
  79932. /**
  79933. * Gets the ray "end point" of the ray in the world
  79934. */
  79935. readonly rayToWorld: Vector3;
  79936. /**
  79937. * Sets the hit data (normal & point in world space)
  79938. * @param hitNormalWorld defines the normal in world space
  79939. * @param hitPointWorld defines the point in world space
  79940. */
  79941. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  79942. /**
  79943. * Sets the distance from the start point to the hit point
  79944. * @param distance
  79945. */
  79946. setHitDistance(distance: number): void;
  79947. /**
  79948. * Calculates the distance manually
  79949. */
  79950. calculateHitDistance(): void;
  79951. /**
  79952. * Resets all the values to default
  79953. * @param from The from point on world space
  79954. * @param to The to point on world space
  79955. */
  79956. reset(from?: Vector3, to?: Vector3): void;
  79957. }
  79958. /**
  79959. * Interface for the size containing width and height
  79960. */
  79961. interface IXYZ {
  79962. /**
  79963. * X
  79964. */
  79965. x: number;
  79966. /**
  79967. * Y
  79968. */
  79969. y: number;
  79970. /**
  79971. * Z
  79972. */
  79973. z: number;
  79974. }
  79975. }
  79976. declare module BABYLON {
  79977. /**
  79978. * Interface used to describe a physics joint
  79979. */
  79980. export interface PhysicsImpostorJoint {
  79981. /** Defines the main impostor to which the joint is linked */
  79982. mainImpostor: PhysicsImpostor;
  79983. /** Defines the impostor that is connected to the main impostor using this joint */
  79984. connectedImpostor: PhysicsImpostor;
  79985. /** Defines the joint itself */
  79986. joint: PhysicsJoint;
  79987. }
  79988. /** @hidden */
  79989. export interface IPhysicsEnginePlugin {
  79990. world: any;
  79991. name: string;
  79992. setGravity(gravity: Vector3): void;
  79993. setTimeStep(timeStep: number): void;
  79994. getTimeStep(): number;
  79995. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  79996. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79997. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79998. generatePhysicsBody(impostor: PhysicsImpostor): void;
  79999. removePhysicsBody(impostor: PhysicsImpostor): void;
  80000. generateJoint(joint: PhysicsImpostorJoint): void;
  80001. removeJoint(joint: PhysicsImpostorJoint): void;
  80002. isSupported(): boolean;
  80003. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  80004. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  80005. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80006. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80007. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80008. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80009. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  80010. getBodyMass(impostor: PhysicsImpostor): number;
  80011. getBodyFriction(impostor: PhysicsImpostor): number;
  80012. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  80013. getBodyRestitution(impostor: PhysicsImpostor): number;
  80014. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  80015. getBodyPressure?(impostor: PhysicsImpostor): number;
  80016. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  80017. getBodyStiffness?(impostor: PhysicsImpostor): number;
  80018. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  80019. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  80020. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  80021. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  80022. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  80023. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80024. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80025. sleepBody(impostor: PhysicsImpostor): void;
  80026. wakeUpBody(impostor: PhysicsImpostor): void;
  80027. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80028. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  80029. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  80030. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  80031. getRadius(impostor: PhysicsImpostor): number;
  80032. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  80033. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  80034. dispose(): void;
  80035. }
  80036. /**
  80037. * Interface used to define a physics engine
  80038. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  80039. */
  80040. export interface IPhysicsEngine {
  80041. /**
  80042. * Gets the gravity vector used by the simulation
  80043. */
  80044. gravity: Vector3;
  80045. /**
  80046. * Sets the gravity vector used by the simulation
  80047. * @param gravity defines the gravity vector to use
  80048. */
  80049. setGravity(gravity: Vector3): void;
  80050. /**
  80051. * Set the time step of the physics engine.
  80052. * Default is 1/60.
  80053. * To slow it down, enter 1/600 for example.
  80054. * To speed it up, 1/30
  80055. * @param newTimeStep the new timestep to apply to this world.
  80056. */
  80057. setTimeStep(newTimeStep: number): void;
  80058. /**
  80059. * Get the time step of the physics engine.
  80060. * @returns the current time step
  80061. */
  80062. getTimeStep(): number;
  80063. /**
  80064. * Release all resources
  80065. */
  80066. dispose(): void;
  80067. /**
  80068. * Gets the name of the current physics plugin
  80069. * @returns the name of the plugin
  80070. */
  80071. getPhysicsPluginName(): string;
  80072. /**
  80073. * Adding a new impostor for the impostor tracking.
  80074. * This will be done by the impostor itself.
  80075. * @param impostor the impostor to add
  80076. */
  80077. addImpostor(impostor: PhysicsImpostor): void;
  80078. /**
  80079. * Remove an impostor from the engine.
  80080. * This impostor and its mesh will not longer be updated by the physics engine.
  80081. * @param impostor the impostor to remove
  80082. */
  80083. removeImpostor(impostor: PhysicsImpostor): void;
  80084. /**
  80085. * Add a joint to the physics engine
  80086. * @param mainImpostor defines the main impostor to which the joint is added.
  80087. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  80088. * @param joint defines the joint that will connect both impostors.
  80089. */
  80090. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80091. /**
  80092. * Removes a joint from the simulation
  80093. * @param mainImpostor defines the impostor used with the joint
  80094. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  80095. * @param joint defines the joint to remove
  80096. */
  80097. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80098. /**
  80099. * Gets the current plugin used to run the simulation
  80100. * @returns current plugin
  80101. */
  80102. getPhysicsPlugin(): IPhysicsEnginePlugin;
  80103. /**
  80104. * Gets the list of physic impostors
  80105. * @returns an array of PhysicsImpostor
  80106. */
  80107. getImpostors(): Array<PhysicsImpostor>;
  80108. /**
  80109. * Gets the impostor for a physics enabled object
  80110. * @param object defines the object impersonated by the impostor
  80111. * @returns the PhysicsImpostor or null if not found
  80112. */
  80113. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80114. /**
  80115. * Gets the impostor for a physics body object
  80116. * @param body defines physics body used by the impostor
  80117. * @returns the PhysicsImpostor or null if not found
  80118. */
  80119. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  80120. /**
  80121. * Does a raycast in the physics world
  80122. * @param from when should the ray start?
  80123. * @param to when should the ray end?
  80124. * @returns PhysicsRaycastResult
  80125. */
  80126. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80127. /**
  80128. * Called by the scene. No need to call it.
  80129. * @param delta defines the timespam between frames
  80130. */
  80131. _step(delta: number): void;
  80132. }
  80133. }
  80134. declare module BABYLON {
  80135. /**
  80136. * The interface for the physics imposter parameters
  80137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80138. */
  80139. export interface PhysicsImpostorParameters {
  80140. /**
  80141. * The mass of the physics imposter
  80142. */
  80143. mass: number;
  80144. /**
  80145. * The friction of the physics imposter
  80146. */
  80147. friction?: number;
  80148. /**
  80149. * The coefficient of restitution of the physics imposter
  80150. */
  80151. restitution?: number;
  80152. /**
  80153. * The native options of the physics imposter
  80154. */
  80155. nativeOptions?: any;
  80156. /**
  80157. * Specifies if the parent should be ignored
  80158. */
  80159. ignoreParent?: boolean;
  80160. /**
  80161. * Specifies if bi-directional transformations should be disabled
  80162. */
  80163. disableBidirectionalTransformation?: boolean;
  80164. /**
  80165. * The pressure inside the physics imposter, soft object only
  80166. */
  80167. pressure?: number;
  80168. /**
  80169. * The stiffness the physics imposter, soft object only
  80170. */
  80171. stiffness?: number;
  80172. /**
  80173. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  80174. */
  80175. velocityIterations?: number;
  80176. /**
  80177. * The number of iterations used in maintaining consistent vertex positions, soft object only
  80178. */
  80179. positionIterations?: number;
  80180. /**
  80181. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  80182. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  80183. * Add to fix multiple points
  80184. */
  80185. fixedPoints?: number;
  80186. /**
  80187. * The collision margin around a soft object
  80188. */
  80189. margin?: number;
  80190. /**
  80191. * The collision margin around a soft object
  80192. */
  80193. damping?: number;
  80194. /**
  80195. * The path for a rope based on an extrusion
  80196. */
  80197. path?: any;
  80198. /**
  80199. * The shape of an extrusion used for a rope based on an extrusion
  80200. */
  80201. shape?: any;
  80202. }
  80203. /**
  80204. * Interface for a physics-enabled object
  80205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80206. */
  80207. export interface IPhysicsEnabledObject {
  80208. /**
  80209. * The position of the physics-enabled object
  80210. */
  80211. position: Vector3;
  80212. /**
  80213. * The rotation of the physics-enabled object
  80214. */
  80215. rotationQuaternion: Nullable<Quaternion>;
  80216. /**
  80217. * The scale of the physics-enabled object
  80218. */
  80219. scaling: Vector3;
  80220. /**
  80221. * The rotation of the physics-enabled object
  80222. */
  80223. rotation?: Vector3;
  80224. /**
  80225. * The parent of the physics-enabled object
  80226. */
  80227. parent?: any;
  80228. /**
  80229. * The bounding info of the physics-enabled object
  80230. * @returns The bounding info of the physics-enabled object
  80231. */
  80232. getBoundingInfo(): BoundingInfo;
  80233. /**
  80234. * Computes the world matrix
  80235. * @param force Specifies if the world matrix should be computed by force
  80236. * @returns A world matrix
  80237. */
  80238. computeWorldMatrix(force: boolean): Matrix;
  80239. /**
  80240. * Gets the world matrix
  80241. * @returns A world matrix
  80242. */
  80243. getWorldMatrix?(): Matrix;
  80244. /**
  80245. * Gets the child meshes
  80246. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  80247. * @returns An array of abstract meshes
  80248. */
  80249. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  80250. /**
  80251. * Gets the vertex data
  80252. * @param kind The type of vertex data
  80253. * @returns A nullable array of numbers, or a float32 array
  80254. */
  80255. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  80256. /**
  80257. * Gets the indices from the mesh
  80258. * @returns A nullable array of index arrays
  80259. */
  80260. getIndices?(): Nullable<IndicesArray>;
  80261. /**
  80262. * Gets the scene from the mesh
  80263. * @returns the indices array or null
  80264. */
  80265. getScene?(): Scene;
  80266. /**
  80267. * Gets the absolute position from the mesh
  80268. * @returns the absolute position
  80269. */
  80270. getAbsolutePosition(): Vector3;
  80271. /**
  80272. * Gets the absolute pivot point from the mesh
  80273. * @returns the absolute pivot point
  80274. */
  80275. getAbsolutePivotPoint(): Vector3;
  80276. /**
  80277. * Rotates the mesh
  80278. * @param axis The axis of rotation
  80279. * @param amount The amount of rotation
  80280. * @param space The space of the rotation
  80281. * @returns The rotation transform node
  80282. */
  80283. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80284. /**
  80285. * Translates the mesh
  80286. * @param axis The axis of translation
  80287. * @param distance The distance of translation
  80288. * @param space The space of the translation
  80289. * @returns The transform node
  80290. */
  80291. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80292. /**
  80293. * Sets the absolute position of the mesh
  80294. * @param absolutePosition The absolute position of the mesh
  80295. * @returns The transform node
  80296. */
  80297. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80298. /**
  80299. * Gets the class name of the mesh
  80300. * @returns The class name
  80301. */
  80302. getClassName(): string;
  80303. }
  80304. /**
  80305. * Represents a physics imposter
  80306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80307. */
  80308. export class PhysicsImpostor {
  80309. /**
  80310. * The physics-enabled object used as the physics imposter
  80311. */
  80312. object: IPhysicsEnabledObject;
  80313. /**
  80314. * The type of the physics imposter
  80315. */
  80316. type: number;
  80317. private _options;
  80318. private _scene?;
  80319. /**
  80320. * The default object size of the imposter
  80321. */
  80322. static DEFAULT_OBJECT_SIZE: Vector3;
  80323. /**
  80324. * The identity quaternion of the imposter
  80325. */
  80326. static IDENTITY_QUATERNION: Quaternion;
  80327. /** @hidden */
  80328. _pluginData: any;
  80329. private _physicsEngine;
  80330. private _physicsBody;
  80331. private _bodyUpdateRequired;
  80332. private _onBeforePhysicsStepCallbacks;
  80333. private _onAfterPhysicsStepCallbacks;
  80334. /** @hidden */
  80335. _onPhysicsCollideCallbacks: Array<{
  80336. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  80337. otherImpostors: Array<PhysicsImpostor>;
  80338. }>;
  80339. private _deltaPosition;
  80340. private _deltaRotation;
  80341. private _deltaRotationConjugated;
  80342. /** hidden */
  80343. _isFromLine: boolean;
  80344. private _parent;
  80345. private _isDisposed;
  80346. private static _tmpVecs;
  80347. private static _tmpQuat;
  80348. /**
  80349. * Specifies if the physics imposter is disposed
  80350. */
  80351. readonly isDisposed: boolean;
  80352. /**
  80353. * Gets the mass of the physics imposter
  80354. */
  80355. mass: number;
  80356. /**
  80357. * Gets the coefficient of friction
  80358. */
  80359. /**
  80360. * Sets the coefficient of friction
  80361. */
  80362. friction: number;
  80363. /**
  80364. * Gets the coefficient of restitution
  80365. */
  80366. /**
  80367. * Sets the coefficient of restitution
  80368. */
  80369. restitution: number;
  80370. /**
  80371. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  80372. */
  80373. /**
  80374. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  80375. */
  80376. pressure: number;
  80377. /**
  80378. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80379. */
  80380. /**
  80381. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80382. */
  80383. stiffness: number;
  80384. /**
  80385. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80386. */
  80387. /**
  80388. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80389. */
  80390. velocityIterations: number;
  80391. /**
  80392. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80393. */
  80394. /**
  80395. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80396. */
  80397. positionIterations: number;
  80398. /**
  80399. * The unique id of the physics imposter
  80400. * set by the physics engine when adding this impostor to the array
  80401. */
  80402. uniqueId: number;
  80403. /**
  80404. * @hidden
  80405. */
  80406. soft: boolean;
  80407. /**
  80408. * @hidden
  80409. */
  80410. segments: number;
  80411. private _joints;
  80412. /**
  80413. * Initializes the physics imposter
  80414. * @param object The physics-enabled object used as the physics imposter
  80415. * @param type The type of the physics imposter
  80416. * @param _options The options for the physics imposter
  80417. * @param _scene The Babylon scene
  80418. */
  80419. constructor(
  80420. /**
  80421. * The physics-enabled object used as the physics imposter
  80422. */
  80423. object: IPhysicsEnabledObject,
  80424. /**
  80425. * The type of the physics imposter
  80426. */
  80427. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  80428. /**
  80429. * This function will completly initialize this impostor.
  80430. * It will create a new body - but only if this mesh has no parent.
  80431. * If it has, this impostor will not be used other than to define the impostor
  80432. * of the child mesh.
  80433. * @hidden
  80434. */
  80435. _init(): void;
  80436. private _getPhysicsParent;
  80437. /**
  80438. * Should a new body be generated.
  80439. * @returns boolean specifying if body initialization is required
  80440. */
  80441. isBodyInitRequired(): boolean;
  80442. /**
  80443. * Sets the updated scaling
  80444. * @param updated Specifies if the scaling is updated
  80445. */
  80446. setScalingUpdated(): void;
  80447. /**
  80448. * Force a regeneration of this or the parent's impostor's body.
  80449. * Use under cautious - This will remove all joints already implemented.
  80450. */
  80451. forceUpdate(): void;
  80452. /**
  80453. * Gets the body that holds this impostor. Either its own, or its parent.
  80454. */
  80455. /**
  80456. * Set the physics body. Used mainly by the physics engine/plugin
  80457. */
  80458. physicsBody: any;
  80459. /**
  80460. * Get the parent of the physics imposter
  80461. * @returns Physics imposter or null
  80462. */
  80463. /**
  80464. * Sets the parent of the physics imposter
  80465. */
  80466. parent: Nullable<PhysicsImpostor>;
  80467. /**
  80468. * Resets the update flags
  80469. */
  80470. resetUpdateFlags(): void;
  80471. /**
  80472. * Gets the object extend size
  80473. * @returns the object extend size
  80474. */
  80475. getObjectExtendSize(): Vector3;
  80476. /**
  80477. * Gets the object center
  80478. * @returns The object center
  80479. */
  80480. getObjectCenter(): Vector3;
  80481. /**
  80482. * Get a specific parametes from the options parameter
  80483. * @param paramName The object parameter name
  80484. * @returns The object parameter
  80485. */
  80486. getParam(paramName: string): any;
  80487. /**
  80488. * Sets a specific parameter in the options given to the physics plugin
  80489. * @param paramName The parameter name
  80490. * @param value The value of the parameter
  80491. */
  80492. setParam(paramName: string, value: number): void;
  80493. /**
  80494. * Specifically change the body's mass option. Won't recreate the physics body object
  80495. * @param mass The mass of the physics imposter
  80496. */
  80497. setMass(mass: number): void;
  80498. /**
  80499. * Gets the linear velocity
  80500. * @returns linear velocity or null
  80501. */
  80502. getLinearVelocity(): Nullable<Vector3>;
  80503. /**
  80504. * Sets the linear velocity
  80505. * @param velocity linear velocity or null
  80506. */
  80507. setLinearVelocity(velocity: Nullable<Vector3>): void;
  80508. /**
  80509. * Gets the angular velocity
  80510. * @returns angular velocity or null
  80511. */
  80512. getAngularVelocity(): Nullable<Vector3>;
  80513. /**
  80514. * Sets the angular velocity
  80515. * @param velocity The velocity or null
  80516. */
  80517. setAngularVelocity(velocity: Nullable<Vector3>): void;
  80518. /**
  80519. * Execute a function with the physics plugin native code
  80520. * Provide a function the will have two variables - the world object and the physics body object
  80521. * @param func The function to execute with the physics plugin native code
  80522. */
  80523. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  80524. /**
  80525. * Register a function that will be executed before the physics world is stepping forward
  80526. * @param func The function to execute before the physics world is stepped forward
  80527. */
  80528. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80529. /**
  80530. * Unregister a function that will be executed before the physics world is stepping forward
  80531. * @param func The function to execute before the physics world is stepped forward
  80532. */
  80533. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80534. /**
  80535. * Register a function that will be executed after the physics step
  80536. * @param func The function to execute after physics step
  80537. */
  80538. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80539. /**
  80540. * Unregisters a function that will be executed after the physics step
  80541. * @param func The function to execute after physics step
  80542. */
  80543. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80544. /**
  80545. * register a function that will be executed when this impostor collides against a different body
  80546. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  80547. * @param func Callback that is executed on collision
  80548. */
  80549. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  80550. /**
  80551. * Unregisters the physics imposter on contact
  80552. * @param collideAgainst The physics object to collide against
  80553. * @param func Callback to execute on collision
  80554. */
  80555. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  80556. private _tmpQuat;
  80557. private _tmpQuat2;
  80558. /**
  80559. * Get the parent rotation
  80560. * @returns The parent rotation
  80561. */
  80562. getParentsRotation(): Quaternion;
  80563. /**
  80564. * this function is executed by the physics engine.
  80565. */
  80566. beforeStep: () => void;
  80567. /**
  80568. * this function is executed by the physics engine
  80569. */
  80570. afterStep: () => void;
  80571. /**
  80572. * Legacy collision detection event support
  80573. */
  80574. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  80575. /**
  80576. * event and body object due to cannon's event-based architecture.
  80577. */
  80578. onCollide: (e: {
  80579. body: any;
  80580. }) => void;
  80581. /**
  80582. * Apply a force
  80583. * @param force The force to apply
  80584. * @param contactPoint The contact point for the force
  80585. * @returns The physics imposter
  80586. */
  80587. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80588. /**
  80589. * Apply an impulse
  80590. * @param force The impulse force
  80591. * @param contactPoint The contact point for the impulse force
  80592. * @returns The physics imposter
  80593. */
  80594. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80595. /**
  80596. * A help function to create a joint
  80597. * @param otherImpostor A physics imposter used to create a joint
  80598. * @param jointType The type of joint
  80599. * @param jointData The data for the joint
  80600. * @returns The physics imposter
  80601. */
  80602. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  80603. /**
  80604. * Add a joint to this impostor with a different impostor
  80605. * @param otherImpostor A physics imposter used to add a joint
  80606. * @param joint The joint to add
  80607. * @returns The physics imposter
  80608. */
  80609. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  80610. /**
  80611. * Add an anchor to a cloth impostor
  80612. * @param otherImpostor rigid impostor to anchor to
  80613. * @param width ratio across width from 0 to 1
  80614. * @param height ratio up height from 0 to 1
  80615. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  80616. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  80617. * @returns impostor the soft imposter
  80618. */
  80619. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80620. /**
  80621. * Add a hook to a rope impostor
  80622. * @param otherImpostor rigid impostor to anchor to
  80623. * @param length ratio across rope from 0 to 1
  80624. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  80625. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  80626. * @returns impostor the rope imposter
  80627. */
  80628. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80629. /**
  80630. * Will keep this body still, in a sleep mode.
  80631. * @returns the physics imposter
  80632. */
  80633. sleep(): PhysicsImpostor;
  80634. /**
  80635. * Wake the body up.
  80636. * @returns The physics imposter
  80637. */
  80638. wakeUp(): PhysicsImpostor;
  80639. /**
  80640. * Clones the physics imposter
  80641. * @param newObject The physics imposter clones to this physics-enabled object
  80642. * @returns A nullable physics imposter
  80643. */
  80644. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80645. /**
  80646. * Disposes the physics imposter
  80647. */
  80648. dispose(): void;
  80649. /**
  80650. * Sets the delta position
  80651. * @param position The delta position amount
  80652. */
  80653. setDeltaPosition(position: Vector3): void;
  80654. /**
  80655. * Sets the delta rotation
  80656. * @param rotation The delta rotation amount
  80657. */
  80658. setDeltaRotation(rotation: Quaternion): void;
  80659. /**
  80660. * Gets the box size of the physics imposter and stores the result in the input parameter
  80661. * @param result Stores the box size
  80662. * @returns The physics imposter
  80663. */
  80664. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  80665. /**
  80666. * Gets the radius of the physics imposter
  80667. * @returns Radius of the physics imposter
  80668. */
  80669. getRadius(): number;
  80670. /**
  80671. * Sync a bone with this impostor
  80672. * @param bone The bone to sync to the impostor.
  80673. * @param boneMesh The mesh that the bone is influencing.
  80674. * @param jointPivot The pivot of the joint / bone in local space.
  80675. * @param distToJoint Optional distance from the impostor to the joint.
  80676. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80677. */
  80678. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  80679. /**
  80680. * Sync impostor to a bone
  80681. * @param bone The bone that the impostor will be synced to.
  80682. * @param boneMesh The mesh that the bone is influencing.
  80683. * @param jointPivot The pivot of the joint / bone in local space.
  80684. * @param distToJoint Optional distance from the impostor to the joint.
  80685. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80686. * @param boneAxis Optional vector3 axis the bone is aligned with
  80687. */
  80688. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  80689. /**
  80690. * No-Imposter type
  80691. */
  80692. static NoImpostor: number;
  80693. /**
  80694. * Sphere-Imposter type
  80695. */
  80696. static SphereImpostor: number;
  80697. /**
  80698. * Box-Imposter type
  80699. */
  80700. static BoxImpostor: number;
  80701. /**
  80702. * Plane-Imposter type
  80703. */
  80704. static PlaneImpostor: number;
  80705. /**
  80706. * Mesh-imposter type
  80707. */
  80708. static MeshImpostor: number;
  80709. /**
  80710. * Cylinder-Imposter type
  80711. */
  80712. static CylinderImpostor: number;
  80713. /**
  80714. * Particle-Imposter type
  80715. */
  80716. static ParticleImpostor: number;
  80717. /**
  80718. * Heightmap-Imposter type
  80719. */
  80720. static HeightmapImpostor: number;
  80721. /**
  80722. * ConvexHull-Impostor type (Ammo.js plugin only)
  80723. */
  80724. static ConvexHullImpostor: number;
  80725. /**
  80726. * Rope-Imposter type
  80727. */
  80728. static RopeImpostor: number;
  80729. /**
  80730. * Cloth-Imposter type
  80731. */
  80732. static ClothImpostor: number;
  80733. /**
  80734. * Softbody-Imposter type
  80735. */
  80736. static SoftbodyImpostor: number;
  80737. }
  80738. }
  80739. declare module BABYLON {
  80740. /**
  80741. * @hidden
  80742. **/
  80743. export class _CreationDataStorage {
  80744. closePath?: boolean;
  80745. closeArray?: boolean;
  80746. idx: number[];
  80747. dashSize: number;
  80748. gapSize: number;
  80749. path3D: Path3D;
  80750. pathArray: Vector3[][];
  80751. arc: number;
  80752. radius: number;
  80753. cap: number;
  80754. tessellation: number;
  80755. }
  80756. /**
  80757. * @hidden
  80758. **/
  80759. class _InstanceDataStorage {
  80760. visibleInstances: any;
  80761. batchCache: _InstancesBatch;
  80762. instancesBufferSize: number;
  80763. instancesBuffer: Nullable<Buffer>;
  80764. instancesData: Float32Array;
  80765. overridenInstanceCount: number;
  80766. isFrozen: boolean;
  80767. previousBatch: _InstancesBatch;
  80768. hardwareInstancedRendering: boolean;
  80769. sideOrientation: number;
  80770. }
  80771. /**
  80772. * @hidden
  80773. **/
  80774. export class _InstancesBatch {
  80775. mustReturn: boolean;
  80776. visibleInstances: Nullable<InstancedMesh[]>[];
  80777. renderSelf: boolean[];
  80778. hardwareInstancedRendering: boolean[];
  80779. }
  80780. /**
  80781. * Class used to represent renderable models
  80782. */
  80783. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  80784. /**
  80785. * Mesh side orientation : usually the external or front surface
  80786. */
  80787. static readonly FRONTSIDE: number;
  80788. /**
  80789. * Mesh side orientation : usually the internal or back surface
  80790. */
  80791. static readonly BACKSIDE: number;
  80792. /**
  80793. * Mesh side orientation : both internal and external or front and back surfaces
  80794. */
  80795. static readonly DOUBLESIDE: number;
  80796. /**
  80797. * Mesh side orientation : by default, `FRONTSIDE`
  80798. */
  80799. static readonly DEFAULTSIDE: number;
  80800. /**
  80801. * Mesh cap setting : no cap
  80802. */
  80803. static readonly NO_CAP: number;
  80804. /**
  80805. * Mesh cap setting : one cap at the beginning of the mesh
  80806. */
  80807. static readonly CAP_START: number;
  80808. /**
  80809. * Mesh cap setting : one cap at the end of the mesh
  80810. */
  80811. static readonly CAP_END: number;
  80812. /**
  80813. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  80814. */
  80815. static readonly CAP_ALL: number;
  80816. /**
  80817. * Gets the default side orientation.
  80818. * @param orientation the orientation to value to attempt to get
  80819. * @returns the default orientation
  80820. * @hidden
  80821. */
  80822. static _GetDefaultSideOrientation(orientation?: number): number;
  80823. private _onBeforeRenderObservable;
  80824. private _onBeforeBindObservable;
  80825. private _onAfterRenderObservable;
  80826. private _onBeforeDrawObservable;
  80827. /**
  80828. * An event triggered before rendering the mesh
  80829. */
  80830. readonly onBeforeRenderObservable: Observable<Mesh>;
  80831. /**
  80832. * An event triggered before binding the mesh
  80833. */
  80834. readonly onBeforeBindObservable: Observable<Mesh>;
  80835. /**
  80836. * An event triggered after rendering the mesh
  80837. */
  80838. readonly onAfterRenderObservable: Observable<Mesh>;
  80839. /**
  80840. * An event triggered before drawing the mesh
  80841. */
  80842. readonly onBeforeDrawObservable: Observable<Mesh>;
  80843. private _onBeforeDrawObserver;
  80844. /**
  80845. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80846. */
  80847. onBeforeDraw: () => void;
  80848. /**
  80849. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80850. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80851. */
  80852. delayLoadState: number;
  80853. /**
  80854. * Gets the list of instances created from this mesh
  80855. * it is not supposed to be modified manually.
  80856. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80857. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80858. */
  80859. instances: InstancedMesh[];
  80860. /**
  80861. * Gets the file containing delay loading data for this mesh
  80862. */
  80863. delayLoadingFile: string;
  80864. /** @hidden */
  80865. _binaryInfo: any;
  80866. private _LODLevels;
  80867. /**
  80868. * User defined function used to change how LOD level selection is done
  80869. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80870. */
  80871. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  80872. private _morphTargetManager;
  80873. /**
  80874. * Gets or sets the morph target manager
  80875. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80876. */
  80877. morphTargetManager: Nullable<MorphTargetManager>;
  80878. /** @hidden */
  80879. _creationDataStorage: Nullable<_CreationDataStorage>;
  80880. /** @hidden */
  80881. _geometry: Nullable<Geometry>;
  80882. /** @hidden */
  80883. _delayInfo: Array<string>;
  80884. /** @hidden */
  80885. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  80886. /** @hidden */
  80887. _instanceDataStorage: _InstanceDataStorage;
  80888. private _effectiveMaterial;
  80889. /** @hidden */
  80890. _shouldGenerateFlatShading: boolean;
  80891. private _preActivateId;
  80892. /** @hidden */
  80893. _originalBuilderSideOrientation: number;
  80894. /**
  80895. * Use this property to change the original side orientation defined at construction time
  80896. */
  80897. overrideMaterialSideOrientation: Nullable<number>;
  80898. private _areNormalsFrozen;
  80899. private _sourcePositions;
  80900. private _sourceNormals;
  80901. private _source;
  80902. private meshMap;
  80903. /**
  80904. * Gets the source mesh (the one used to clone this one from)
  80905. */
  80906. readonly source: Nullable<Mesh>;
  80907. /**
  80908. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80909. */
  80910. isUnIndexed: boolean;
  80911. /**
  80912. * @constructor
  80913. * @param name The value used by scene.getMeshByName() to do a lookup.
  80914. * @param scene The scene to add this mesh to.
  80915. * @param parent The parent of this mesh, if it has one
  80916. * @param source An optional Mesh from which geometry is shared, cloned.
  80917. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80918. * When false, achieved by calling a clone(), also passing False.
  80919. * This will make creation of children, recursive.
  80920. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80921. */
  80922. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  80923. /**
  80924. * Gets the class name
  80925. * @returns the string "Mesh".
  80926. */
  80927. getClassName(): string;
  80928. /** @hidden */
  80929. readonly _isMesh: boolean;
  80930. /**
  80931. * Returns a description of this mesh
  80932. * @param fullDetails define if full details about this mesh must be used
  80933. * @returns a descriptive string representing this mesh
  80934. */
  80935. toString(fullDetails?: boolean): string;
  80936. /** @hidden */
  80937. _unBindEffect(): void;
  80938. /**
  80939. * Gets a boolean indicating if this mesh has LOD
  80940. */
  80941. readonly hasLODLevels: boolean;
  80942. /**
  80943. * Gets the list of MeshLODLevel associated with the current mesh
  80944. * @returns an array of MeshLODLevel
  80945. */
  80946. getLODLevels(): MeshLODLevel[];
  80947. private _sortLODLevels;
  80948. /**
  80949. * Add a mesh as LOD level triggered at the given distance.
  80950. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80951. * @param distance The distance from the center of the object to show this level
  80952. * @param mesh The mesh to be added as LOD level (can be null)
  80953. * @return This mesh (for chaining)
  80954. */
  80955. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80956. /**
  80957. * Returns the LOD level mesh at the passed distance or null if not found.
  80958. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80959. * @param distance The distance from the center of the object to show this level
  80960. * @returns a Mesh or `null`
  80961. */
  80962. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80963. /**
  80964. * Remove a mesh from the LOD array
  80965. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80966. * @param mesh defines the mesh to be removed
  80967. * @return This mesh (for chaining)
  80968. */
  80969. removeLODLevel(mesh: Mesh): Mesh;
  80970. /**
  80971. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80972. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80973. * @param camera defines the camera to use to compute distance
  80974. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80975. * @return This mesh (for chaining)
  80976. */
  80977. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80978. /**
  80979. * Gets the mesh internal Geometry object
  80980. */
  80981. readonly geometry: Nullable<Geometry>;
  80982. /**
  80983. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80984. * @returns the total number of vertices
  80985. */
  80986. getTotalVertices(): number;
  80987. /**
  80988. * Returns the content of an associated vertex buffer
  80989. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80990. * - VertexBuffer.PositionKind
  80991. * - VertexBuffer.UVKind
  80992. * - VertexBuffer.UV2Kind
  80993. * - VertexBuffer.UV3Kind
  80994. * - VertexBuffer.UV4Kind
  80995. * - VertexBuffer.UV5Kind
  80996. * - VertexBuffer.UV6Kind
  80997. * - VertexBuffer.ColorKind
  80998. * - VertexBuffer.MatricesIndicesKind
  80999. * - VertexBuffer.MatricesIndicesExtraKind
  81000. * - VertexBuffer.MatricesWeightsKind
  81001. * - VertexBuffer.MatricesWeightsExtraKind
  81002. * @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
  81003. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  81004. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  81005. */
  81006. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81007. /**
  81008. * Returns the mesh VertexBuffer object from the requested `kind`
  81009. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81010. * - VertexBuffer.PositionKind
  81011. * - VertexBuffer.UVKind
  81012. * - VertexBuffer.UV2Kind
  81013. * - VertexBuffer.UV3Kind
  81014. * - VertexBuffer.UV4Kind
  81015. * - VertexBuffer.UV5Kind
  81016. * - VertexBuffer.UV6Kind
  81017. * - VertexBuffer.ColorKind
  81018. * - VertexBuffer.MatricesIndicesKind
  81019. * - VertexBuffer.MatricesIndicesExtraKind
  81020. * - VertexBuffer.MatricesWeightsKind
  81021. * - VertexBuffer.MatricesWeightsExtraKind
  81022. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  81023. */
  81024. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81025. /**
  81026. * Tests if a specific vertex buffer is associated with this mesh
  81027. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81028. * - VertexBuffer.PositionKind
  81029. * - VertexBuffer.UVKind
  81030. * - VertexBuffer.UV2Kind
  81031. * - VertexBuffer.UV3Kind
  81032. * - VertexBuffer.UV4Kind
  81033. * - VertexBuffer.UV5Kind
  81034. * - VertexBuffer.UV6Kind
  81035. * - VertexBuffer.ColorKind
  81036. * - VertexBuffer.MatricesIndicesKind
  81037. * - VertexBuffer.MatricesIndicesExtraKind
  81038. * - VertexBuffer.MatricesWeightsKind
  81039. * - VertexBuffer.MatricesWeightsExtraKind
  81040. * @returns a boolean
  81041. */
  81042. isVerticesDataPresent(kind: string): boolean;
  81043. /**
  81044. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  81045. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81046. * - VertexBuffer.PositionKind
  81047. * - VertexBuffer.UVKind
  81048. * - VertexBuffer.UV2Kind
  81049. * - VertexBuffer.UV3Kind
  81050. * - VertexBuffer.UV4Kind
  81051. * - VertexBuffer.UV5Kind
  81052. * - VertexBuffer.UV6Kind
  81053. * - VertexBuffer.ColorKind
  81054. * - VertexBuffer.MatricesIndicesKind
  81055. * - VertexBuffer.MatricesIndicesExtraKind
  81056. * - VertexBuffer.MatricesWeightsKind
  81057. * - VertexBuffer.MatricesWeightsExtraKind
  81058. * @returns a boolean
  81059. */
  81060. isVertexBufferUpdatable(kind: string): boolean;
  81061. /**
  81062. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  81063. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81064. * - VertexBuffer.PositionKind
  81065. * - VertexBuffer.UVKind
  81066. * - VertexBuffer.UV2Kind
  81067. * - VertexBuffer.UV3Kind
  81068. * - VertexBuffer.UV4Kind
  81069. * - VertexBuffer.UV5Kind
  81070. * - VertexBuffer.UV6Kind
  81071. * - VertexBuffer.ColorKind
  81072. * - VertexBuffer.MatricesIndicesKind
  81073. * - VertexBuffer.MatricesIndicesExtraKind
  81074. * - VertexBuffer.MatricesWeightsKind
  81075. * - VertexBuffer.MatricesWeightsExtraKind
  81076. * @returns an array of strings
  81077. */
  81078. getVerticesDataKinds(): string[];
  81079. /**
  81080. * Returns a positive integer : the total number of indices in this mesh geometry.
  81081. * @returns the numner of indices or zero if the mesh has no geometry.
  81082. */
  81083. getTotalIndices(): number;
  81084. /**
  81085. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81086. * @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.
  81087. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81088. * @returns the indices array or an empty array if the mesh has no geometry
  81089. */
  81090. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81091. readonly isBlocked: boolean;
  81092. /**
  81093. * Determine if the current mesh is ready to be rendered
  81094. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81095. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  81096. * @returns true if all associated assets are ready (material, textures, shaders)
  81097. */
  81098. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  81099. /**
  81100. * 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.
  81101. */
  81102. readonly areNormalsFrozen: boolean;
  81103. /**
  81104. * 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.
  81105. * @returns the current mesh
  81106. */
  81107. freezeNormals(): Mesh;
  81108. /**
  81109. * 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
  81110. * @returns the current mesh
  81111. */
  81112. unfreezeNormals(): Mesh;
  81113. /**
  81114. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  81115. */
  81116. overridenInstanceCount: number;
  81117. /** @hidden */
  81118. _preActivate(): Mesh;
  81119. /** @hidden */
  81120. _preActivateForIntermediateRendering(renderId: number): Mesh;
  81121. /** @hidden */
  81122. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  81123. /**
  81124. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81125. * This means the mesh underlying bounding box and sphere are recomputed.
  81126. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81127. * @returns the current mesh
  81128. */
  81129. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  81130. /** @hidden */
  81131. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  81132. /**
  81133. * This function will subdivide the mesh into multiple submeshes
  81134. * @param count defines the expected number of submeshes
  81135. */
  81136. subdivide(count: number): void;
  81137. /**
  81138. * Copy a FloatArray into a specific associated vertex buffer
  81139. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81140. * - VertexBuffer.PositionKind
  81141. * - VertexBuffer.UVKind
  81142. * - VertexBuffer.UV2Kind
  81143. * - VertexBuffer.UV3Kind
  81144. * - VertexBuffer.UV4Kind
  81145. * - VertexBuffer.UV5Kind
  81146. * - VertexBuffer.UV6Kind
  81147. * - VertexBuffer.ColorKind
  81148. * - VertexBuffer.MatricesIndicesKind
  81149. * - VertexBuffer.MatricesIndicesExtraKind
  81150. * - VertexBuffer.MatricesWeightsKind
  81151. * - VertexBuffer.MatricesWeightsExtraKind
  81152. * @param data defines the data source
  81153. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81154. * @param stride defines the data stride size (can be null)
  81155. * @returns the current mesh
  81156. */
  81157. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  81158. /**
  81159. * Flags an associated vertex buffer as updatable
  81160. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  81161. * - VertexBuffer.PositionKind
  81162. * - VertexBuffer.UVKind
  81163. * - VertexBuffer.UV2Kind
  81164. * - VertexBuffer.UV3Kind
  81165. * - VertexBuffer.UV4Kind
  81166. * - VertexBuffer.UV5Kind
  81167. * - VertexBuffer.UV6Kind
  81168. * - VertexBuffer.ColorKind
  81169. * - VertexBuffer.MatricesIndicesKind
  81170. * - VertexBuffer.MatricesIndicesExtraKind
  81171. * - VertexBuffer.MatricesWeightsKind
  81172. * - VertexBuffer.MatricesWeightsExtraKind
  81173. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81174. */
  81175. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  81176. /**
  81177. * Sets the mesh global Vertex Buffer
  81178. * @param buffer defines the buffer to use
  81179. * @returns the current mesh
  81180. */
  81181. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  81182. /**
  81183. * Update a specific associated vertex buffer
  81184. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81185. * - VertexBuffer.PositionKind
  81186. * - VertexBuffer.UVKind
  81187. * - VertexBuffer.UV2Kind
  81188. * - VertexBuffer.UV3Kind
  81189. * - VertexBuffer.UV4Kind
  81190. * - VertexBuffer.UV5Kind
  81191. * - VertexBuffer.UV6Kind
  81192. * - VertexBuffer.ColorKind
  81193. * - VertexBuffer.MatricesIndicesKind
  81194. * - VertexBuffer.MatricesIndicesExtraKind
  81195. * - VertexBuffer.MatricesWeightsKind
  81196. * - VertexBuffer.MatricesWeightsExtraKind
  81197. * @param data defines the data source
  81198. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81199. * @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)
  81200. * @returns the current mesh
  81201. */
  81202. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  81203. /**
  81204. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  81205. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  81206. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  81207. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  81208. * @returns the current mesh
  81209. */
  81210. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  81211. /**
  81212. * Creates a un-shared specific occurence of the geometry for the mesh.
  81213. * @returns the current mesh
  81214. */
  81215. makeGeometryUnique(): Mesh;
  81216. /**
  81217. * Set the index buffer of this mesh
  81218. * @param indices defines the source data
  81219. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  81220. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  81221. * @returns the current mesh
  81222. */
  81223. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  81224. /**
  81225. * Update the current index buffer
  81226. * @param indices defines the source data
  81227. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81228. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  81229. * @returns the current mesh
  81230. */
  81231. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  81232. /**
  81233. * Invert the geometry to move from a right handed system to a left handed one.
  81234. * @returns the current mesh
  81235. */
  81236. toLeftHanded(): Mesh;
  81237. /** @hidden */
  81238. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  81239. /** @hidden */
  81240. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  81241. /**
  81242. * Registers for this mesh a javascript function called just before the rendering process
  81243. * @param func defines the function to call before rendering this mesh
  81244. * @returns the current mesh
  81245. */
  81246. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81247. /**
  81248. * Disposes a previously registered javascript function called before the rendering
  81249. * @param func defines the function to remove
  81250. * @returns the current mesh
  81251. */
  81252. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81253. /**
  81254. * Registers for this mesh a javascript function called just after the rendering is complete
  81255. * @param func defines the function to call after rendering this mesh
  81256. * @returns the current mesh
  81257. */
  81258. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81259. /**
  81260. * Disposes a previously registered javascript function called after the rendering.
  81261. * @param func defines the function to remove
  81262. * @returns the current mesh
  81263. */
  81264. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81265. /** @hidden */
  81266. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  81267. /** @hidden */
  81268. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  81269. /** @hidden */
  81270. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  81271. /** @hidden */
  81272. _freeze(): void;
  81273. /** @hidden */
  81274. _unFreeze(): void;
  81275. /**
  81276. * 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
  81277. * @param subMesh defines the subMesh to render
  81278. * @param enableAlphaMode defines if alpha mode can be changed
  81279. * @returns the current mesh
  81280. */
  81281. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  81282. private _onBeforeDraw;
  81283. /**
  81284. * Renormalize the mesh and patch it up if there are no weights
  81285. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  81286. * However in the case of zero weights then we set just a single influence to 1.
  81287. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  81288. */
  81289. cleanMatrixWeights(): void;
  81290. private normalizeSkinFourWeights;
  81291. private normalizeSkinWeightsAndExtra;
  81292. /**
  81293. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  81294. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  81295. * the user know there was an issue with importing the mesh
  81296. * @returns a validation object with skinned, valid and report string
  81297. */
  81298. validateSkinning(): {
  81299. skinned: boolean;
  81300. valid: boolean;
  81301. report: string;
  81302. };
  81303. /** @hidden */
  81304. _checkDelayState(): Mesh;
  81305. private _queueLoad;
  81306. /**
  81307. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81308. * A mesh is in the frustum if its bounding box intersects the frustum
  81309. * @param frustumPlanes defines the frustum to test
  81310. * @returns true if the mesh is in the frustum planes
  81311. */
  81312. isInFrustum(frustumPlanes: Plane[]): boolean;
  81313. /**
  81314. * Sets the mesh material by the material or multiMaterial `id` property
  81315. * @param id is a string identifying the material or the multiMaterial
  81316. * @returns the current mesh
  81317. */
  81318. setMaterialByID(id: string): Mesh;
  81319. /**
  81320. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  81321. * @returns an array of IAnimatable
  81322. */
  81323. getAnimatables(): IAnimatable[];
  81324. /**
  81325. * Modifies the mesh geometry according to the passed transformation matrix.
  81326. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  81327. * The mesh normals are modified using the same transformation.
  81328. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81329. * @param transform defines the transform matrix to use
  81330. * @see http://doc.babylonjs.com/resources/baking_transformations
  81331. * @returns the current mesh
  81332. */
  81333. bakeTransformIntoVertices(transform: Matrix): Mesh;
  81334. /**
  81335. * Modifies the mesh geometry according to its own current World Matrix.
  81336. * The mesh World Matrix is then reset.
  81337. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  81338. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81339. * @see http://doc.babylonjs.com/resources/baking_transformations
  81340. * @returns the current mesh
  81341. */
  81342. bakeCurrentTransformIntoVertices(): Mesh;
  81343. /** @hidden */
  81344. readonly _positions: Nullable<Vector3[]>;
  81345. /** @hidden */
  81346. _resetPointsArrayCache(): Mesh;
  81347. /** @hidden */
  81348. _generatePointsArray(): boolean;
  81349. /**
  81350. * Returns a new Mesh object generated from the current mesh properties.
  81351. * This method must not get confused with createInstance()
  81352. * @param name is a string, the name given to the new mesh
  81353. * @param newParent can be any Node object (default `null`)
  81354. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  81355. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  81356. * @returns a new mesh
  81357. */
  81358. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  81359. /**
  81360. * Releases resources associated with this mesh.
  81361. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81362. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81363. */
  81364. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81365. /**
  81366. * Modifies the mesh geometry according to a displacement map.
  81367. * 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.
  81368. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81369. * @param url is a string, the URL from the image file is to be downloaded.
  81370. * @param minHeight is the lower limit of the displacement.
  81371. * @param maxHeight is the upper limit of the displacement.
  81372. * @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.
  81373. * @param uvOffset is an optional vector2 used to offset UV.
  81374. * @param uvScale is an optional vector2 used to scale UV.
  81375. * @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.
  81376. * @returns the Mesh.
  81377. */
  81378. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81379. /**
  81380. * Modifies the mesh geometry according to a displacementMap buffer.
  81381. * 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.
  81382. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81383. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  81384. * @param heightMapWidth is the width of the buffer image.
  81385. * @param heightMapHeight is the height of the buffer image.
  81386. * @param minHeight is the lower limit of the displacement.
  81387. * @param maxHeight is the upper limit of the displacement.
  81388. * @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.
  81389. * @param uvOffset is an optional vector2 used to offset UV.
  81390. * @param uvScale is an optional vector2 used to scale UV.
  81391. * @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.
  81392. * @returns the Mesh.
  81393. */
  81394. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81395. /**
  81396. * Modify the mesh to get a flat shading rendering.
  81397. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  81398. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  81399. * @returns current mesh
  81400. */
  81401. convertToFlatShadedMesh(): Mesh;
  81402. /**
  81403. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  81404. * In other words, more vertices, no more indices and a single bigger VBO.
  81405. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  81406. * @returns current mesh
  81407. */
  81408. convertToUnIndexedMesh(): Mesh;
  81409. /**
  81410. * Inverses facet orientations.
  81411. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81412. * @param flipNormals will also inverts the normals
  81413. * @returns current mesh
  81414. */
  81415. flipFaces(flipNormals?: boolean): Mesh;
  81416. /**
  81417. * Increase the number of facets and hence vertices in a mesh
  81418. * Vertex normals are interpolated from existing vertex normals
  81419. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81420. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  81421. */
  81422. increaseVertices(numberPerEdge: number): void;
  81423. /**
  81424. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  81425. * This will undo any application of covertToFlatShadedMesh
  81426. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81427. */
  81428. forceSharedVertices(): void;
  81429. /** @hidden */
  81430. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  81431. /** @hidden */
  81432. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  81433. /**
  81434. * Creates a new InstancedMesh object from the mesh model.
  81435. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  81436. * @param name defines the name of the new instance
  81437. * @returns a new InstancedMesh
  81438. */
  81439. createInstance(name: string): InstancedMesh;
  81440. /**
  81441. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  81442. * After this call, all the mesh instances have the same submeshes than the current mesh.
  81443. * @returns the current mesh
  81444. */
  81445. synchronizeInstances(): Mesh;
  81446. /**
  81447. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  81448. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  81449. * This should be used together with the simplification to avoid disappearing triangles.
  81450. * @param successCallback an optional success callback to be called after the optimization finished.
  81451. * @returns the current mesh
  81452. */
  81453. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  81454. /**
  81455. * Serialize current mesh
  81456. * @param serializationObject defines the object which will receive the serialization data
  81457. */
  81458. serialize(serializationObject: any): void;
  81459. /** @hidden */
  81460. _syncGeometryWithMorphTargetManager(): void;
  81461. /** @hidden */
  81462. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  81463. /**
  81464. * Returns a new Mesh object parsed from the source provided.
  81465. * @param parsedMesh is the source
  81466. * @param scene defines the hosting scene
  81467. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  81468. * @returns a new Mesh
  81469. */
  81470. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  81471. /**
  81472. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  81473. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81474. * @param name defines the name of the mesh to create
  81475. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  81476. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  81477. * @param closePath creates a seam between the first and the last points of each path of the path array
  81478. * @param offset is taken in account only if the `pathArray` is containing a single path
  81479. * @param scene defines the hosting scene
  81480. * @param updatable defines if the mesh must be flagged as updatable
  81481. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81482. * @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)
  81483. * @returns a new Mesh
  81484. */
  81485. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81486. /**
  81487. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  81488. * @param name defines the name of the mesh to create
  81489. * @param radius sets the radius size (float) of the polygon (default 0.5)
  81490. * @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
  81491. * @param scene defines the hosting scene
  81492. * @param updatable defines if the mesh must be flagged as updatable
  81493. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81494. * @returns a new Mesh
  81495. */
  81496. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81497. /**
  81498. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  81499. * @param name defines the name of the mesh to create
  81500. * @param size sets the size (float) of each box side (default 1)
  81501. * @param scene defines the hosting scene
  81502. * @param updatable defines if the mesh must be flagged as updatable
  81503. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81504. * @returns a new Mesh
  81505. */
  81506. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81507. /**
  81508. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  81509. * @param name defines the name of the mesh to create
  81510. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81511. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81512. * @param scene defines the hosting scene
  81513. * @param updatable defines if the mesh must be flagged as updatable
  81514. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81515. * @returns a new Mesh
  81516. */
  81517. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81518. /**
  81519. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  81520. * @param name defines the name of the mesh to create
  81521. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81522. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81523. * @param scene defines the hosting scene
  81524. * @returns a new Mesh
  81525. */
  81526. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  81527. /**
  81528. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  81529. * @param name defines the name of the mesh to create
  81530. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  81531. * @param diameterTop set the top cap diameter (floats, default 1)
  81532. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  81533. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  81534. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  81535. * @param scene defines the hosting scene
  81536. * @param updatable defines if the mesh must be flagged as updatable
  81537. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81538. * @returns a new Mesh
  81539. */
  81540. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  81541. /**
  81542. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  81543. * @param name defines the name of the mesh to create
  81544. * @param diameter sets the diameter size (float) of the torus (default 1)
  81545. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  81546. * @param tessellation sets the number of torus sides (postive integer, default 16)
  81547. * @param scene defines the hosting scene
  81548. * @param updatable defines if the mesh must be flagged as updatable
  81549. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81550. * @returns a new Mesh
  81551. */
  81552. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81553. /**
  81554. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  81555. * @param name defines the name of the mesh to create
  81556. * @param radius sets the global radius size (float) of the torus knot (default 2)
  81557. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  81558. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  81559. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  81560. * @param p the number of windings on X axis (positive integers, default 2)
  81561. * @param q the number of windings on Y axis (positive integers, default 3)
  81562. * @param scene defines the hosting scene
  81563. * @param updatable defines if the mesh must be flagged as updatable
  81564. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81565. * @returns a new Mesh
  81566. */
  81567. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81568. /**
  81569. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  81570. * @param name defines the name of the mesh to create
  81571. * @param points is an array successive Vector3
  81572. * @param scene defines the hosting scene
  81573. * @param updatable defines if the mesh must be flagged as updatable
  81574. * @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).
  81575. * @returns a new Mesh
  81576. */
  81577. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  81578. /**
  81579. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  81580. * @param name defines the name of the mesh to create
  81581. * @param points is an array successive Vector3
  81582. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  81583. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  81584. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  81585. * @param scene defines the hosting scene
  81586. * @param updatable defines if the mesh must be flagged as updatable
  81587. * @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)
  81588. * @returns a new Mesh
  81589. */
  81590. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  81591. /**
  81592. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  81593. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  81594. * 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.
  81595. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81596. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81597. * Remember you can only change the shape positions, not their number when updating a polygon.
  81598. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  81599. * @param name defines the name of the mesh to create
  81600. * @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
  81601. * @param scene defines the hosting scene
  81602. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81603. * @param updatable defines if the mesh must be flagged as updatable
  81604. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81605. * @param earcutInjection can be used to inject your own earcut reference
  81606. * @returns a new Mesh
  81607. */
  81608. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81609. /**
  81610. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  81611. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  81612. * @param name defines the name of the mesh to create
  81613. * @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
  81614. * @param depth defines the height of extrusion
  81615. * @param scene defines the hosting scene
  81616. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81617. * @param updatable defines if the mesh must be flagged as updatable
  81618. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81619. * @param earcutInjection can be used to inject your own earcut reference
  81620. * @returns a new Mesh
  81621. */
  81622. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81623. /**
  81624. * Creates an extruded shape mesh.
  81625. * 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
  81626. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81627. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81628. * @param name defines the name of the mesh to create
  81629. * @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
  81630. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81631. * @param scale is the value to scale the shape
  81632. * @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
  81633. * @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
  81634. * @param scene defines the hosting scene
  81635. * @param updatable defines if the mesh must be flagged as updatable
  81636. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81637. * @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)
  81638. * @returns a new Mesh
  81639. */
  81640. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81641. /**
  81642. * Creates an custom extruded shape mesh.
  81643. * The custom extrusion is a parametric shape.
  81644. * It has no predefined shape. Its final shape will depend on the input parameters.
  81645. * Please consider using the same method from the MeshBuilder class instead
  81646. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81647. * @param name defines the name of the mesh to create
  81648. * @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
  81649. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81650. * @param scaleFunction is a custom Javascript function called on each path point
  81651. * @param rotationFunction is a custom Javascript function called on each path point
  81652. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  81653. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  81654. * @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
  81655. * @param scene defines the hosting scene
  81656. * @param updatable defines if the mesh must be flagged as updatable
  81657. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81658. * @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)
  81659. * @returns a new Mesh
  81660. */
  81661. 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;
  81662. /**
  81663. * Creates lathe mesh.
  81664. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  81665. * Please consider using the same method from the MeshBuilder class instead
  81666. * @param name defines the name of the mesh to create
  81667. * @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
  81668. * @param radius is the radius value of the lathe
  81669. * @param tessellation is the side number of the lathe.
  81670. * @param scene defines the hosting scene
  81671. * @param updatable defines if the mesh must be flagged as updatable
  81672. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81673. * @returns a new Mesh
  81674. */
  81675. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81676. /**
  81677. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  81678. * @param name defines the name of the mesh to create
  81679. * @param size sets the size (float) of both sides of the plane at once (default 1)
  81680. * @param scene defines the hosting scene
  81681. * @param updatable defines if the mesh must be flagged as updatable
  81682. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81683. * @returns a new Mesh
  81684. */
  81685. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81686. /**
  81687. * Creates a ground mesh.
  81688. * Please consider using the same method from the MeshBuilder class instead
  81689. * @param name defines the name of the mesh to create
  81690. * @param width set the width of the ground
  81691. * @param height set the height of the ground
  81692. * @param subdivisions sets the number of subdivisions per side
  81693. * @param scene defines the hosting scene
  81694. * @param updatable defines if the mesh must be flagged as updatable
  81695. * @returns a new Mesh
  81696. */
  81697. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  81698. /**
  81699. * Creates a tiled ground mesh.
  81700. * Please consider using the same method from the MeshBuilder class instead
  81701. * @param name defines the name of the mesh to create
  81702. * @param xmin set the ground minimum X coordinate
  81703. * @param zmin set the ground minimum Y coordinate
  81704. * @param xmax set the ground maximum X coordinate
  81705. * @param zmax set the ground maximum Z coordinate
  81706. * @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
  81707. * @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
  81708. * @param scene defines the hosting scene
  81709. * @param updatable defines if the mesh must be flagged as updatable
  81710. * @returns a new Mesh
  81711. */
  81712. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  81713. w: number;
  81714. h: number;
  81715. }, precision: {
  81716. w: number;
  81717. h: number;
  81718. }, scene: Scene, updatable?: boolean): Mesh;
  81719. /**
  81720. * Creates a ground mesh from a height map.
  81721. * Please consider using the same method from the MeshBuilder class instead
  81722. * @see http://doc.babylonjs.com/babylon101/height_map
  81723. * @param name defines the name of the mesh to create
  81724. * @param url sets the URL of the height map image resource
  81725. * @param width set the ground width size
  81726. * @param height set the ground height size
  81727. * @param subdivisions sets the number of subdivision per side
  81728. * @param minHeight is the minimum altitude on the ground
  81729. * @param maxHeight is the maximum altitude on the ground
  81730. * @param scene defines the hosting scene
  81731. * @param updatable defines if the mesh must be flagged as updatable
  81732. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  81733. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  81734. * @returns a new Mesh
  81735. */
  81736. 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;
  81737. /**
  81738. * Creates a tube mesh.
  81739. * The tube is a parametric shape.
  81740. * It has no predefined shape. Its final shape will depend on the input parameters.
  81741. * Please consider using the same method from the MeshBuilder class instead
  81742. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81743. * @param name defines the name of the mesh to create
  81744. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  81745. * @param radius sets the tube radius size
  81746. * @param tessellation is the number of sides on the tubular surface
  81747. * @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
  81748. * @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
  81749. * @param scene defines the hosting scene
  81750. * @param updatable defines if the mesh must be flagged as updatable
  81751. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81752. * @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)
  81753. * @returns a new Mesh
  81754. */
  81755. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  81756. (i: number, distance: number): number;
  81757. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81758. /**
  81759. * Creates a polyhedron mesh.
  81760. * Please consider using the same method from the MeshBuilder class instead.
  81761. * * 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
  81762. * * The parameter `size` (positive float, default 1) sets the polygon size
  81763. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  81764. * * 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`
  81765. * * 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
  81766. * * 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)`)
  81767. * * 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
  81768. * * 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
  81769. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81770. * * If you create a double-sided mesh, you can choose what parts of 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
  81771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81772. * @param name defines the name of the mesh to create
  81773. * @param options defines the options used to create the mesh
  81774. * @param scene defines the hosting scene
  81775. * @returns a new Mesh
  81776. */
  81777. static CreatePolyhedron(name: string, options: {
  81778. type?: number;
  81779. size?: number;
  81780. sizeX?: number;
  81781. sizeY?: number;
  81782. sizeZ?: number;
  81783. custom?: any;
  81784. faceUV?: Vector4[];
  81785. faceColors?: Color4[];
  81786. updatable?: boolean;
  81787. sideOrientation?: number;
  81788. }, scene: Scene): Mesh;
  81789. /**
  81790. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  81791. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  81792. * * 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`)
  81793. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  81794. * * 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
  81795. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81796. * * If you create a double-sided mesh, you can choose what parts of 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
  81797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81798. * @param name defines the name of the mesh
  81799. * @param options defines the options used to create the mesh
  81800. * @param scene defines the hosting scene
  81801. * @returns a new Mesh
  81802. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  81803. */
  81804. static CreateIcoSphere(name: string, options: {
  81805. radius?: number;
  81806. flat?: boolean;
  81807. subdivisions?: number;
  81808. sideOrientation?: number;
  81809. updatable?: boolean;
  81810. }, scene: Scene): Mesh;
  81811. /**
  81812. * Creates a decal mesh.
  81813. * Please consider using the same method from the MeshBuilder class instead.
  81814. * A decal is a mesh usually applied as a model onto the surface of another mesh
  81815. * @param name defines the name of the mesh
  81816. * @param sourceMesh defines the mesh receiving the decal
  81817. * @param position sets the position of the decal in world coordinates
  81818. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  81819. * @param size sets the decal scaling
  81820. * @param angle sets the angle to rotate the decal
  81821. * @returns a new Mesh
  81822. */
  81823. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  81824. /**
  81825. * Prepare internal position array for software CPU skinning
  81826. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  81827. */
  81828. setPositionsForCPUSkinning(): Float32Array;
  81829. /**
  81830. * Prepare internal normal array for software CPU skinning
  81831. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  81832. */
  81833. setNormalsForCPUSkinning(): Float32Array;
  81834. /**
  81835. * Updates the vertex buffer by applying transformation from the bones
  81836. * @param skeleton defines the skeleton to apply to current mesh
  81837. * @returns the current mesh
  81838. */
  81839. applySkeleton(skeleton: Skeleton): Mesh;
  81840. /**
  81841. * 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
  81842. * @param meshes defines the list of meshes to scan
  81843. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  81844. */
  81845. static MinMax(meshes: AbstractMesh[]): {
  81846. min: Vector3;
  81847. max: Vector3;
  81848. };
  81849. /**
  81850. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  81851. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  81852. * @returns a vector3
  81853. */
  81854. static Center(meshesOrMinMaxVector: {
  81855. min: Vector3;
  81856. max: Vector3;
  81857. } | AbstractMesh[]): Vector3;
  81858. /**
  81859. * Merge the array of meshes into a single mesh for performance reasons.
  81860. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  81861. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  81862. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  81863. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  81864. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  81865. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  81866. * @returns a new mesh
  81867. */
  81868. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  81869. /** @hidden */
  81870. addInstance(instance: InstancedMesh): void;
  81871. /** @hidden */
  81872. removeInstance(instance: InstancedMesh): void;
  81873. }
  81874. }
  81875. declare module BABYLON {
  81876. /**
  81877. * Base class for the main features of a material in Babylon.js
  81878. */
  81879. export class Material implements IAnimatable {
  81880. /**
  81881. * Returns the triangle fill mode
  81882. */
  81883. static readonly TriangleFillMode: number;
  81884. /**
  81885. * Returns the wireframe mode
  81886. */
  81887. static readonly WireFrameFillMode: number;
  81888. /**
  81889. * Returns the point fill mode
  81890. */
  81891. static readonly PointFillMode: number;
  81892. /**
  81893. * Returns the point list draw mode
  81894. */
  81895. static readonly PointListDrawMode: number;
  81896. /**
  81897. * Returns the line list draw mode
  81898. */
  81899. static readonly LineListDrawMode: number;
  81900. /**
  81901. * Returns the line loop draw mode
  81902. */
  81903. static readonly LineLoopDrawMode: number;
  81904. /**
  81905. * Returns the line strip draw mode
  81906. */
  81907. static readonly LineStripDrawMode: number;
  81908. /**
  81909. * Returns the triangle strip draw mode
  81910. */
  81911. static readonly TriangleStripDrawMode: number;
  81912. /**
  81913. * Returns the triangle fan draw mode
  81914. */
  81915. static readonly TriangleFanDrawMode: number;
  81916. /**
  81917. * Stores the clock-wise side orientation
  81918. */
  81919. static readonly ClockWiseSideOrientation: number;
  81920. /**
  81921. * Stores the counter clock-wise side orientation
  81922. */
  81923. static readonly CounterClockWiseSideOrientation: number;
  81924. /**
  81925. * The dirty texture flag value
  81926. */
  81927. static readonly TextureDirtyFlag: number;
  81928. /**
  81929. * The dirty light flag value
  81930. */
  81931. static readonly LightDirtyFlag: number;
  81932. /**
  81933. * The dirty fresnel flag value
  81934. */
  81935. static readonly FresnelDirtyFlag: number;
  81936. /**
  81937. * The dirty attribute flag value
  81938. */
  81939. static readonly AttributesDirtyFlag: number;
  81940. /**
  81941. * The dirty misc flag value
  81942. */
  81943. static readonly MiscDirtyFlag: number;
  81944. /**
  81945. * The all dirty flag value
  81946. */
  81947. static readonly AllDirtyFlag: number;
  81948. /**
  81949. * The ID of the material
  81950. */
  81951. id: string;
  81952. /**
  81953. * Gets or sets the unique id of the material
  81954. */
  81955. uniqueId: number;
  81956. /**
  81957. * The name of the material
  81958. */
  81959. name: string;
  81960. /**
  81961. * Gets or sets user defined metadata
  81962. */
  81963. metadata: any;
  81964. /**
  81965. * For internal use only. Please do not use.
  81966. */
  81967. reservedDataStore: any;
  81968. /**
  81969. * Specifies if the ready state should be checked on each call
  81970. */
  81971. checkReadyOnEveryCall: boolean;
  81972. /**
  81973. * Specifies if the ready state should be checked once
  81974. */
  81975. checkReadyOnlyOnce: boolean;
  81976. /**
  81977. * The state of the material
  81978. */
  81979. state: string;
  81980. /**
  81981. * The alpha value of the material
  81982. */
  81983. protected _alpha: number;
  81984. /**
  81985. * List of inspectable custom properties (used by the Inspector)
  81986. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81987. */
  81988. inspectableCustomProperties: IInspectable[];
  81989. /**
  81990. * Sets the alpha value of the material
  81991. */
  81992. /**
  81993. * Gets the alpha value of the material
  81994. */
  81995. alpha: number;
  81996. /**
  81997. * Specifies if back face culling is enabled
  81998. */
  81999. protected _backFaceCulling: boolean;
  82000. /**
  82001. * Sets the back-face culling state
  82002. */
  82003. /**
  82004. * Gets the back-face culling state
  82005. */
  82006. backFaceCulling: boolean;
  82007. /**
  82008. * Stores the value for side orientation
  82009. */
  82010. sideOrientation: number;
  82011. /**
  82012. * Callback triggered when the material is compiled
  82013. */
  82014. onCompiled: Nullable<(effect: Effect) => void>;
  82015. /**
  82016. * Callback triggered when an error occurs
  82017. */
  82018. onError: Nullable<(effect: Effect, errors: string) => void>;
  82019. /**
  82020. * Callback triggered to get the render target textures
  82021. */
  82022. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  82023. /**
  82024. * Gets a boolean indicating that current material needs to register RTT
  82025. */
  82026. readonly hasRenderTargetTextures: boolean;
  82027. /**
  82028. * Specifies if the material should be serialized
  82029. */
  82030. doNotSerialize: boolean;
  82031. /**
  82032. * @hidden
  82033. */
  82034. _storeEffectOnSubMeshes: boolean;
  82035. /**
  82036. * Stores the animations for the material
  82037. */
  82038. animations: Nullable<Array<Animation>>;
  82039. /**
  82040. * An event triggered when the material is disposed
  82041. */
  82042. onDisposeObservable: Observable<Material>;
  82043. /**
  82044. * An observer which watches for dispose events
  82045. */
  82046. private _onDisposeObserver;
  82047. private _onUnBindObservable;
  82048. /**
  82049. * Called during a dispose event
  82050. */
  82051. onDispose: () => void;
  82052. private _onBindObservable;
  82053. /**
  82054. * An event triggered when the material is bound
  82055. */
  82056. readonly onBindObservable: Observable<AbstractMesh>;
  82057. /**
  82058. * An observer which watches for bind events
  82059. */
  82060. private _onBindObserver;
  82061. /**
  82062. * Called during a bind event
  82063. */
  82064. onBind: (Mesh: AbstractMesh) => void;
  82065. /**
  82066. * An event triggered when the material is unbound
  82067. */
  82068. readonly onUnBindObservable: Observable<Material>;
  82069. /**
  82070. * Stores the value of the alpha mode
  82071. */
  82072. private _alphaMode;
  82073. /**
  82074. * Sets the value of the alpha mode.
  82075. *
  82076. * | Value | Type | Description |
  82077. * | --- | --- | --- |
  82078. * | 0 | ALPHA_DISABLE | |
  82079. * | 1 | ALPHA_ADD | |
  82080. * | 2 | ALPHA_COMBINE | |
  82081. * | 3 | ALPHA_SUBTRACT | |
  82082. * | 4 | ALPHA_MULTIPLY | |
  82083. * | 5 | ALPHA_MAXIMIZED | |
  82084. * | 6 | ALPHA_ONEONE | |
  82085. * | 7 | ALPHA_PREMULTIPLIED | |
  82086. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  82087. * | 9 | ALPHA_INTERPOLATE | |
  82088. * | 10 | ALPHA_SCREENMODE | |
  82089. *
  82090. */
  82091. /**
  82092. * Gets the value of the alpha mode
  82093. */
  82094. alphaMode: number;
  82095. /**
  82096. * Stores the state of the need depth pre-pass value
  82097. */
  82098. private _needDepthPrePass;
  82099. /**
  82100. * Sets the need depth pre-pass value
  82101. */
  82102. /**
  82103. * Gets the depth pre-pass value
  82104. */
  82105. needDepthPrePass: boolean;
  82106. /**
  82107. * Specifies if depth writing should be disabled
  82108. */
  82109. disableDepthWrite: boolean;
  82110. /**
  82111. * Specifies if depth writing should be forced
  82112. */
  82113. forceDepthWrite: boolean;
  82114. /**
  82115. * Specifies if there should be a separate pass for culling
  82116. */
  82117. separateCullingPass: boolean;
  82118. /**
  82119. * Stores the state specifing if fog should be enabled
  82120. */
  82121. private _fogEnabled;
  82122. /**
  82123. * Sets the state for enabling fog
  82124. */
  82125. /**
  82126. * Gets the value of the fog enabled state
  82127. */
  82128. fogEnabled: boolean;
  82129. /**
  82130. * Stores the size of points
  82131. */
  82132. pointSize: number;
  82133. /**
  82134. * Stores the z offset value
  82135. */
  82136. zOffset: number;
  82137. /**
  82138. * Gets a value specifying if wireframe mode is enabled
  82139. */
  82140. /**
  82141. * Sets the state of wireframe mode
  82142. */
  82143. wireframe: boolean;
  82144. /**
  82145. * Gets the value specifying if point clouds are enabled
  82146. */
  82147. /**
  82148. * Sets the state of point cloud mode
  82149. */
  82150. pointsCloud: boolean;
  82151. /**
  82152. * Gets the material fill mode
  82153. */
  82154. /**
  82155. * Sets the material fill mode
  82156. */
  82157. fillMode: number;
  82158. /**
  82159. * @hidden
  82160. * Stores the effects for the material
  82161. */
  82162. _effect: Nullable<Effect>;
  82163. /**
  82164. * @hidden
  82165. * Specifies if the material was previously ready
  82166. */
  82167. _wasPreviouslyReady: boolean;
  82168. /**
  82169. * Specifies if uniform buffers should be used
  82170. */
  82171. private _useUBO;
  82172. /**
  82173. * Stores a reference to the scene
  82174. */
  82175. private _scene;
  82176. /**
  82177. * Stores the fill mode state
  82178. */
  82179. private _fillMode;
  82180. /**
  82181. * Specifies if the depth write state should be cached
  82182. */
  82183. private _cachedDepthWriteState;
  82184. /**
  82185. * Stores the uniform buffer
  82186. */
  82187. protected _uniformBuffer: UniformBuffer;
  82188. /** @hidden */
  82189. _indexInSceneMaterialArray: number;
  82190. /** @hidden */
  82191. meshMap: Nullable<{
  82192. [id: string]: AbstractMesh | undefined;
  82193. }>;
  82194. /**
  82195. * Creates a material instance
  82196. * @param name defines the name of the material
  82197. * @param scene defines the scene to reference
  82198. * @param doNotAdd specifies if the material should be added to the scene
  82199. */
  82200. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  82201. /**
  82202. * Returns a string representation of the current material
  82203. * @param fullDetails defines a boolean indicating which levels of logging is desired
  82204. * @returns a string with material information
  82205. */
  82206. toString(fullDetails?: boolean): string;
  82207. /**
  82208. * Gets the class name of the material
  82209. * @returns a string with the class name of the material
  82210. */
  82211. getClassName(): string;
  82212. /**
  82213. * Specifies if updates for the material been locked
  82214. */
  82215. readonly isFrozen: boolean;
  82216. /**
  82217. * Locks updates for the material
  82218. */
  82219. freeze(): void;
  82220. /**
  82221. * Unlocks updates for the material
  82222. */
  82223. unfreeze(): void;
  82224. /**
  82225. * Specifies if the material is ready to be used
  82226. * @param mesh defines the mesh to check
  82227. * @param useInstances specifies if instances should be used
  82228. * @returns a boolean indicating if the material is ready to be used
  82229. */
  82230. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82231. /**
  82232. * Specifies that the submesh is ready to be used
  82233. * @param mesh defines the mesh to check
  82234. * @param subMesh defines which submesh to check
  82235. * @param useInstances specifies that instances should be used
  82236. * @returns a boolean indicating that the submesh is ready or not
  82237. */
  82238. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82239. /**
  82240. * Returns the material effect
  82241. * @returns the effect associated with the material
  82242. */
  82243. getEffect(): Nullable<Effect>;
  82244. /**
  82245. * Returns the current scene
  82246. * @returns a Scene
  82247. */
  82248. getScene(): Scene;
  82249. /**
  82250. * Specifies if the material will require alpha blending
  82251. * @returns a boolean specifying if alpha blending is needed
  82252. */
  82253. needAlphaBlending(): boolean;
  82254. /**
  82255. * Specifies if the mesh will require alpha blending
  82256. * @param mesh defines the mesh to check
  82257. * @returns a boolean specifying if alpha blending is needed for the mesh
  82258. */
  82259. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  82260. /**
  82261. * Specifies if this material should be rendered in alpha test mode
  82262. * @returns a boolean specifying if an alpha test is needed.
  82263. */
  82264. needAlphaTesting(): boolean;
  82265. /**
  82266. * Gets the texture used for the alpha test
  82267. * @returns the texture to use for alpha testing
  82268. */
  82269. getAlphaTestTexture(): Nullable<BaseTexture>;
  82270. /**
  82271. * Marks the material to indicate that it needs to be re-calculated
  82272. */
  82273. markDirty(): void;
  82274. /** @hidden */
  82275. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  82276. /**
  82277. * Binds the material to the mesh
  82278. * @param world defines the world transformation matrix
  82279. * @param mesh defines the mesh to bind the material to
  82280. */
  82281. bind(world: Matrix, mesh?: Mesh): void;
  82282. /**
  82283. * Binds the submesh to the material
  82284. * @param world defines the world transformation matrix
  82285. * @param mesh defines the mesh containing the submesh
  82286. * @param subMesh defines the submesh to bind the material to
  82287. */
  82288. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  82289. /**
  82290. * Binds the world matrix to the material
  82291. * @param world defines the world transformation matrix
  82292. */
  82293. bindOnlyWorldMatrix(world: Matrix): void;
  82294. /**
  82295. * Binds the scene's uniform buffer to the effect.
  82296. * @param effect defines the effect to bind to the scene uniform buffer
  82297. * @param sceneUbo defines the uniform buffer storing scene data
  82298. */
  82299. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  82300. /**
  82301. * Binds the view matrix to the effect
  82302. * @param effect defines the effect to bind the view matrix to
  82303. */
  82304. bindView(effect: Effect): void;
  82305. /**
  82306. * Binds the view projection matrix to the effect
  82307. * @param effect defines the effect to bind the view projection matrix to
  82308. */
  82309. bindViewProjection(effect: Effect): void;
  82310. /**
  82311. * Specifies if material alpha testing should be turned on for the mesh
  82312. * @param mesh defines the mesh to check
  82313. */
  82314. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  82315. /**
  82316. * Processes to execute after binding the material to a mesh
  82317. * @param mesh defines the rendered mesh
  82318. */
  82319. protected _afterBind(mesh?: Mesh): void;
  82320. /**
  82321. * Unbinds the material from the mesh
  82322. */
  82323. unbind(): void;
  82324. /**
  82325. * Gets the active textures from the material
  82326. * @returns an array of textures
  82327. */
  82328. getActiveTextures(): BaseTexture[];
  82329. /**
  82330. * Specifies if the material uses a texture
  82331. * @param texture defines the texture to check against the material
  82332. * @returns a boolean specifying if the material uses the texture
  82333. */
  82334. hasTexture(texture: BaseTexture): boolean;
  82335. /**
  82336. * Makes a duplicate of the material, and gives it a new name
  82337. * @param name defines the new name for the duplicated material
  82338. * @returns the cloned material
  82339. */
  82340. clone(name: string): Nullable<Material>;
  82341. /**
  82342. * Gets the meshes bound to the material
  82343. * @returns an array of meshes bound to the material
  82344. */
  82345. getBindedMeshes(): AbstractMesh[];
  82346. /**
  82347. * Force shader compilation
  82348. * @param mesh defines the mesh associated with this material
  82349. * @param onCompiled defines a function to execute once the material is compiled
  82350. * @param options defines the options to configure the compilation
  82351. */
  82352. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  82353. clipPlane: boolean;
  82354. }>): void;
  82355. /**
  82356. * Force shader compilation
  82357. * @param mesh defines the mesh that will use this material
  82358. * @param options defines additional options for compiling the shaders
  82359. * @returns a promise that resolves when the compilation completes
  82360. */
  82361. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  82362. clipPlane: boolean;
  82363. }>): Promise<void>;
  82364. private static readonly _ImageProcessingDirtyCallBack;
  82365. private static readonly _TextureDirtyCallBack;
  82366. private static readonly _FresnelDirtyCallBack;
  82367. private static readonly _MiscDirtyCallBack;
  82368. private static readonly _LightsDirtyCallBack;
  82369. private static readonly _AttributeDirtyCallBack;
  82370. private static _FresnelAndMiscDirtyCallBack;
  82371. private static _TextureAndMiscDirtyCallBack;
  82372. private static readonly _DirtyCallbackArray;
  82373. private static readonly _RunDirtyCallBacks;
  82374. /**
  82375. * Marks a define in the material to indicate that it needs to be re-computed
  82376. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  82377. */
  82378. markAsDirty(flag: number): void;
  82379. /**
  82380. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  82381. * @param func defines a function which checks material defines against the submeshes
  82382. */
  82383. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  82384. /**
  82385. * Indicates that image processing needs to be re-calculated for all submeshes
  82386. */
  82387. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  82388. /**
  82389. * Indicates that textures need to be re-calculated for all submeshes
  82390. */
  82391. protected _markAllSubMeshesAsTexturesDirty(): void;
  82392. /**
  82393. * Indicates that fresnel needs to be re-calculated for all submeshes
  82394. */
  82395. protected _markAllSubMeshesAsFresnelDirty(): void;
  82396. /**
  82397. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  82398. */
  82399. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  82400. /**
  82401. * Indicates that lights need to be re-calculated for all submeshes
  82402. */
  82403. protected _markAllSubMeshesAsLightsDirty(): void;
  82404. /**
  82405. * Indicates that attributes need to be re-calculated for all submeshes
  82406. */
  82407. protected _markAllSubMeshesAsAttributesDirty(): void;
  82408. /**
  82409. * Indicates that misc needs to be re-calculated for all submeshes
  82410. */
  82411. protected _markAllSubMeshesAsMiscDirty(): void;
  82412. /**
  82413. * Indicates that textures and misc need to be re-calculated for all submeshes
  82414. */
  82415. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  82416. /**
  82417. * Disposes the material
  82418. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82419. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82420. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82421. */
  82422. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82423. /** @hidden */
  82424. private releaseVertexArrayObject;
  82425. /**
  82426. * Serializes this material
  82427. * @returns the serialized material object
  82428. */
  82429. serialize(): any;
  82430. /**
  82431. * Creates a material from parsed material data
  82432. * @param parsedMaterial defines parsed material data
  82433. * @param scene defines the hosting scene
  82434. * @param rootUrl defines the root URL to use to load textures
  82435. * @returns a new material
  82436. */
  82437. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  82438. }
  82439. }
  82440. declare module BABYLON {
  82441. /**
  82442. * Base class for submeshes
  82443. */
  82444. export class BaseSubMesh {
  82445. /** @hidden */
  82446. _materialDefines: Nullable<MaterialDefines>;
  82447. /** @hidden */
  82448. _materialEffect: Nullable<Effect>;
  82449. /**
  82450. * Gets associated effect
  82451. */
  82452. readonly effect: Nullable<Effect>;
  82453. /**
  82454. * Sets associated effect (effect used to render this submesh)
  82455. * @param effect defines the effect to associate with
  82456. * @param defines defines the set of defines used to compile this effect
  82457. */
  82458. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  82459. }
  82460. /**
  82461. * Defines a subdivision inside a mesh
  82462. */
  82463. export class SubMesh extends BaseSubMesh implements ICullable {
  82464. /** the material index to use */
  82465. materialIndex: number;
  82466. /** vertex index start */
  82467. verticesStart: number;
  82468. /** vertices count */
  82469. verticesCount: number;
  82470. /** index start */
  82471. indexStart: number;
  82472. /** indices count */
  82473. indexCount: number;
  82474. /** @hidden */
  82475. _linesIndexCount: number;
  82476. private _mesh;
  82477. private _renderingMesh;
  82478. private _boundingInfo;
  82479. private _linesIndexBuffer;
  82480. /** @hidden */
  82481. _lastColliderWorldVertices: Nullable<Vector3[]>;
  82482. /** @hidden */
  82483. _trianglePlanes: Plane[];
  82484. /** @hidden */
  82485. _lastColliderTransformMatrix: Nullable<Matrix>;
  82486. /** @hidden */
  82487. _renderId: number;
  82488. /** @hidden */
  82489. _alphaIndex: number;
  82490. /** @hidden */
  82491. _distanceToCamera: number;
  82492. /** @hidden */
  82493. _id: number;
  82494. private _currentMaterial;
  82495. /**
  82496. * Add a new submesh to a mesh
  82497. * @param materialIndex defines the material index to use
  82498. * @param verticesStart defines vertex index start
  82499. * @param verticesCount defines vertices count
  82500. * @param indexStart defines index start
  82501. * @param indexCount defines indices count
  82502. * @param mesh defines the parent mesh
  82503. * @param renderingMesh defines an optional rendering mesh
  82504. * @param createBoundingBox defines if bounding box should be created for this submesh
  82505. * @returns the new submesh
  82506. */
  82507. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  82508. /**
  82509. * Creates a new submesh
  82510. * @param materialIndex defines the material index to use
  82511. * @param verticesStart defines vertex index start
  82512. * @param verticesCount defines vertices count
  82513. * @param indexStart defines index start
  82514. * @param indexCount defines indices count
  82515. * @param mesh defines the parent mesh
  82516. * @param renderingMesh defines an optional rendering mesh
  82517. * @param createBoundingBox defines if bounding box should be created for this submesh
  82518. */
  82519. constructor(
  82520. /** the material index to use */
  82521. materialIndex: number,
  82522. /** vertex index start */
  82523. verticesStart: number,
  82524. /** vertices count */
  82525. verticesCount: number,
  82526. /** index start */
  82527. indexStart: number,
  82528. /** indices count */
  82529. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  82530. /**
  82531. * Returns true if this submesh covers the entire parent mesh
  82532. * @ignorenaming
  82533. */
  82534. readonly IsGlobal: boolean;
  82535. /**
  82536. * Returns the submesh BoudingInfo object
  82537. * @returns current bounding info (or mesh's one if the submesh is global)
  82538. */
  82539. getBoundingInfo(): BoundingInfo;
  82540. /**
  82541. * Sets the submesh BoundingInfo
  82542. * @param boundingInfo defines the new bounding info to use
  82543. * @returns the SubMesh
  82544. */
  82545. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  82546. /**
  82547. * Returns the mesh of the current submesh
  82548. * @return the parent mesh
  82549. */
  82550. getMesh(): AbstractMesh;
  82551. /**
  82552. * Returns the rendering mesh of the submesh
  82553. * @returns the rendering mesh (could be different from parent mesh)
  82554. */
  82555. getRenderingMesh(): Mesh;
  82556. /**
  82557. * Returns the submesh material
  82558. * @returns null or the current material
  82559. */
  82560. getMaterial(): Nullable<Material>;
  82561. /**
  82562. * Sets a new updated BoundingInfo object to the submesh
  82563. * @param data defines an optional position array to use to determine the bounding info
  82564. * @returns the SubMesh
  82565. */
  82566. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  82567. /** @hidden */
  82568. _checkCollision(collider: Collider): boolean;
  82569. /**
  82570. * Updates the submesh BoundingInfo
  82571. * @param world defines the world matrix to use to update the bounding info
  82572. * @returns the submesh
  82573. */
  82574. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  82575. /**
  82576. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  82577. * @param frustumPlanes defines the frustum planes
  82578. * @returns true if the submesh is intersecting with the frustum
  82579. */
  82580. isInFrustum(frustumPlanes: Plane[]): boolean;
  82581. /**
  82582. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  82583. * @param frustumPlanes defines the frustum planes
  82584. * @returns true if the submesh is inside the frustum
  82585. */
  82586. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82587. /**
  82588. * Renders the submesh
  82589. * @param enableAlphaMode defines if alpha needs to be used
  82590. * @returns the submesh
  82591. */
  82592. render(enableAlphaMode: boolean): SubMesh;
  82593. /**
  82594. * @hidden
  82595. */
  82596. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  82597. /**
  82598. * Checks if the submesh intersects with a ray
  82599. * @param ray defines the ray to test
  82600. * @returns true is the passed ray intersects the submesh bounding box
  82601. */
  82602. canIntersects(ray: Ray): boolean;
  82603. /**
  82604. * Intersects current submesh with a ray
  82605. * @param ray defines the ray to test
  82606. * @param positions defines mesh's positions array
  82607. * @param indices defines mesh's indices array
  82608. * @param fastCheck defines if only bounding info should be used
  82609. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82610. * @returns intersection info or null if no intersection
  82611. */
  82612. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  82613. /** @hidden */
  82614. private _intersectLines;
  82615. /** @hidden */
  82616. private _intersectTriangles;
  82617. /** @hidden */
  82618. private _intersectUnIndexedTriangles;
  82619. /** @hidden */
  82620. _rebuild(): void;
  82621. /**
  82622. * Creates a new submesh from the passed mesh
  82623. * @param newMesh defines the new hosting mesh
  82624. * @param newRenderingMesh defines an optional rendering mesh
  82625. * @returns the new submesh
  82626. */
  82627. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  82628. /**
  82629. * Release associated resources
  82630. */
  82631. dispose(): void;
  82632. /**
  82633. * Gets the class name
  82634. * @returns the string "SubMesh".
  82635. */
  82636. getClassName(): string;
  82637. /**
  82638. * Creates a new submesh from indices data
  82639. * @param materialIndex the index of the main mesh material
  82640. * @param startIndex the index where to start the copy in the mesh indices array
  82641. * @param indexCount the number of indices to copy then from the startIndex
  82642. * @param mesh the main mesh to create the submesh from
  82643. * @param renderingMesh the optional rendering mesh
  82644. * @returns a new submesh
  82645. */
  82646. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  82647. }
  82648. }
  82649. declare module BABYLON {
  82650. /**
  82651. * Class used to store geometry data (vertex buffers + index buffer)
  82652. */
  82653. export class Geometry implements IGetSetVerticesData {
  82654. /**
  82655. * Gets or sets the ID of the geometry
  82656. */
  82657. id: string;
  82658. /**
  82659. * Gets or sets the unique ID of the geometry
  82660. */
  82661. uniqueId: number;
  82662. /**
  82663. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82664. */
  82665. delayLoadState: number;
  82666. /**
  82667. * Gets the file containing the data to load when running in delay load state
  82668. */
  82669. delayLoadingFile: Nullable<string>;
  82670. /**
  82671. * Callback called when the geometry is updated
  82672. */
  82673. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  82674. private _scene;
  82675. private _engine;
  82676. private _meshes;
  82677. private _totalVertices;
  82678. /** @hidden */
  82679. _indices: IndicesArray;
  82680. /** @hidden */
  82681. _vertexBuffers: {
  82682. [key: string]: VertexBuffer;
  82683. };
  82684. private _isDisposed;
  82685. private _extend;
  82686. private _boundingBias;
  82687. /** @hidden */
  82688. _delayInfo: Array<string>;
  82689. private _indexBuffer;
  82690. private _indexBufferIsUpdatable;
  82691. /** @hidden */
  82692. _boundingInfo: Nullable<BoundingInfo>;
  82693. /** @hidden */
  82694. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  82695. /** @hidden */
  82696. _softwareSkinningFrameId: number;
  82697. private _vertexArrayObjects;
  82698. private _updatable;
  82699. /** @hidden */
  82700. _positions: Nullable<Vector3[]>;
  82701. /**
  82702. * 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
  82703. */
  82704. /**
  82705. * 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
  82706. */
  82707. boundingBias: Vector2;
  82708. /**
  82709. * Static function used to attach a new empty geometry to a mesh
  82710. * @param mesh defines the mesh to attach the geometry to
  82711. * @returns the new Geometry
  82712. */
  82713. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  82714. /**
  82715. * Creates a new geometry
  82716. * @param id defines the unique ID
  82717. * @param scene defines the hosting scene
  82718. * @param vertexData defines the VertexData used to get geometry data
  82719. * @param updatable defines if geometry must be updatable (false by default)
  82720. * @param mesh defines the mesh that will be associated with the geometry
  82721. */
  82722. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  82723. /**
  82724. * Gets the current extend of the geometry
  82725. */
  82726. readonly extend: {
  82727. minimum: Vector3;
  82728. maximum: Vector3;
  82729. };
  82730. /**
  82731. * Gets the hosting scene
  82732. * @returns the hosting Scene
  82733. */
  82734. getScene(): Scene;
  82735. /**
  82736. * Gets the hosting engine
  82737. * @returns the hosting Engine
  82738. */
  82739. getEngine(): Engine;
  82740. /**
  82741. * Defines if the geometry is ready to use
  82742. * @returns true if the geometry is ready to be used
  82743. */
  82744. isReady(): boolean;
  82745. /**
  82746. * Gets a value indicating that the geometry should not be serialized
  82747. */
  82748. readonly doNotSerialize: boolean;
  82749. /** @hidden */
  82750. _rebuild(): void;
  82751. /**
  82752. * Affects all geometry data in one call
  82753. * @param vertexData defines the geometry data
  82754. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  82755. */
  82756. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  82757. /**
  82758. * Set specific vertex data
  82759. * @param kind defines the data kind (Position, normal, etc...)
  82760. * @param data defines the vertex data to use
  82761. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82762. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82763. */
  82764. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  82765. /**
  82766. * Removes a specific vertex data
  82767. * @param kind defines the data kind (Position, normal, etc...)
  82768. */
  82769. removeVerticesData(kind: string): void;
  82770. /**
  82771. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  82772. * @param buffer defines the vertex buffer to use
  82773. * @param totalVertices defines the total number of vertices for position kind (could be null)
  82774. */
  82775. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  82776. /**
  82777. * Update a specific vertex buffer
  82778. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  82779. * It will do nothing if the buffer is not updatable
  82780. * @param kind defines the data kind (Position, normal, etc...)
  82781. * @param data defines the data to use
  82782. * @param offset defines the offset in the target buffer where to store the data
  82783. * @param useBytes set to true if the offset is in bytes
  82784. */
  82785. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  82786. /**
  82787. * Update a specific vertex buffer
  82788. * This function will create a new buffer if the current one is not updatable
  82789. * @param kind defines the data kind (Position, normal, etc...)
  82790. * @param data defines the data to use
  82791. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  82792. */
  82793. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  82794. private _updateBoundingInfo;
  82795. /** @hidden */
  82796. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  82797. /**
  82798. * Gets total number of vertices
  82799. * @returns the total number of vertices
  82800. */
  82801. getTotalVertices(): number;
  82802. /**
  82803. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82804. * @param kind defines the data kind (Position, normal, etc...)
  82805. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82806. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82807. * @returns a float array containing vertex data
  82808. */
  82809. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82810. /**
  82811. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  82812. * @param kind defines the data kind (Position, normal, etc...)
  82813. * @returns true if the vertex buffer with the specified kind is updatable
  82814. */
  82815. isVertexBufferUpdatable(kind: string): boolean;
  82816. /**
  82817. * Gets a specific vertex buffer
  82818. * @param kind defines the data kind (Position, normal, etc...)
  82819. * @returns a VertexBuffer
  82820. */
  82821. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  82822. /**
  82823. * Returns all vertex buffers
  82824. * @return an object holding all vertex buffers indexed by kind
  82825. */
  82826. getVertexBuffers(): Nullable<{
  82827. [key: string]: VertexBuffer;
  82828. }>;
  82829. /**
  82830. * Gets a boolean indicating if specific vertex buffer is present
  82831. * @param kind defines the data kind (Position, normal, etc...)
  82832. * @returns true if data is present
  82833. */
  82834. isVerticesDataPresent(kind: string): boolean;
  82835. /**
  82836. * Gets a list of all attached data kinds (Position, normal, etc...)
  82837. * @returns a list of string containing all kinds
  82838. */
  82839. getVerticesDataKinds(): string[];
  82840. /**
  82841. * Update index buffer
  82842. * @param indices defines the indices to store in the index buffer
  82843. * @param offset defines the offset in the target buffer where to store the data
  82844. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  82845. */
  82846. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  82847. /**
  82848. * Creates a new index buffer
  82849. * @param indices defines the indices to store in the index buffer
  82850. * @param totalVertices defines the total number of vertices (could be null)
  82851. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82852. */
  82853. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  82854. /**
  82855. * Return the total number of indices
  82856. * @returns the total number of indices
  82857. */
  82858. getTotalIndices(): number;
  82859. /**
  82860. * Gets the index buffer array
  82861. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82862. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82863. * @returns the index buffer array
  82864. */
  82865. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82866. /**
  82867. * Gets the index buffer
  82868. * @return the index buffer
  82869. */
  82870. getIndexBuffer(): Nullable<DataBuffer>;
  82871. /** @hidden */
  82872. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  82873. /**
  82874. * Release the associated resources for a specific mesh
  82875. * @param mesh defines the source mesh
  82876. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82877. */
  82878. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  82879. /**
  82880. * Apply current geometry to a given mesh
  82881. * @param mesh defines the mesh to apply geometry to
  82882. */
  82883. applyToMesh(mesh: Mesh): void;
  82884. private _updateExtend;
  82885. private _applyToMesh;
  82886. private notifyUpdate;
  82887. /**
  82888. * Load the geometry if it was flagged as delay loaded
  82889. * @param scene defines the hosting scene
  82890. * @param onLoaded defines a callback called when the geometry is loaded
  82891. */
  82892. load(scene: Scene, onLoaded?: () => void): void;
  82893. private _queueLoad;
  82894. /**
  82895. * Invert the geometry to move from a right handed system to a left handed one.
  82896. */
  82897. toLeftHanded(): void;
  82898. /** @hidden */
  82899. _resetPointsArrayCache(): void;
  82900. /** @hidden */
  82901. _generatePointsArray(): boolean;
  82902. /**
  82903. * Gets a value indicating if the geometry is disposed
  82904. * @returns true if the geometry was disposed
  82905. */
  82906. isDisposed(): boolean;
  82907. private _disposeVertexArrayObjects;
  82908. /**
  82909. * Free all associated resources
  82910. */
  82911. dispose(): void;
  82912. /**
  82913. * Clone the current geometry into a new geometry
  82914. * @param id defines the unique ID of the new geometry
  82915. * @returns a new geometry object
  82916. */
  82917. copy(id: string): Geometry;
  82918. /**
  82919. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82920. * @return a JSON representation of the current geometry data (without the vertices data)
  82921. */
  82922. serialize(): any;
  82923. private toNumberArray;
  82924. /**
  82925. * Serialize all vertices data into a JSON oject
  82926. * @returns a JSON representation of the current geometry data
  82927. */
  82928. serializeVerticeData(): any;
  82929. /**
  82930. * Extracts a clone of a mesh geometry
  82931. * @param mesh defines the source mesh
  82932. * @param id defines the unique ID of the new geometry object
  82933. * @returns the new geometry object
  82934. */
  82935. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  82936. /**
  82937. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82938. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82939. * Be aware Math.random() could cause collisions, but:
  82940. * "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"
  82941. * @returns a string containing a new GUID
  82942. */
  82943. static RandomId(): string;
  82944. /** @hidden */
  82945. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  82946. private static _CleanMatricesWeights;
  82947. /**
  82948. * Create a new geometry from persisted data (Using .babylon file format)
  82949. * @param parsedVertexData defines the persisted data
  82950. * @param scene defines the hosting scene
  82951. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82952. * @returns the new geometry object
  82953. */
  82954. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  82955. }
  82956. }
  82957. declare module BABYLON {
  82958. /**
  82959. * Define an interface for all classes that will get and set the data on vertices
  82960. */
  82961. export interface IGetSetVerticesData {
  82962. /**
  82963. * Gets a boolean indicating if specific vertex data is present
  82964. * @param kind defines the vertex data kind to use
  82965. * @returns true is data kind is present
  82966. */
  82967. isVerticesDataPresent(kind: string): boolean;
  82968. /**
  82969. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82970. * @param kind defines the data kind (Position, normal, etc...)
  82971. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82972. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82973. * @returns a float array containing vertex data
  82974. */
  82975. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82976. /**
  82977. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82978. * @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.
  82979. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82980. * @returns the indices array or an empty array if the mesh has no geometry
  82981. */
  82982. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82983. /**
  82984. * Set specific vertex data
  82985. * @param kind defines the data kind (Position, normal, etc...)
  82986. * @param data defines the vertex data to use
  82987. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82988. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82989. */
  82990. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82991. /**
  82992. * Update a specific associated vertex buffer
  82993. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82994. * - VertexBuffer.PositionKind
  82995. * - VertexBuffer.UVKind
  82996. * - VertexBuffer.UV2Kind
  82997. * - VertexBuffer.UV3Kind
  82998. * - VertexBuffer.UV4Kind
  82999. * - VertexBuffer.UV5Kind
  83000. * - VertexBuffer.UV6Kind
  83001. * - VertexBuffer.ColorKind
  83002. * - VertexBuffer.MatricesIndicesKind
  83003. * - VertexBuffer.MatricesIndicesExtraKind
  83004. * - VertexBuffer.MatricesWeightsKind
  83005. * - VertexBuffer.MatricesWeightsExtraKind
  83006. * @param data defines the data source
  83007. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  83008. * @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)
  83009. */
  83010. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  83011. /**
  83012. * Creates a new index buffer
  83013. * @param indices defines the indices to store in the index buffer
  83014. * @param totalVertices defines the total number of vertices (could be null)
  83015. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  83016. */
  83017. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  83018. }
  83019. /**
  83020. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  83021. */
  83022. export class VertexData {
  83023. /**
  83024. * Mesh side orientation : usually the external or front surface
  83025. */
  83026. static readonly FRONTSIDE: number;
  83027. /**
  83028. * Mesh side orientation : usually the internal or back surface
  83029. */
  83030. static readonly BACKSIDE: number;
  83031. /**
  83032. * Mesh side orientation : both internal and external or front and back surfaces
  83033. */
  83034. static readonly DOUBLESIDE: number;
  83035. /**
  83036. * Mesh side orientation : by default, `FRONTSIDE`
  83037. */
  83038. static readonly DEFAULTSIDE: number;
  83039. /**
  83040. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  83041. */
  83042. positions: Nullable<FloatArray>;
  83043. /**
  83044. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  83045. */
  83046. normals: Nullable<FloatArray>;
  83047. /**
  83048. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  83049. */
  83050. tangents: Nullable<FloatArray>;
  83051. /**
  83052. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83053. */
  83054. uvs: Nullable<FloatArray>;
  83055. /**
  83056. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83057. */
  83058. uvs2: Nullable<FloatArray>;
  83059. /**
  83060. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83061. */
  83062. uvs3: Nullable<FloatArray>;
  83063. /**
  83064. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83065. */
  83066. uvs4: Nullable<FloatArray>;
  83067. /**
  83068. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83069. */
  83070. uvs5: Nullable<FloatArray>;
  83071. /**
  83072. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83073. */
  83074. uvs6: Nullable<FloatArray>;
  83075. /**
  83076. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  83077. */
  83078. colors: Nullable<FloatArray>;
  83079. /**
  83080. * 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).
  83081. */
  83082. matricesIndices: Nullable<FloatArray>;
  83083. /**
  83084. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  83085. */
  83086. matricesWeights: Nullable<FloatArray>;
  83087. /**
  83088. * An array extending the number of possible indices
  83089. */
  83090. matricesIndicesExtra: Nullable<FloatArray>;
  83091. /**
  83092. * An array extending the number of possible weights when the number of indices is extended
  83093. */
  83094. matricesWeightsExtra: Nullable<FloatArray>;
  83095. /**
  83096. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  83097. */
  83098. indices: Nullable<IndicesArray>;
  83099. /**
  83100. * Uses the passed data array to set the set the values for the specified kind of data
  83101. * @param data a linear array of floating numbers
  83102. * @param kind the type of data that is being set, eg positions, colors etc
  83103. */
  83104. set(data: FloatArray, kind: string): void;
  83105. /**
  83106. * Associates the vertexData to the passed Mesh.
  83107. * Sets it as updatable or not (default `false`)
  83108. * @param mesh the mesh the vertexData is applied to
  83109. * @param updatable when used and having the value true allows new data to update the vertexData
  83110. * @returns the VertexData
  83111. */
  83112. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  83113. /**
  83114. * Associates the vertexData to the passed Geometry.
  83115. * Sets it as updatable or not (default `false`)
  83116. * @param geometry the geometry the vertexData is applied to
  83117. * @param updatable when used and having the value true allows new data to update the vertexData
  83118. * @returns VertexData
  83119. */
  83120. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  83121. /**
  83122. * Updates the associated mesh
  83123. * @param mesh the mesh to be updated
  83124. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83125. * @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
  83126. * @returns VertexData
  83127. */
  83128. updateMesh(mesh: Mesh): VertexData;
  83129. /**
  83130. * Updates the associated geometry
  83131. * @param geometry the geometry to be updated
  83132. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83133. * @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
  83134. * @returns VertexData.
  83135. */
  83136. updateGeometry(geometry: Geometry): VertexData;
  83137. private _applyTo;
  83138. private _update;
  83139. /**
  83140. * Transforms each position and each normal of the vertexData according to the passed Matrix
  83141. * @param matrix the transforming matrix
  83142. * @returns the VertexData
  83143. */
  83144. transform(matrix: Matrix): VertexData;
  83145. /**
  83146. * Merges the passed VertexData into the current one
  83147. * @param other the VertexData to be merged into the current one
  83148. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  83149. * @returns the modified VertexData
  83150. */
  83151. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  83152. private _mergeElement;
  83153. private _validate;
  83154. /**
  83155. * Serializes the VertexData
  83156. * @returns a serialized object
  83157. */
  83158. serialize(): any;
  83159. /**
  83160. * Extracts the vertexData from a mesh
  83161. * @param mesh the mesh from which to extract the VertexData
  83162. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  83163. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83164. * @returns the object VertexData associated to the passed mesh
  83165. */
  83166. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83167. /**
  83168. * Extracts the vertexData from the geometry
  83169. * @param geometry the geometry from which to extract the VertexData
  83170. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  83171. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83172. * @returns the object VertexData associated to the passed mesh
  83173. */
  83174. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83175. private static _ExtractFrom;
  83176. /**
  83177. * Creates the VertexData for a Ribbon
  83178. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  83179. * * pathArray array of paths, each of which an array of successive Vector3
  83180. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  83181. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  83182. * * 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
  83183. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83184. * * 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)
  83185. * * 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)
  83186. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  83187. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  83188. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  83189. * @returns the VertexData of the ribbon
  83190. */
  83191. static CreateRibbon(options: {
  83192. pathArray: Vector3[][];
  83193. closeArray?: boolean;
  83194. closePath?: boolean;
  83195. offset?: number;
  83196. sideOrientation?: number;
  83197. frontUVs?: Vector4;
  83198. backUVs?: Vector4;
  83199. invertUV?: boolean;
  83200. uvs?: Vector2[];
  83201. colors?: Color4[];
  83202. }): VertexData;
  83203. /**
  83204. * Creates the VertexData for a box
  83205. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83206. * * size sets the width, height and depth of the box to the value of size, optional default 1
  83207. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  83208. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  83209. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  83210. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  83211. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  83212. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83213. * * 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)
  83214. * * 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)
  83215. * @returns the VertexData of the box
  83216. */
  83217. static CreateBox(options: {
  83218. size?: number;
  83219. width?: number;
  83220. height?: number;
  83221. depth?: number;
  83222. faceUV?: Vector4[];
  83223. faceColors?: Color4[];
  83224. sideOrientation?: number;
  83225. frontUVs?: Vector4;
  83226. backUVs?: Vector4;
  83227. }): VertexData;
  83228. /**
  83229. * Creates the VertexData for an ellipsoid, defaults to a sphere
  83230. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83231. * * segments sets the number of horizontal strips optional, default 32
  83232. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  83233. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  83234. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  83235. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  83236. * * 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
  83237. * * 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
  83238. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83239. * * 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)
  83240. * * 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)
  83241. * @returns the VertexData of the ellipsoid
  83242. */
  83243. static CreateSphere(options: {
  83244. segments?: number;
  83245. diameter?: number;
  83246. diameterX?: number;
  83247. diameterY?: number;
  83248. diameterZ?: number;
  83249. arc?: number;
  83250. slice?: number;
  83251. sideOrientation?: number;
  83252. frontUVs?: Vector4;
  83253. backUVs?: Vector4;
  83254. }): VertexData;
  83255. /**
  83256. * Creates the VertexData for a cylinder, cone or prism
  83257. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83258. * * height sets the height (y direction) of the cylinder, optional, default 2
  83259. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  83260. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  83261. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  83262. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83263. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  83264. * * 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
  83265. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83266. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83267. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  83268. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  83269. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83270. * * 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)
  83271. * * 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)
  83272. * @returns the VertexData of the cylinder, cone or prism
  83273. */
  83274. static CreateCylinder(options: {
  83275. height?: number;
  83276. diameterTop?: number;
  83277. diameterBottom?: number;
  83278. diameter?: number;
  83279. tessellation?: number;
  83280. subdivisions?: number;
  83281. arc?: number;
  83282. faceColors?: Color4[];
  83283. faceUV?: Vector4[];
  83284. hasRings?: boolean;
  83285. enclose?: boolean;
  83286. sideOrientation?: number;
  83287. frontUVs?: Vector4;
  83288. backUVs?: Vector4;
  83289. }): VertexData;
  83290. /**
  83291. * Creates the VertexData for a torus
  83292. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83293. * * diameter the diameter of the torus, optional default 1
  83294. * * thickness the diameter of the tube forming the torus, optional default 0.5
  83295. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83297. * * 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)
  83298. * * 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)
  83299. * @returns the VertexData of the torus
  83300. */
  83301. static CreateTorus(options: {
  83302. diameter?: number;
  83303. thickness?: number;
  83304. tessellation?: number;
  83305. sideOrientation?: number;
  83306. frontUVs?: Vector4;
  83307. backUVs?: Vector4;
  83308. }): VertexData;
  83309. /**
  83310. * Creates the VertexData of the LineSystem
  83311. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  83312. * - lines an array of lines, each line being an array of successive Vector3
  83313. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  83314. * @returns the VertexData of the LineSystem
  83315. */
  83316. static CreateLineSystem(options: {
  83317. lines: Vector3[][];
  83318. colors?: Nullable<Color4[][]>;
  83319. }): VertexData;
  83320. /**
  83321. * Create the VertexData for a DashedLines
  83322. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  83323. * - points an array successive Vector3
  83324. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  83325. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  83326. * - dashNb the intended total number of dashes, optional, default 200
  83327. * @returns the VertexData for the DashedLines
  83328. */
  83329. static CreateDashedLines(options: {
  83330. points: Vector3[];
  83331. dashSize?: number;
  83332. gapSize?: number;
  83333. dashNb?: number;
  83334. }): VertexData;
  83335. /**
  83336. * Creates the VertexData for a Ground
  83337. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83338. * - width the width (x direction) of the ground, optional, default 1
  83339. * - height the height (z direction) of the ground, optional, default 1
  83340. * - subdivisions the number of subdivisions per side, optional, default 1
  83341. * @returns the VertexData of the Ground
  83342. */
  83343. static CreateGround(options: {
  83344. width?: number;
  83345. height?: number;
  83346. subdivisions?: number;
  83347. subdivisionsX?: number;
  83348. subdivisionsY?: number;
  83349. }): VertexData;
  83350. /**
  83351. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  83352. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83353. * * xmin the ground minimum X coordinate, optional, default -1
  83354. * * zmin the ground minimum Z coordinate, optional, default -1
  83355. * * xmax the ground maximum X coordinate, optional, default 1
  83356. * * zmax the ground maximum Z coordinate, optional, default 1
  83357. * * 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}
  83358. * * 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}
  83359. * @returns the VertexData of the TiledGround
  83360. */
  83361. static CreateTiledGround(options: {
  83362. xmin: number;
  83363. zmin: number;
  83364. xmax: number;
  83365. zmax: number;
  83366. subdivisions?: {
  83367. w: number;
  83368. h: number;
  83369. };
  83370. precision?: {
  83371. w: number;
  83372. h: number;
  83373. };
  83374. }): VertexData;
  83375. /**
  83376. * Creates the VertexData of the Ground designed from a heightmap
  83377. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  83378. * * width the width (x direction) of the ground
  83379. * * height the height (z direction) of the ground
  83380. * * subdivisions the number of subdivisions per side
  83381. * * minHeight the minimum altitude on the ground, optional, default 0
  83382. * * maxHeight the maximum altitude on the ground, optional default 1
  83383. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  83384. * * buffer the array holding the image color data
  83385. * * bufferWidth the width of image
  83386. * * bufferHeight the height of image
  83387. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  83388. * @returns the VertexData of the Ground designed from a heightmap
  83389. */
  83390. static CreateGroundFromHeightMap(options: {
  83391. width: number;
  83392. height: number;
  83393. subdivisions: number;
  83394. minHeight: number;
  83395. maxHeight: number;
  83396. colorFilter: Color3;
  83397. buffer: Uint8Array;
  83398. bufferWidth: number;
  83399. bufferHeight: number;
  83400. alphaFilter: number;
  83401. }): VertexData;
  83402. /**
  83403. * Creates the VertexData for a Plane
  83404. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  83405. * * size sets the width and height of the plane to the value of size, optional default 1
  83406. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  83407. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  83408. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83409. * * 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)
  83410. * * 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)
  83411. * @returns the VertexData of the box
  83412. */
  83413. static CreatePlane(options: {
  83414. size?: number;
  83415. width?: number;
  83416. height?: number;
  83417. sideOrientation?: number;
  83418. frontUVs?: Vector4;
  83419. backUVs?: Vector4;
  83420. }): VertexData;
  83421. /**
  83422. * Creates the VertexData of the Disc or regular Polygon
  83423. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  83424. * * radius the radius of the disc, optional default 0.5
  83425. * * tessellation the number of polygon sides, optional, default 64
  83426. * * 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
  83427. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83428. * * 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)
  83429. * * 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)
  83430. * @returns the VertexData of the box
  83431. */
  83432. static CreateDisc(options: {
  83433. radius?: number;
  83434. tessellation?: number;
  83435. arc?: number;
  83436. sideOrientation?: number;
  83437. frontUVs?: Vector4;
  83438. backUVs?: Vector4;
  83439. }): VertexData;
  83440. /**
  83441. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  83442. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  83443. * @param polygon a mesh built from polygonTriangulation.build()
  83444. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83445. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83446. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83447. * @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)
  83448. * @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)
  83449. * @returns the VertexData of the Polygon
  83450. */
  83451. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  83452. /**
  83453. * Creates the VertexData of the IcoSphere
  83454. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  83455. * * radius the radius of the IcoSphere, optional default 1
  83456. * * radiusX allows stretching in the x direction, optional, default radius
  83457. * * radiusY allows stretching in the y direction, optional, default radius
  83458. * * radiusZ allows stretching in the z direction, optional, default radius
  83459. * * flat when true creates a flat shaded mesh, optional, default true
  83460. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83461. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83462. * * 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)
  83463. * * 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)
  83464. * @returns the VertexData of the IcoSphere
  83465. */
  83466. static CreateIcoSphere(options: {
  83467. radius?: number;
  83468. radiusX?: number;
  83469. radiusY?: number;
  83470. radiusZ?: number;
  83471. flat?: boolean;
  83472. subdivisions?: number;
  83473. sideOrientation?: number;
  83474. frontUVs?: Vector4;
  83475. backUVs?: Vector4;
  83476. }): VertexData;
  83477. /**
  83478. * Creates the VertexData for a Polyhedron
  83479. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  83480. * * type provided types are:
  83481. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  83482. * * 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)
  83483. * * size the size of the IcoSphere, optional default 1
  83484. * * sizeX allows stretching in the x direction, optional, default size
  83485. * * sizeY allows stretching in the y direction, optional, default size
  83486. * * sizeZ allows stretching in the z direction, optional, default size
  83487. * * 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
  83488. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83489. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83490. * * flat when true creates a flat shaded mesh, optional, default true
  83491. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83492. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83493. * * 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)
  83494. * * 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)
  83495. * @returns the VertexData of the Polyhedron
  83496. */
  83497. static CreatePolyhedron(options: {
  83498. type?: number;
  83499. size?: number;
  83500. sizeX?: number;
  83501. sizeY?: number;
  83502. sizeZ?: number;
  83503. custom?: any;
  83504. faceUV?: Vector4[];
  83505. faceColors?: Color4[];
  83506. flat?: boolean;
  83507. sideOrientation?: number;
  83508. frontUVs?: Vector4;
  83509. backUVs?: Vector4;
  83510. }): VertexData;
  83511. /**
  83512. * Creates the VertexData for a TorusKnot
  83513. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  83514. * * radius the radius of the torus knot, optional, default 2
  83515. * * tube the thickness of the tube, optional, default 0.5
  83516. * * radialSegments the number of sides on each tube segments, optional, default 32
  83517. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  83518. * * p the number of windings around the z axis, optional, default 2
  83519. * * q the number of windings around the x axis, optional, default 3
  83520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83521. * * 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)
  83522. * * 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)
  83523. * @returns the VertexData of the Torus Knot
  83524. */
  83525. static CreateTorusKnot(options: {
  83526. radius?: number;
  83527. tube?: number;
  83528. radialSegments?: number;
  83529. tubularSegments?: number;
  83530. p?: number;
  83531. q?: number;
  83532. sideOrientation?: number;
  83533. frontUVs?: Vector4;
  83534. backUVs?: Vector4;
  83535. }): VertexData;
  83536. /**
  83537. * Compute normals for given positions and indices
  83538. * @param positions an array of vertex positions, [...., x, y, z, ......]
  83539. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  83540. * @param normals an array of vertex normals, [...., x, y, z, ......]
  83541. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  83542. * * facetNormals : optional array of facet normals (vector3)
  83543. * * facetPositions : optional array of facet positions (vector3)
  83544. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  83545. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  83546. * * bInfo : optional bounding info, required for facetPartitioning computation
  83547. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  83548. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  83549. * * useRightHandedSystem: optional boolean to for right handed system computation
  83550. * * depthSort : optional boolean to enable the facet depth sort computation
  83551. * * distanceTo : optional Vector3 to compute the facet depth from this location
  83552. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  83553. */
  83554. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  83555. facetNormals?: any;
  83556. facetPositions?: any;
  83557. facetPartitioning?: any;
  83558. ratio?: number;
  83559. bInfo?: any;
  83560. bbSize?: Vector3;
  83561. subDiv?: any;
  83562. useRightHandedSystem?: boolean;
  83563. depthSort?: boolean;
  83564. distanceTo?: Vector3;
  83565. depthSortedFacets?: any;
  83566. }): void;
  83567. /** @hidden */
  83568. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  83569. /**
  83570. * Applies VertexData created from the imported parameters to the geometry
  83571. * @param parsedVertexData the parsed data from an imported file
  83572. * @param geometry the geometry to apply the VertexData to
  83573. */
  83574. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  83575. }
  83576. }
  83577. declare module BABYLON {
  83578. /**
  83579. * Class containing static functions to help procedurally build meshes
  83580. */
  83581. export class DiscBuilder {
  83582. /**
  83583. * Creates a plane polygonal mesh. By default, this is a disc
  83584. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  83585. * * 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
  83586. * * 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
  83587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  83588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  83589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83590. * @param name defines the name of the mesh
  83591. * @param options defines the options used to create the mesh
  83592. * @param scene defines the hosting scene
  83593. * @returns the plane polygonal mesh
  83594. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  83595. */
  83596. static CreateDisc(name: string, options: {
  83597. radius?: number;
  83598. tessellation?: number;
  83599. arc?: number;
  83600. updatable?: boolean;
  83601. sideOrientation?: number;
  83602. frontUVs?: Vector4;
  83603. backUVs?: Vector4;
  83604. }, scene?: Nullable<Scene>): Mesh;
  83605. }
  83606. }
  83607. declare module BABYLON {
  83608. /**
  83609. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  83610. *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.
  83611. * The SPS is also a particle system. It provides some methods to manage the particles.
  83612. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  83613. *
  83614. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  83615. */
  83616. export class SolidParticleSystem implements IDisposable {
  83617. /**
  83618. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  83619. * Example : var p = SPS.particles[i];
  83620. */
  83621. particles: SolidParticle[];
  83622. /**
  83623. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  83624. */
  83625. nbParticles: number;
  83626. /**
  83627. * If the particles must ever face the camera (default false). Useful for planar particles.
  83628. */
  83629. billboard: boolean;
  83630. /**
  83631. * Recompute normals when adding a shape
  83632. */
  83633. recomputeNormals: boolean;
  83634. /**
  83635. * This a counter ofr your own usage. It's not set by any SPS functions.
  83636. */
  83637. counter: number;
  83638. /**
  83639. * The SPS name. This name is also given to the underlying mesh.
  83640. */
  83641. name: string;
  83642. /**
  83643. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  83644. */
  83645. mesh: Mesh;
  83646. /**
  83647. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  83648. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  83649. */
  83650. vars: any;
  83651. /**
  83652. * This array is populated when the SPS is set as 'pickable'.
  83653. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  83654. * Each element of this array is an object `{idx: int, faceId: int}`.
  83655. * `idx` is the picked particle index in the `SPS.particles` array
  83656. * `faceId` is the picked face index counted within this particle.
  83657. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  83658. */
  83659. pickedParticles: {
  83660. idx: number;
  83661. faceId: number;
  83662. }[];
  83663. /**
  83664. * This array is populated when `enableDepthSort` is set to true.
  83665. * Each element of this array is an instance of the class DepthSortedParticle.
  83666. */
  83667. depthSortedParticles: DepthSortedParticle[];
  83668. /**
  83669. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  83670. * @hidden
  83671. */
  83672. _bSphereOnly: boolean;
  83673. /**
  83674. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  83675. * @hidden
  83676. */
  83677. _bSphereRadiusFactor: number;
  83678. private _scene;
  83679. private _positions;
  83680. private _indices;
  83681. private _normals;
  83682. private _colors;
  83683. private _uvs;
  83684. private _indices32;
  83685. private _positions32;
  83686. private _normals32;
  83687. private _fixedNormal32;
  83688. private _colors32;
  83689. private _uvs32;
  83690. private _index;
  83691. private _updatable;
  83692. private _pickable;
  83693. private _isVisibilityBoxLocked;
  83694. private _alwaysVisible;
  83695. private _depthSort;
  83696. private _shapeCounter;
  83697. private _copy;
  83698. private _color;
  83699. private _computeParticleColor;
  83700. private _computeParticleTexture;
  83701. private _computeParticleRotation;
  83702. private _computeParticleVertex;
  83703. private _computeBoundingBox;
  83704. private _depthSortParticles;
  83705. private _camera;
  83706. private _mustUnrotateFixedNormals;
  83707. private _particlesIntersect;
  83708. private _needs32Bits;
  83709. /**
  83710. * Creates a SPS (Solid Particle System) object.
  83711. * @param name (String) is the SPS name, this will be the underlying mesh name.
  83712. * @param scene (Scene) is the scene in which the SPS is added.
  83713. * @param options defines the options of the sps e.g.
  83714. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  83715. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  83716. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  83717. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  83718. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  83719. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  83720. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  83721. */
  83722. constructor(name: string, scene: Scene, options?: {
  83723. updatable?: boolean;
  83724. isPickable?: boolean;
  83725. enableDepthSort?: boolean;
  83726. particleIntersection?: boolean;
  83727. boundingSphereOnly?: boolean;
  83728. bSphereRadiusFactor?: number;
  83729. });
  83730. /**
  83731. * Builds the SPS underlying mesh. Returns a standard Mesh.
  83732. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  83733. * @returns the created mesh
  83734. */
  83735. buildMesh(): Mesh;
  83736. /**
  83737. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  83738. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  83739. * Thus the particles generated from `digest()` have their property `position` set yet.
  83740. * @param mesh ( Mesh ) is the mesh to be digested
  83741. * @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
  83742. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  83743. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  83744. * @returns the current SPS
  83745. */
  83746. digest(mesh: Mesh, options?: {
  83747. facetNb?: number;
  83748. number?: number;
  83749. delta?: number;
  83750. }): SolidParticleSystem;
  83751. private _unrotateFixedNormals;
  83752. private _resetCopy;
  83753. private _meshBuilder;
  83754. private _posToShape;
  83755. private _uvsToShapeUV;
  83756. private _addParticle;
  83757. /**
  83758. * Adds some particles to the SPS from the model shape. Returns the shape id.
  83759. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  83760. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  83761. * @param nb (positive integer) the number of particles to be created from this model
  83762. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  83763. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  83764. * @returns the number of shapes in the system
  83765. */
  83766. addShape(mesh: Mesh, nb: number, options?: {
  83767. positionFunction?: any;
  83768. vertexFunction?: any;
  83769. }): number;
  83770. private _rebuildParticle;
  83771. /**
  83772. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  83773. * @returns the SPS.
  83774. */
  83775. rebuildMesh(): SolidParticleSystem;
  83776. /**
  83777. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  83778. * This method calls `updateParticle()` for each particle of the SPS.
  83779. * For an animated SPS, it is usually called within the render loop.
  83780. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  83781. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  83782. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  83783. * @returns the SPS.
  83784. */
  83785. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  83786. /**
  83787. * Disposes the SPS.
  83788. */
  83789. dispose(): void;
  83790. /**
  83791. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  83792. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83793. * @returns the SPS.
  83794. */
  83795. refreshVisibleSize(): SolidParticleSystem;
  83796. /**
  83797. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  83798. * @param size the size (float) of the visibility box
  83799. * note : this doesn't lock the SPS mesh bounding box.
  83800. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83801. */
  83802. setVisibilityBox(size: number): void;
  83803. /**
  83804. * Gets whether the SPS as always visible or not
  83805. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83806. */
  83807. /**
  83808. * Sets the SPS as always visible or not
  83809. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83810. */
  83811. isAlwaysVisible: boolean;
  83812. /**
  83813. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83814. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83815. */
  83816. /**
  83817. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83818. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83819. */
  83820. isVisibilityBoxLocked: boolean;
  83821. /**
  83822. * Tells to `setParticles()` to compute the particle rotations or not.
  83823. * Default value : true. The SPS is faster when it's set to false.
  83824. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83825. */
  83826. /**
  83827. * Gets if `setParticles()` computes the particle rotations or not.
  83828. * Default value : true. The SPS is faster when it's set to false.
  83829. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83830. */
  83831. computeParticleRotation: boolean;
  83832. /**
  83833. * Tells to `setParticles()` to compute the particle colors or not.
  83834. * Default value : true. The SPS is faster when it's set to false.
  83835. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83836. */
  83837. /**
  83838. * Gets if `setParticles()` computes the particle colors or not.
  83839. * Default value : true. The SPS is faster when it's set to false.
  83840. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83841. */
  83842. computeParticleColor: boolean;
  83843. /**
  83844. * Gets if `setParticles()` computes the particle textures or not.
  83845. * Default value : true. The SPS is faster when it's set to false.
  83846. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  83847. */
  83848. computeParticleTexture: boolean;
  83849. /**
  83850. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  83851. * Default value : false. The SPS is faster when it's set to false.
  83852. * Note : the particle custom vertex positions aren't stored values.
  83853. */
  83854. /**
  83855. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  83856. * Default value : false. The SPS is faster when it's set to false.
  83857. * Note : the particle custom vertex positions aren't stored values.
  83858. */
  83859. computeParticleVertex: boolean;
  83860. /**
  83861. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  83862. */
  83863. /**
  83864. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  83865. */
  83866. computeBoundingBox: boolean;
  83867. /**
  83868. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  83869. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83870. * Default : `true`
  83871. */
  83872. /**
  83873. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  83874. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83875. * Default : `true`
  83876. */
  83877. depthSortParticles: boolean;
  83878. /**
  83879. * This function does nothing. It may be overwritten to set all the particle first values.
  83880. * The SPS doesn't call this function, you may have to call it by your own.
  83881. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83882. */
  83883. initParticles(): void;
  83884. /**
  83885. * This function does nothing. It may be overwritten to recycle a particle.
  83886. * The SPS doesn't call this function, you may have to call it by your own.
  83887. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83888. * @param particle The particle to recycle
  83889. * @returns the recycled particle
  83890. */
  83891. recycleParticle(particle: SolidParticle): SolidParticle;
  83892. /**
  83893. * Updates a particle : this function should be overwritten by the user.
  83894. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  83895. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83896. * @example : just set a particle position or velocity and recycle conditions
  83897. * @param particle The particle to update
  83898. * @returns the updated particle
  83899. */
  83900. updateParticle(particle: SolidParticle): SolidParticle;
  83901. /**
  83902. * Updates a vertex of a particle : it can be overwritten by the user.
  83903. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  83904. * @param particle the current particle
  83905. * @param vertex the current index of the current particle
  83906. * @param pt the index of the current vertex in the particle shape
  83907. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  83908. * @example : just set a vertex particle position
  83909. * @returns the updated vertex
  83910. */
  83911. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  83912. /**
  83913. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  83914. * This does nothing and may be overwritten by the user.
  83915. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83916. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83917. * @param update the boolean update value actually passed to setParticles()
  83918. */
  83919. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83920. /**
  83921. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  83922. * This will be passed three parameters.
  83923. * This does nothing and may be overwritten by the user.
  83924. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83925. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83926. * @param update the boolean update value actually passed to setParticles()
  83927. */
  83928. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83929. }
  83930. }
  83931. declare module BABYLON {
  83932. /**
  83933. * Represents one particle of a solid particle system.
  83934. */
  83935. export class SolidParticle {
  83936. /**
  83937. * particle global index
  83938. */
  83939. idx: number;
  83940. /**
  83941. * The color of the particle
  83942. */
  83943. color: Nullable<Color4>;
  83944. /**
  83945. * The world space position of the particle.
  83946. */
  83947. position: Vector3;
  83948. /**
  83949. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  83950. */
  83951. rotation: Vector3;
  83952. /**
  83953. * The world space rotation quaternion of the particle.
  83954. */
  83955. rotationQuaternion: Nullable<Quaternion>;
  83956. /**
  83957. * The scaling of the particle.
  83958. */
  83959. scaling: Vector3;
  83960. /**
  83961. * The uvs of the particle.
  83962. */
  83963. uvs: Vector4;
  83964. /**
  83965. * The current speed of the particle.
  83966. */
  83967. velocity: Vector3;
  83968. /**
  83969. * The pivot point in the particle local space.
  83970. */
  83971. pivot: Vector3;
  83972. /**
  83973. * Must the particle be translated from its pivot point in its local space ?
  83974. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  83975. * Default : false
  83976. */
  83977. translateFromPivot: boolean;
  83978. /**
  83979. * Is the particle active or not ?
  83980. */
  83981. alive: boolean;
  83982. /**
  83983. * Is the particle visible or not ?
  83984. */
  83985. isVisible: boolean;
  83986. /**
  83987. * Index of this particle in the global "positions" array (Internal use)
  83988. * @hidden
  83989. */
  83990. _pos: number;
  83991. /**
  83992. * @hidden Index of this particle in the global "indices" array (Internal use)
  83993. */
  83994. _ind: number;
  83995. /**
  83996. * @hidden ModelShape of this particle (Internal use)
  83997. */
  83998. _model: ModelShape;
  83999. /**
  84000. * ModelShape id of this particle
  84001. */
  84002. shapeId: number;
  84003. /**
  84004. * Index of the particle in its shape id (Internal use)
  84005. */
  84006. idxInShape: number;
  84007. /**
  84008. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  84009. */
  84010. _modelBoundingInfo: BoundingInfo;
  84011. /**
  84012. * @hidden Particle BoundingInfo object (Internal use)
  84013. */
  84014. _boundingInfo: BoundingInfo;
  84015. /**
  84016. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  84017. */
  84018. _sps: SolidParticleSystem;
  84019. /**
  84020. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  84021. */
  84022. _stillInvisible: boolean;
  84023. /**
  84024. * @hidden Last computed particle rotation matrix
  84025. */
  84026. _rotationMatrix: number[];
  84027. /**
  84028. * Parent particle Id, if any.
  84029. * Default null.
  84030. */
  84031. parentId: Nullable<number>;
  84032. /**
  84033. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  84034. * The possible values are :
  84035. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84036. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84037. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84038. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84039. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84040. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  84041. * */
  84042. cullingStrategy: number;
  84043. /**
  84044. * @hidden Internal global position in the SPS.
  84045. */
  84046. _globalPosition: Vector3;
  84047. /**
  84048. * Creates a Solid Particle object.
  84049. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  84050. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  84051. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  84052. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  84053. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  84054. * @param shapeId (integer) is the model shape identifier in the SPS.
  84055. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  84056. * @param sps defines the sps it is associated to
  84057. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  84058. */
  84059. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  84060. /**
  84061. * Legacy support, changed scale to scaling
  84062. */
  84063. /**
  84064. * Legacy support, changed scale to scaling
  84065. */
  84066. scale: Vector3;
  84067. /**
  84068. * Legacy support, changed quaternion to rotationQuaternion
  84069. */
  84070. /**
  84071. * Legacy support, changed quaternion to rotationQuaternion
  84072. */
  84073. quaternion: Nullable<Quaternion>;
  84074. /**
  84075. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  84076. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  84077. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  84078. * @returns true if it intersects
  84079. */
  84080. intersectsMesh(target: Mesh | SolidParticle): boolean;
  84081. /**
  84082. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  84083. * A particle is in the frustum if its bounding box intersects the frustum
  84084. * @param frustumPlanes defines the frustum to test
  84085. * @returns true if the particle is in the frustum planes
  84086. */
  84087. isInFrustum(frustumPlanes: Plane[]): boolean;
  84088. /**
  84089. * get the rotation matrix of the particle
  84090. * @hidden
  84091. */
  84092. getRotationMatrix(m: Matrix): void;
  84093. }
  84094. /**
  84095. * Represents the shape of the model used by one particle of a solid particle system.
  84096. * SPS internal tool, don't use it manually.
  84097. */
  84098. export class ModelShape {
  84099. /**
  84100. * The shape id
  84101. * @hidden
  84102. */
  84103. shapeID: number;
  84104. /**
  84105. * flat array of model positions (internal use)
  84106. * @hidden
  84107. */
  84108. _shape: Vector3[];
  84109. /**
  84110. * flat array of model UVs (internal use)
  84111. * @hidden
  84112. */
  84113. _shapeUV: number[];
  84114. /**
  84115. * length of the shape in the model indices array (internal use)
  84116. * @hidden
  84117. */
  84118. _indicesLength: number;
  84119. /**
  84120. * Custom position function (internal use)
  84121. * @hidden
  84122. */
  84123. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  84124. /**
  84125. * Custom vertex function (internal use)
  84126. * @hidden
  84127. */
  84128. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  84129. /**
  84130. * 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.
  84131. * SPS internal tool, don't use it manually.
  84132. * @hidden
  84133. */
  84134. 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>);
  84135. }
  84136. /**
  84137. * Represents a Depth Sorted Particle in the solid particle system.
  84138. */
  84139. export class DepthSortedParticle {
  84140. /**
  84141. * Index of the particle in the "indices" array
  84142. */
  84143. ind: number;
  84144. /**
  84145. * Length of the particle shape in the "indices" array
  84146. */
  84147. indicesLength: number;
  84148. /**
  84149. * Squared distance from the particle to the camera
  84150. */
  84151. sqDistance: number;
  84152. }
  84153. }
  84154. declare module BABYLON {
  84155. /**
  84156. * Class used to store all common mesh properties
  84157. */
  84158. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  84159. /** No occlusion */
  84160. static OCCLUSION_TYPE_NONE: number;
  84161. /** Occlusion set to optimisitic */
  84162. static OCCLUSION_TYPE_OPTIMISTIC: number;
  84163. /** Occlusion set to strict */
  84164. static OCCLUSION_TYPE_STRICT: number;
  84165. /** Use an accurante occlusion algorithm */
  84166. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  84167. /** Use a conservative occlusion algorithm */
  84168. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  84169. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  84170. * Test order :
  84171. * Is the bounding sphere outside the frustum ?
  84172. * If not, are the bounding box vertices outside the frustum ?
  84173. * It not, then the cullable object is in the frustum.
  84174. */
  84175. static readonly CULLINGSTRATEGY_STANDARD: number;
  84176. /** Culling strategy : Bounding Sphere Only.
  84177. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  84178. * It's also less accurate than the standard because some not visible objects can still be selected.
  84179. * Test : is the bounding sphere outside the frustum ?
  84180. * If not, then the cullable object is in the frustum.
  84181. */
  84182. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  84183. /** Culling strategy : Optimistic Inclusion.
  84184. * This in an inclusion test first, then the standard exclusion test.
  84185. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  84186. * 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.
  84187. * Anyway, it's as accurate as the standard strategy.
  84188. * Test :
  84189. * Is the cullable object bounding sphere center in the frustum ?
  84190. * If not, apply the default culling strategy.
  84191. */
  84192. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  84193. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  84194. * This in an inclusion test first, then the bounding sphere only exclusion test.
  84195. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  84196. * 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.
  84197. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  84198. * Test :
  84199. * Is the cullable object bounding sphere center in the frustum ?
  84200. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  84201. */
  84202. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  84203. /**
  84204. * No billboard
  84205. */
  84206. static readonly BILLBOARDMODE_NONE: number;
  84207. /** Billboard on X axis */
  84208. static readonly BILLBOARDMODE_X: number;
  84209. /** Billboard on Y axis */
  84210. static readonly BILLBOARDMODE_Y: number;
  84211. /** Billboard on Z axis */
  84212. static readonly BILLBOARDMODE_Z: number;
  84213. /** Billboard on all axes */
  84214. static readonly BILLBOARDMODE_ALL: number;
  84215. private _facetData;
  84216. /**
  84217. * The culling strategy to use to check whether the mesh must be rendered or not.
  84218. * This value can be changed at any time and will be used on the next render mesh selection.
  84219. * The possible values are :
  84220. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84221. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84222. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84223. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84224. * Please read each static variable documentation to get details about the culling process.
  84225. * */
  84226. cullingStrategy: number;
  84227. /**
  84228. * Gets the number of facets in the mesh
  84229. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84230. */
  84231. readonly facetNb: number;
  84232. /**
  84233. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  84234. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84235. */
  84236. partitioningSubdivisions: number;
  84237. /**
  84238. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  84239. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  84240. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84241. */
  84242. partitioningBBoxRatio: number;
  84243. /**
  84244. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  84245. * Works only for updatable meshes.
  84246. * Doesn't work with multi-materials
  84247. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84248. */
  84249. mustDepthSortFacets: boolean;
  84250. /**
  84251. * The location (Vector3) where the facet depth sort must be computed from.
  84252. * By default, the active camera position.
  84253. * Used only when facet depth sort is enabled
  84254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84255. */
  84256. facetDepthSortFrom: Vector3;
  84257. /**
  84258. * gets a boolean indicating if facetData is enabled
  84259. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84260. */
  84261. readonly isFacetDataEnabled: boolean;
  84262. /** @hidden */
  84263. _updateNonUniformScalingState(value: boolean): boolean;
  84264. /**
  84265. * An event triggered when this mesh collides with another one
  84266. */
  84267. onCollideObservable: Observable<AbstractMesh>;
  84268. private _onCollideObserver;
  84269. /** Set a function to call when this mesh collides with another one */
  84270. onCollide: () => void;
  84271. /**
  84272. * An event triggered when the collision's position changes
  84273. */
  84274. onCollisionPositionChangeObservable: Observable<Vector3>;
  84275. private _onCollisionPositionChangeObserver;
  84276. /** Set a function to call when the collision's position changes */
  84277. onCollisionPositionChange: () => void;
  84278. /**
  84279. * An event triggered when material is changed
  84280. */
  84281. onMaterialChangedObservable: Observable<AbstractMesh>;
  84282. /**
  84283. * Gets or sets the orientation for POV movement & rotation
  84284. */
  84285. definedFacingForward: boolean;
  84286. /** @hidden */
  84287. _occlusionQuery: Nullable<WebGLQuery>;
  84288. private _visibility;
  84289. /** @hidden */
  84290. _isActive: boolean;
  84291. /** @hidden */
  84292. _onlyForInstances: boolean;
  84293. /** @hidden */
  84294. _renderingGroup: Nullable<RenderingGroup>;
  84295. /**
  84296. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84297. */
  84298. /**
  84299. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84300. */
  84301. visibility: number;
  84302. /** Gets or sets the alpha index used to sort transparent meshes
  84303. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  84304. */
  84305. alphaIndex: number;
  84306. /**
  84307. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  84308. */
  84309. isVisible: boolean;
  84310. /**
  84311. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84312. */
  84313. isPickable: boolean;
  84314. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  84315. showSubMeshesBoundingBox: boolean;
  84316. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  84317. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  84318. */
  84319. isBlocker: boolean;
  84320. /**
  84321. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  84322. */
  84323. enablePointerMoveEvents: boolean;
  84324. /**
  84325. * Specifies the rendering group id for this mesh (0 by default)
  84326. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84327. */
  84328. renderingGroupId: number;
  84329. private _material;
  84330. /** Gets or sets current material */
  84331. material: Nullable<Material>;
  84332. private _receiveShadows;
  84333. /**
  84334. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  84335. * @see http://doc.babylonjs.com/babylon101/shadows
  84336. */
  84337. receiveShadows: boolean;
  84338. /** Defines color to use when rendering outline */
  84339. outlineColor: Color3;
  84340. /** Define width to use when rendering outline */
  84341. outlineWidth: number;
  84342. /** Defines color to use when rendering overlay */
  84343. overlayColor: Color3;
  84344. /** Defines alpha to use when rendering overlay */
  84345. overlayAlpha: number;
  84346. private _hasVertexAlpha;
  84347. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  84348. hasVertexAlpha: boolean;
  84349. private _useVertexColors;
  84350. /** 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) */
  84351. useVertexColors: boolean;
  84352. private _computeBonesUsingShaders;
  84353. /**
  84354. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  84355. */
  84356. computeBonesUsingShaders: boolean;
  84357. private _numBoneInfluencers;
  84358. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  84359. numBoneInfluencers: number;
  84360. private _applyFog;
  84361. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  84362. applyFog: boolean;
  84363. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  84364. useOctreeForRenderingSelection: boolean;
  84365. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  84366. useOctreeForPicking: boolean;
  84367. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  84368. useOctreeForCollisions: boolean;
  84369. private _layerMask;
  84370. /**
  84371. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  84372. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  84373. */
  84374. layerMask: number;
  84375. /**
  84376. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  84377. */
  84378. alwaysSelectAsActiveMesh: boolean;
  84379. /**
  84380. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  84381. */
  84382. doNotSyncBoundingInfo: boolean;
  84383. /**
  84384. * Gets or sets the current action manager
  84385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84386. */
  84387. actionManager: Nullable<AbstractActionManager>;
  84388. private _checkCollisions;
  84389. private _collisionMask;
  84390. private _collisionGroup;
  84391. /**
  84392. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  84393. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84394. */
  84395. ellipsoid: Vector3;
  84396. /**
  84397. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  84398. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84399. */
  84400. ellipsoidOffset: Vector3;
  84401. private _collider;
  84402. private _oldPositionForCollisions;
  84403. private _diffPositionForCollisions;
  84404. /**
  84405. * Gets or sets a collision mask used to mask collisions (default is -1).
  84406. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84407. */
  84408. collisionMask: number;
  84409. /**
  84410. * Gets or sets the current collision group mask (-1 by default).
  84411. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84412. */
  84413. collisionGroup: number;
  84414. /**
  84415. * Defines edge width used when edgesRenderer is enabled
  84416. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84417. */
  84418. edgesWidth: number;
  84419. /**
  84420. * Defines edge color used when edgesRenderer is enabled
  84421. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84422. */
  84423. edgesColor: Color4;
  84424. /** @hidden */
  84425. _edgesRenderer: Nullable<IEdgesRenderer>;
  84426. /** @hidden */
  84427. _masterMesh: Nullable<AbstractMesh>;
  84428. /** @hidden */
  84429. _boundingInfo: Nullable<BoundingInfo>;
  84430. /** @hidden */
  84431. _renderId: number;
  84432. /**
  84433. * Gets or sets the list of subMeshes
  84434. * @see http://doc.babylonjs.com/how_to/multi_materials
  84435. */
  84436. subMeshes: SubMesh[];
  84437. /** @hidden */
  84438. _intersectionsInProgress: AbstractMesh[];
  84439. /** @hidden */
  84440. _unIndexed: boolean;
  84441. /** @hidden */
  84442. _lightSources: Light[];
  84443. /** Gets the list of lights affecting that mesh */
  84444. readonly lightSources: Light[];
  84445. /** @hidden */
  84446. readonly _positions: Nullable<Vector3[]>;
  84447. /** @hidden */
  84448. _waitingData: {
  84449. lods: Nullable<any>;
  84450. actions: Nullable<any>;
  84451. freezeWorldMatrix: Nullable<boolean>;
  84452. };
  84453. private _skeleton;
  84454. /** @hidden */
  84455. _bonesTransformMatrices: Nullable<Float32Array>;
  84456. /**
  84457. * Gets or sets a skeleton to apply skining transformations
  84458. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84459. */
  84460. skeleton: Nullable<Skeleton>;
  84461. /**
  84462. * An event triggered when the mesh is rebuilt.
  84463. */
  84464. onRebuildObservable: Observable<AbstractMesh>;
  84465. /**
  84466. * Creates a new AbstractMesh
  84467. * @param name defines the name of the mesh
  84468. * @param scene defines the hosting scene
  84469. */
  84470. constructor(name: string, scene?: Nullable<Scene>);
  84471. /**
  84472. * Returns the string "AbstractMesh"
  84473. * @returns "AbstractMesh"
  84474. */
  84475. getClassName(): string;
  84476. /**
  84477. * Gets a string representation of the current mesh
  84478. * @param fullDetails defines a boolean indicating if full details must be included
  84479. * @returns a string representation of the current mesh
  84480. */
  84481. toString(fullDetails?: boolean): string;
  84482. /**
  84483. * @hidden
  84484. */
  84485. protected _getEffectiveParent(): Nullable<Node>;
  84486. /** @hidden */
  84487. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84488. /** @hidden */
  84489. _rebuild(): void;
  84490. /** @hidden */
  84491. _resyncLightSources(): void;
  84492. /** @hidden */
  84493. _resyncLighSource(light: Light): void;
  84494. /** @hidden */
  84495. _unBindEffect(): void;
  84496. /** @hidden */
  84497. _removeLightSource(light: Light): void;
  84498. private _markSubMeshesAsDirty;
  84499. /** @hidden */
  84500. _markSubMeshesAsLightDirty(): void;
  84501. /** @hidden */
  84502. _markSubMeshesAsAttributesDirty(): void;
  84503. /** @hidden */
  84504. _markSubMeshesAsMiscDirty(): void;
  84505. /**
  84506. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  84507. */
  84508. scaling: Vector3;
  84509. /**
  84510. * Returns true if the mesh is blocked. Implemented by child classes
  84511. */
  84512. readonly isBlocked: boolean;
  84513. /**
  84514. * Returns the mesh itself by default. Implemented by child classes
  84515. * @param camera defines the camera to use to pick the right LOD level
  84516. * @returns the currentAbstractMesh
  84517. */
  84518. getLOD(camera: Camera): Nullable<AbstractMesh>;
  84519. /**
  84520. * Returns 0 by default. Implemented by child classes
  84521. * @returns an integer
  84522. */
  84523. getTotalVertices(): number;
  84524. /**
  84525. * Returns a positive integer : the total number of indices in this mesh geometry.
  84526. * @returns the numner of indices or zero if the mesh has no geometry.
  84527. */
  84528. getTotalIndices(): number;
  84529. /**
  84530. * Returns null by default. Implemented by child classes
  84531. * @returns null
  84532. */
  84533. getIndices(): Nullable<IndicesArray>;
  84534. /**
  84535. * Returns the array of the requested vertex data kind. Implemented by child classes
  84536. * @param kind defines the vertex data kind to use
  84537. * @returns null
  84538. */
  84539. getVerticesData(kind: string): Nullable<FloatArray>;
  84540. /**
  84541. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84542. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84543. * Note that a new underlying VertexBuffer object is created each call.
  84544. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84545. * @param kind defines vertex data kind:
  84546. * * VertexBuffer.PositionKind
  84547. * * VertexBuffer.UVKind
  84548. * * VertexBuffer.UV2Kind
  84549. * * VertexBuffer.UV3Kind
  84550. * * VertexBuffer.UV4Kind
  84551. * * VertexBuffer.UV5Kind
  84552. * * VertexBuffer.UV6Kind
  84553. * * VertexBuffer.ColorKind
  84554. * * VertexBuffer.MatricesIndicesKind
  84555. * * VertexBuffer.MatricesIndicesExtraKind
  84556. * * VertexBuffer.MatricesWeightsKind
  84557. * * VertexBuffer.MatricesWeightsExtraKind
  84558. * @param data defines the data source
  84559. * @param updatable defines if the data must be flagged as updatable (or static)
  84560. * @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
  84561. * @returns the current mesh
  84562. */
  84563. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84564. /**
  84565. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84566. * If the mesh has no geometry, it is simply returned as it is.
  84567. * @param kind defines vertex data kind:
  84568. * * VertexBuffer.PositionKind
  84569. * * VertexBuffer.UVKind
  84570. * * VertexBuffer.UV2Kind
  84571. * * VertexBuffer.UV3Kind
  84572. * * VertexBuffer.UV4Kind
  84573. * * VertexBuffer.UV5Kind
  84574. * * VertexBuffer.UV6Kind
  84575. * * VertexBuffer.ColorKind
  84576. * * VertexBuffer.MatricesIndicesKind
  84577. * * VertexBuffer.MatricesIndicesExtraKind
  84578. * * VertexBuffer.MatricesWeightsKind
  84579. * * VertexBuffer.MatricesWeightsExtraKind
  84580. * @param data defines the data source
  84581. * @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
  84582. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  84583. * @returns the current mesh
  84584. */
  84585. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  84586. /**
  84587. * Sets the mesh indices,
  84588. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84589. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  84590. * @param totalVertices Defines the total number of vertices
  84591. * @returns the current mesh
  84592. */
  84593. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  84594. /**
  84595. * Gets a boolean indicating if specific vertex data is present
  84596. * @param kind defines the vertex data kind to use
  84597. * @returns true is data kind is present
  84598. */
  84599. isVerticesDataPresent(kind: string): boolean;
  84600. /**
  84601. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  84602. * @returns a BoundingInfo
  84603. */
  84604. getBoundingInfo(): BoundingInfo;
  84605. /**
  84606. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  84607. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  84608. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  84609. * @returns the current mesh
  84610. */
  84611. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  84612. /**
  84613. * Overwrite the current bounding info
  84614. * @param boundingInfo defines the new bounding info
  84615. * @returns the current mesh
  84616. */
  84617. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  84618. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  84619. readonly useBones: boolean;
  84620. /** @hidden */
  84621. _preActivate(): void;
  84622. /** @hidden */
  84623. _preActivateForIntermediateRendering(renderId: number): void;
  84624. /** @hidden */
  84625. _activate(renderId: number): boolean;
  84626. /** @hidden */
  84627. _postActivate(): void;
  84628. /** @hidden */
  84629. _freeze(): void;
  84630. /** @hidden */
  84631. _unFreeze(): void;
  84632. /**
  84633. * Gets the current world matrix
  84634. * @returns a Matrix
  84635. */
  84636. getWorldMatrix(): Matrix;
  84637. /** @hidden */
  84638. _getWorldMatrixDeterminant(): number;
  84639. /**
  84640. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  84641. */
  84642. readonly isAnInstance: boolean;
  84643. /**
  84644. * Perform relative position change from the point of view of behind the front of the mesh.
  84645. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84646. * Supports definition of mesh facing forward or backward
  84647. * @param amountRight defines the distance on the right axis
  84648. * @param amountUp defines the distance on the up axis
  84649. * @param amountForward defines the distance on the forward axis
  84650. * @returns the current mesh
  84651. */
  84652. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  84653. /**
  84654. * Calculate relative position change from the point of view of behind the front of the mesh.
  84655. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84656. * Supports definition of mesh facing forward or backward
  84657. * @param amountRight defines the distance on the right axis
  84658. * @param amountUp defines the distance on the up axis
  84659. * @param amountForward defines the distance on the forward axis
  84660. * @returns the new displacement vector
  84661. */
  84662. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  84663. /**
  84664. * Perform relative rotation change from the point of view of behind the front of the mesh.
  84665. * Supports definition of mesh facing forward or backward
  84666. * @param flipBack defines the flip
  84667. * @param twirlClockwise defines the twirl
  84668. * @param tiltRight defines the tilt
  84669. * @returns the current mesh
  84670. */
  84671. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  84672. /**
  84673. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  84674. * Supports definition of mesh facing forward or backward.
  84675. * @param flipBack defines the flip
  84676. * @param twirlClockwise defines the twirl
  84677. * @param tiltRight defines the tilt
  84678. * @returns the new rotation vector
  84679. */
  84680. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  84681. /**
  84682. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84683. * This means the mesh underlying bounding box and sphere are recomputed.
  84684. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84685. * @returns the current mesh
  84686. */
  84687. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  84688. /** @hidden */
  84689. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  84690. /** @hidden */
  84691. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  84692. /** @hidden */
  84693. _updateBoundingInfo(): AbstractMesh;
  84694. /** @hidden */
  84695. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  84696. /** @hidden */
  84697. protected _afterComputeWorldMatrix(): void;
  84698. /** @hidden */
  84699. readonly _effectiveMesh: AbstractMesh;
  84700. /**
  84701. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84702. * A mesh is in the frustum if its bounding box intersects the frustum
  84703. * @param frustumPlanes defines the frustum to test
  84704. * @returns true if the mesh is in the frustum planes
  84705. */
  84706. isInFrustum(frustumPlanes: Plane[]): boolean;
  84707. /**
  84708. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  84709. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  84710. * @param frustumPlanes defines the frustum to test
  84711. * @returns true if the mesh is completely in the frustum planes
  84712. */
  84713. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84714. /**
  84715. * True if the mesh intersects another mesh or a SolidParticle object
  84716. * @param mesh defines a target mesh or SolidParticle to test
  84717. * @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)
  84718. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  84719. * @returns true if there is an intersection
  84720. */
  84721. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  84722. /**
  84723. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  84724. * @param point defines the point to test
  84725. * @returns true if there is an intersection
  84726. */
  84727. intersectsPoint(point: Vector3): boolean;
  84728. /**
  84729. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  84730. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84731. */
  84732. checkCollisions: boolean;
  84733. /**
  84734. * Gets Collider object used to compute collisions (not physics)
  84735. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84736. */
  84737. readonly collider: Nullable<Collider>;
  84738. /**
  84739. * Move the mesh using collision engine
  84740. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84741. * @param displacement defines the requested displacement vector
  84742. * @returns the current mesh
  84743. */
  84744. moveWithCollisions(displacement: Vector3): AbstractMesh;
  84745. private _onCollisionPositionChange;
  84746. /** @hidden */
  84747. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  84748. /** @hidden */
  84749. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  84750. /** @hidden */
  84751. _checkCollision(collider: Collider): AbstractMesh;
  84752. /** @hidden */
  84753. _generatePointsArray(): boolean;
  84754. /**
  84755. * Checks if the passed Ray intersects with the mesh
  84756. * @param ray defines the ray to use
  84757. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  84758. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84759. * @returns the picking info
  84760. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84761. */
  84762. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  84763. /**
  84764. * Clones the current mesh
  84765. * @param name defines the mesh name
  84766. * @param newParent defines the new mesh parent
  84767. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  84768. * @returns the new mesh
  84769. */
  84770. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84771. /**
  84772. * Disposes all the submeshes of the current meshnp
  84773. * @returns the current mesh
  84774. */
  84775. releaseSubMeshes(): AbstractMesh;
  84776. /**
  84777. * Releases resources associated with this abstract mesh.
  84778. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84779. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84780. */
  84781. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84782. /**
  84783. * Adds the passed mesh as a child to the current mesh
  84784. * @param mesh defines the child mesh
  84785. * @returns the current mesh
  84786. */
  84787. addChild(mesh: AbstractMesh): AbstractMesh;
  84788. /**
  84789. * Removes the passed mesh from the current mesh children list
  84790. * @param mesh defines the child mesh
  84791. * @returns the current mesh
  84792. */
  84793. removeChild(mesh: AbstractMesh): AbstractMesh;
  84794. /** @hidden */
  84795. private _initFacetData;
  84796. /**
  84797. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  84798. * This method can be called within the render loop.
  84799. * 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
  84800. * @returns the current mesh
  84801. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84802. */
  84803. updateFacetData(): AbstractMesh;
  84804. /**
  84805. * Returns the facetLocalNormals array.
  84806. * The normals are expressed in the mesh local spac
  84807. * @returns an array of Vector3
  84808. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84809. */
  84810. getFacetLocalNormals(): Vector3[];
  84811. /**
  84812. * Returns the facetLocalPositions array.
  84813. * The facet positions are expressed in the mesh local space
  84814. * @returns an array of Vector3
  84815. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84816. */
  84817. getFacetLocalPositions(): Vector3[];
  84818. /**
  84819. * Returns the facetLocalPartioning array
  84820. * @returns an array of array of numbers
  84821. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84822. */
  84823. getFacetLocalPartitioning(): number[][];
  84824. /**
  84825. * Returns the i-th facet position in the world system.
  84826. * This method allocates a new Vector3 per call
  84827. * @param i defines the facet index
  84828. * @returns a new Vector3
  84829. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84830. */
  84831. getFacetPosition(i: number): Vector3;
  84832. /**
  84833. * Sets the reference Vector3 with the i-th facet position in the world system
  84834. * @param i defines the facet index
  84835. * @param ref defines the target vector
  84836. * @returns the current mesh
  84837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84838. */
  84839. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  84840. /**
  84841. * Returns the i-th facet normal in the world system.
  84842. * This method allocates a new Vector3 per call
  84843. * @param i defines the facet index
  84844. * @returns a new Vector3
  84845. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84846. */
  84847. getFacetNormal(i: number): Vector3;
  84848. /**
  84849. * Sets the reference Vector3 with the i-th facet normal in the world system
  84850. * @param i defines the facet index
  84851. * @param ref defines the target vector
  84852. * @returns the current mesh
  84853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84854. */
  84855. getFacetNormalToRef(i: number, ref: Vector3): this;
  84856. /**
  84857. * 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)
  84858. * @param x defines x coordinate
  84859. * @param y defines y coordinate
  84860. * @param z defines z coordinate
  84861. * @returns the array of facet indexes
  84862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84863. */
  84864. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  84865. /**
  84866. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  84867. * @param projected sets as the (x,y,z) world projection on the facet
  84868. * @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
  84869. * @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
  84870. * @param x defines x coordinate
  84871. * @param y defines y coordinate
  84872. * @param z defines z coordinate
  84873. * @returns the face index if found (or null instead)
  84874. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84875. */
  84876. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84877. /**
  84878. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  84879. * @param projected sets as the (x,y,z) local projection on the facet
  84880. * @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
  84881. * @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
  84882. * @param x defines x coordinate
  84883. * @param y defines y coordinate
  84884. * @param z defines z coordinate
  84885. * @returns the face index if found (or null instead)
  84886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84887. */
  84888. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84889. /**
  84890. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  84891. * @returns the parameters
  84892. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84893. */
  84894. getFacetDataParameters(): any;
  84895. /**
  84896. * Disables the feature FacetData and frees the related memory
  84897. * @returns the current mesh
  84898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84899. */
  84900. disableFacetData(): AbstractMesh;
  84901. /**
  84902. * Updates the AbstractMesh indices array
  84903. * @param indices defines the data source
  84904. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84905. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  84906. * @returns the current mesh
  84907. */
  84908. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  84909. /**
  84910. * Creates new normals data for the mesh
  84911. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  84912. * @returns the current mesh
  84913. */
  84914. createNormals(updatable: boolean): AbstractMesh;
  84915. /**
  84916. * Align the mesh with a normal
  84917. * @param normal defines the normal to use
  84918. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  84919. * @returns the current mesh
  84920. */
  84921. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  84922. /** @hidden */
  84923. _checkOcclusionQuery(): boolean;
  84924. }
  84925. }
  84926. declare module BABYLON {
  84927. /**
  84928. * Interface used to define ActionEvent
  84929. */
  84930. export interface IActionEvent {
  84931. /** The mesh or sprite that triggered the action */
  84932. source: any;
  84933. /** The X mouse cursor position at the time of the event */
  84934. pointerX: number;
  84935. /** The Y mouse cursor position at the time of the event */
  84936. pointerY: number;
  84937. /** The mesh that is currently pointed at (can be null) */
  84938. meshUnderPointer: Nullable<AbstractMesh>;
  84939. /** the original (browser) event that triggered the ActionEvent */
  84940. sourceEvent?: any;
  84941. /** additional data for the event */
  84942. additionalData?: any;
  84943. }
  84944. /**
  84945. * ActionEvent is the event being sent when an action is triggered.
  84946. */
  84947. export class ActionEvent implements IActionEvent {
  84948. /** The mesh or sprite that triggered the action */
  84949. source: any;
  84950. /** The X mouse cursor position at the time of the event */
  84951. pointerX: number;
  84952. /** The Y mouse cursor position at the time of the event */
  84953. pointerY: number;
  84954. /** The mesh that is currently pointed at (can be null) */
  84955. meshUnderPointer: Nullable<AbstractMesh>;
  84956. /** the original (browser) event that triggered the ActionEvent */
  84957. sourceEvent?: any;
  84958. /** additional data for the event */
  84959. additionalData?: any;
  84960. /**
  84961. * Creates a new ActionEvent
  84962. * @param source The mesh or sprite that triggered the action
  84963. * @param pointerX The X mouse cursor position at the time of the event
  84964. * @param pointerY The Y mouse cursor position at the time of the event
  84965. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  84966. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  84967. * @param additionalData additional data for the event
  84968. */
  84969. constructor(
  84970. /** The mesh or sprite that triggered the action */
  84971. source: any,
  84972. /** The X mouse cursor position at the time of the event */
  84973. pointerX: number,
  84974. /** The Y mouse cursor position at the time of the event */
  84975. pointerY: number,
  84976. /** The mesh that is currently pointed at (can be null) */
  84977. meshUnderPointer: Nullable<AbstractMesh>,
  84978. /** the original (browser) event that triggered the ActionEvent */
  84979. sourceEvent?: any,
  84980. /** additional data for the event */
  84981. additionalData?: any);
  84982. /**
  84983. * Helper function to auto-create an ActionEvent from a source mesh.
  84984. * @param source The source mesh that triggered the event
  84985. * @param evt The original (browser) event
  84986. * @param additionalData additional data for the event
  84987. * @returns the new ActionEvent
  84988. */
  84989. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  84990. /**
  84991. * Helper function to auto-create an ActionEvent from a source sprite
  84992. * @param source The source sprite that triggered the event
  84993. * @param scene Scene associated with the sprite
  84994. * @param evt The original (browser) event
  84995. * @param additionalData additional data for the event
  84996. * @returns the new ActionEvent
  84997. */
  84998. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84999. /**
  85000. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  85001. * @param scene the scene where the event occurred
  85002. * @param evt The original (browser) event
  85003. * @returns the new ActionEvent
  85004. */
  85005. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  85006. /**
  85007. * Helper function to auto-create an ActionEvent from a primitive
  85008. * @param prim defines the target primitive
  85009. * @param pointerPos defines the pointer position
  85010. * @param evt The original (browser) event
  85011. * @param additionalData additional data for the event
  85012. * @returns the new ActionEvent
  85013. */
  85014. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  85015. }
  85016. }
  85017. declare module BABYLON {
  85018. /**
  85019. * Abstract class used to decouple action Manager from scene and meshes.
  85020. * Do not instantiate.
  85021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  85022. */
  85023. export abstract class AbstractActionManager implements IDisposable {
  85024. /** Gets the list of active triggers */
  85025. static Triggers: {
  85026. [key: string]: number;
  85027. };
  85028. /** Gets the cursor to use when hovering items */
  85029. hoverCursor: string;
  85030. /** Gets the list of actions */
  85031. actions: IAction[];
  85032. /**
  85033. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  85034. */
  85035. isRecursive: boolean;
  85036. /**
  85037. * Releases all associated resources
  85038. */
  85039. abstract dispose(): void;
  85040. /**
  85041. * Does this action manager has pointer triggers
  85042. */
  85043. abstract readonly hasPointerTriggers: boolean;
  85044. /**
  85045. * Does this action manager has pick triggers
  85046. */
  85047. abstract readonly hasPickTriggers: boolean;
  85048. /**
  85049. * Process a specific trigger
  85050. * @param trigger defines the trigger to process
  85051. * @param evt defines the event details to be processed
  85052. */
  85053. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  85054. /**
  85055. * Does this action manager handles actions of any of the given triggers
  85056. * @param triggers defines the triggers to be tested
  85057. * @return a boolean indicating whether one (or more) of the triggers is handled
  85058. */
  85059. abstract hasSpecificTriggers(triggers: number[]): boolean;
  85060. /**
  85061. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  85062. * speed.
  85063. * @param triggerA defines the trigger to be tested
  85064. * @param triggerB defines the trigger to be tested
  85065. * @return a boolean indicating whether one (or more) of the triggers is handled
  85066. */
  85067. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  85068. /**
  85069. * Does this action manager handles actions of a given trigger
  85070. * @param trigger defines the trigger to be tested
  85071. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  85072. * @return whether the trigger is handled
  85073. */
  85074. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  85075. /**
  85076. * Serialize this manager to a JSON object
  85077. * @param name defines the property name to store this manager
  85078. * @returns a JSON representation of this manager
  85079. */
  85080. abstract serialize(name: string): any;
  85081. /**
  85082. * Registers an action to this action manager
  85083. * @param action defines the action to be registered
  85084. * @return the action amended (prepared) after registration
  85085. */
  85086. abstract registerAction(action: IAction): Nullable<IAction>;
  85087. /**
  85088. * Unregisters an action to this action manager
  85089. * @param action defines the action to be unregistered
  85090. * @return a boolean indicating whether the action has been unregistered
  85091. */
  85092. abstract unregisterAction(action: IAction): Boolean;
  85093. /**
  85094. * Does exist one action manager with at least one trigger
  85095. **/
  85096. static readonly HasTriggers: boolean;
  85097. /**
  85098. * Does exist one action manager with at least one pick trigger
  85099. **/
  85100. static readonly HasPickTriggers: boolean;
  85101. /**
  85102. * Does exist one action manager that handles actions of a given trigger
  85103. * @param trigger defines the trigger to be tested
  85104. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  85105. **/
  85106. static HasSpecificTrigger(trigger: number): boolean;
  85107. }
  85108. }
  85109. declare module BABYLON {
  85110. /**
  85111. * Defines how a node can be built from a string name.
  85112. */
  85113. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  85114. /**
  85115. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  85116. */
  85117. export class Node implements IBehaviorAware<Node> {
  85118. /** @hidden */
  85119. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  85120. private static _NodeConstructors;
  85121. /**
  85122. * Add a new node constructor
  85123. * @param type defines the type name of the node to construct
  85124. * @param constructorFunc defines the constructor function
  85125. */
  85126. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  85127. /**
  85128. * Returns a node constructor based on type name
  85129. * @param type defines the type name
  85130. * @param name defines the new node name
  85131. * @param scene defines the hosting scene
  85132. * @param options defines optional options to transmit to constructors
  85133. * @returns the new constructor or null
  85134. */
  85135. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  85136. /**
  85137. * Gets or sets the name of the node
  85138. */
  85139. name: string;
  85140. /**
  85141. * Gets or sets the id of the node
  85142. */
  85143. id: string;
  85144. /**
  85145. * Gets or sets the unique id of the node
  85146. */
  85147. uniqueId: number;
  85148. /**
  85149. * Gets or sets a string used to store user defined state for the node
  85150. */
  85151. state: string;
  85152. /**
  85153. * Gets or sets an object used to store user defined information for the node
  85154. */
  85155. metadata: any;
  85156. /**
  85157. * For internal use only. Please do not use.
  85158. */
  85159. reservedDataStore: any;
  85160. /**
  85161. * List of inspectable custom properties (used by the Inspector)
  85162. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85163. */
  85164. inspectableCustomProperties: IInspectable[];
  85165. /**
  85166. * Gets or sets a boolean used to define if the node must be serialized
  85167. */
  85168. doNotSerialize: boolean;
  85169. /** @hidden */
  85170. _isDisposed: boolean;
  85171. /**
  85172. * Gets a list of Animations associated with the node
  85173. */
  85174. animations: Animation[];
  85175. protected _ranges: {
  85176. [name: string]: Nullable<AnimationRange>;
  85177. };
  85178. /**
  85179. * Callback raised when the node is ready to be used
  85180. */
  85181. onReady: Nullable<(node: Node) => void>;
  85182. private _isEnabled;
  85183. private _isParentEnabled;
  85184. private _isReady;
  85185. /** @hidden */
  85186. _currentRenderId: number;
  85187. private _parentUpdateId;
  85188. /** @hidden */
  85189. _childUpdateId: number;
  85190. /** @hidden */
  85191. _waitingParentId: Nullable<string>;
  85192. /** @hidden */
  85193. _scene: Scene;
  85194. /** @hidden */
  85195. _cache: any;
  85196. private _parentNode;
  85197. private _children;
  85198. /** @hidden */
  85199. _worldMatrix: Matrix;
  85200. /** @hidden */
  85201. _worldMatrixDeterminant: number;
  85202. /** @hidden */
  85203. _worldMatrixDeterminantIsDirty: boolean;
  85204. /** @hidden */
  85205. private _sceneRootNodesIndex;
  85206. /**
  85207. * Gets a boolean indicating if the node has been disposed
  85208. * @returns true if the node was disposed
  85209. */
  85210. isDisposed(): boolean;
  85211. /**
  85212. * Gets or sets the parent of the node (without keeping the current position in the scene)
  85213. * @see https://doc.babylonjs.com/how_to/parenting
  85214. */
  85215. parent: Nullable<Node>;
  85216. private addToSceneRootNodes;
  85217. private removeFromSceneRootNodes;
  85218. private _animationPropertiesOverride;
  85219. /**
  85220. * Gets or sets the animation properties override
  85221. */
  85222. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85223. /**
  85224. * Gets a string idenfifying the name of the class
  85225. * @returns "Node" string
  85226. */
  85227. getClassName(): string;
  85228. /** @hidden */
  85229. readonly _isNode: boolean;
  85230. /**
  85231. * An event triggered when the mesh is disposed
  85232. */
  85233. onDisposeObservable: Observable<Node>;
  85234. private _onDisposeObserver;
  85235. /**
  85236. * Sets a callback that will be raised when the node will be disposed
  85237. */
  85238. onDispose: () => void;
  85239. /**
  85240. * Creates a new Node
  85241. * @param name the name and id to be given to this node
  85242. * @param scene the scene this node will be added to
  85243. * @param addToRootNodes the node will be added to scene.rootNodes
  85244. */
  85245. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  85246. /**
  85247. * Gets the scene of the node
  85248. * @returns a scene
  85249. */
  85250. getScene(): Scene;
  85251. /**
  85252. * Gets the engine of the node
  85253. * @returns a Engine
  85254. */
  85255. getEngine(): Engine;
  85256. private _behaviors;
  85257. /**
  85258. * Attach a behavior to the node
  85259. * @see http://doc.babylonjs.com/features/behaviour
  85260. * @param behavior defines the behavior to attach
  85261. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  85262. * @returns the current Node
  85263. */
  85264. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  85265. /**
  85266. * Remove an attached behavior
  85267. * @see http://doc.babylonjs.com/features/behaviour
  85268. * @param behavior defines the behavior to attach
  85269. * @returns the current Node
  85270. */
  85271. removeBehavior(behavior: Behavior<Node>): Node;
  85272. /**
  85273. * Gets the list of attached behaviors
  85274. * @see http://doc.babylonjs.com/features/behaviour
  85275. */
  85276. readonly behaviors: Behavior<Node>[];
  85277. /**
  85278. * Gets an attached behavior by name
  85279. * @param name defines the name of the behavior to look for
  85280. * @see http://doc.babylonjs.com/features/behaviour
  85281. * @returns null if behavior was not found else the requested behavior
  85282. */
  85283. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  85284. /**
  85285. * Returns the latest update of the World matrix
  85286. * @returns a Matrix
  85287. */
  85288. getWorldMatrix(): Matrix;
  85289. /** @hidden */
  85290. _getWorldMatrixDeterminant(): number;
  85291. /**
  85292. * Returns directly the latest state of the mesh World matrix.
  85293. * A Matrix is returned.
  85294. */
  85295. readonly worldMatrixFromCache: Matrix;
  85296. /** @hidden */
  85297. _initCache(): void;
  85298. /** @hidden */
  85299. updateCache(force?: boolean): void;
  85300. /** @hidden */
  85301. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  85302. /** @hidden */
  85303. _updateCache(ignoreParentClass?: boolean): void;
  85304. /** @hidden */
  85305. _isSynchronized(): boolean;
  85306. /** @hidden */
  85307. _markSyncedWithParent(): void;
  85308. /** @hidden */
  85309. isSynchronizedWithParent(): boolean;
  85310. /** @hidden */
  85311. isSynchronized(): boolean;
  85312. /**
  85313. * Is this node ready to be used/rendered
  85314. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85315. * @return true if the node is ready
  85316. */
  85317. isReady(completeCheck?: boolean): boolean;
  85318. /**
  85319. * Is this node enabled?
  85320. * 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
  85321. * @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
  85322. * @return whether this node (and its parent) is enabled
  85323. */
  85324. isEnabled(checkAncestors?: boolean): boolean;
  85325. /** @hidden */
  85326. protected _syncParentEnabledState(): void;
  85327. /**
  85328. * Set the enabled state of this node
  85329. * @param value defines the new enabled state
  85330. */
  85331. setEnabled(value: boolean): void;
  85332. /**
  85333. * Is this node a descendant of the given node?
  85334. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  85335. * @param ancestor defines the parent node to inspect
  85336. * @returns a boolean indicating if this node is a descendant of the given node
  85337. */
  85338. isDescendantOf(ancestor: Node): boolean;
  85339. /** @hidden */
  85340. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  85341. /**
  85342. * Will return all nodes that have this node as ascendant
  85343. * @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
  85344. * @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
  85345. * @return all children nodes of all types
  85346. */
  85347. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  85348. /**
  85349. * Get all child-meshes of this node
  85350. * @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)
  85351. * @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
  85352. * @returns an array of AbstractMesh
  85353. */
  85354. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  85355. /**
  85356. * Get all direct children of this node
  85357. * @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
  85358. * @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)
  85359. * @returns an array of Node
  85360. */
  85361. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  85362. /** @hidden */
  85363. _setReady(state: boolean): void;
  85364. /**
  85365. * Get an animation by name
  85366. * @param name defines the name of the animation to look for
  85367. * @returns null if not found else the requested animation
  85368. */
  85369. getAnimationByName(name: string): Nullable<Animation>;
  85370. /**
  85371. * Creates an animation range for this node
  85372. * @param name defines the name of the range
  85373. * @param from defines the starting key
  85374. * @param to defines the end key
  85375. */
  85376. createAnimationRange(name: string, from: number, to: number): void;
  85377. /**
  85378. * Delete a specific animation range
  85379. * @param name defines the name of the range to delete
  85380. * @param deleteFrames defines if animation frames from the range must be deleted as well
  85381. */
  85382. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  85383. /**
  85384. * Get an animation range by name
  85385. * @param name defines the name of the animation range to look for
  85386. * @returns null if not found else the requested animation range
  85387. */
  85388. getAnimationRange(name: string): Nullable<AnimationRange>;
  85389. /**
  85390. * Gets the list of all animation ranges defined on this node
  85391. * @returns an array
  85392. */
  85393. getAnimationRanges(): Nullable<AnimationRange>[];
  85394. /**
  85395. * Will start the animation sequence
  85396. * @param name defines the range frames for animation sequence
  85397. * @param loop defines if the animation should loop (false by default)
  85398. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  85399. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  85400. * @returns the object created for this animation. If range does not exist, it will return null
  85401. */
  85402. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  85403. /**
  85404. * Serialize animation ranges into a JSON compatible object
  85405. * @returns serialization object
  85406. */
  85407. serializeAnimationRanges(): any;
  85408. /**
  85409. * Computes the world matrix of the node
  85410. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85411. * @returns the world matrix
  85412. */
  85413. computeWorldMatrix(force?: boolean): Matrix;
  85414. /**
  85415. * Releases resources associated with this node.
  85416. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85417. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85418. */
  85419. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85420. /**
  85421. * Parse animation range data from a serialization object and store them into a given node
  85422. * @param node defines where to store the animation ranges
  85423. * @param parsedNode defines the serialization object to read data from
  85424. * @param scene defines the hosting scene
  85425. */
  85426. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  85427. /**
  85428. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  85429. * @param includeDescendants Include bounding info from descendants as well (true by default)
  85430. * @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
  85431. * @returns the new bounding vectors
  85432. */
  85433. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  85434. min: Vector3;
  85435. max: Vector3;
  85436. };
  85437. }
  85438. }
  85439. declare module BABYLON {
  85440. /**
  85441. * @hidden
  85442. */
  85443. export class _IAnimationState {
  85444. key: number;
  85445. repeatCount: number;
  85446. workValue?: any;
  85447. loopMode?: number;
  85448. offsetValue?: any;
  85449. highLimitValue?: any;
  85450. }
  85451. /**
  85452. * Class used to store any kind of animation
  85453. */
  85454. export class Animation {
  85455. /**Name of the animation */
  85456. name: string;
  85457. /**Property to animate */
  85458. targetProperty: string;
  85459. /**The frames per second of the animation */
  85460. framePerSecond: number;
  85461. /**The data type of the animation */
  85462. dataType: number;
  85463. /**The loop mode of the animation */
  85464. loopMode?: number | undefined;
  85465. /**Specifies if blending should be enabled */
  85466. enableBlending?: boolean | undefined;
  85467. /**
  85468. * Use matrix interpolation instead of using direct key value when animating matrices
  85469. */
  85470. static AllowMatricesInterpolation: boolean;
  85471. /**
  85472. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  85473. */
  85474. static AllowMatrixDecomposeForInterpolation: boolean;
  85475. /**
  85476. * Stores the key frames of the animation
  85477. */
  85478. private _keys;
  85479. /**
  85480. * Stores the easing function of the animation
  85481. */
  85482. private _easingFunction;
  85483. /**
  85484. * @hidden Internal use only
  85485. */
  85486. _runtimeAnimations: RuntimeAnimation[];
  85487. /**
  85488. * The set of event that will be linked to this animation
  85489. */
  85490. private _events;
  85491. /**
  85492. * Stores an array of target property paths
  85493. */
  85494. targetPropertyPath: string[];
  85495. /**
  85496. * Stores the blending speed of the animation
  85497. */
  85498. blendingSpeed: number;
  85499. /**
  85500. * Stores the animation ranges for the animation
  85501. */
  85502. private _ranges;
  85503. /**
  85504. * @hidden Internal use
  85505. */
  85506. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  85507. /**
  85508. * Sets up an animation
  85509. * @param property The property to animate
  85510. * @param animationType The animation type to apply
  85511. * @param framePerSecond The frames per second of the animation
  85512. * @param easingFunction The easing function used in the animation
  85513. * @returns The created animation
  85514. */
  85515. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  85516. /**
  85517. * Create and start an animation on a node
  85518. * @param name defines the name of the global animation that will be run on all nodes
  85519. * @param node defines the root node where the animation will take place
  85520. * @param targetProperty defines property to animate
  85521. * @param framePerSecond defines the number of frame per second yo use
  85522. * @param totalFrame defines the number of frames in total
  85523. * @param from defines the initial value
  85524. * @param to defines the final value
  85525. * @param loopMode defines which loop mode you want to use (off by default)
  85526. * @param easingFunction defines the easing function to use (linear by default)
  85527. * @param onAnimationEnd defines the callback to call when animation end
  85528. * @returns the animatable created for this animation
  85529. */
  85530. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85531. /**
  85532. * Create and start an animation on a node and its descendants
  85533. * @param name defines the name of the global animation that will be run on all nodes
  85534. * @param node defines the root node where the animation will take place
  85535. * @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
  85536. * @param targetProperty defines property to animate
  85537. * @param framePerSecond defines the number of frame per second to use
  85538. * @param totalFrame defines the number of frames in total
  85539. * @param from defines the initial value
  85540. * @param to defines the final value
  85541. * @param loopMode defines which loop mode you want to use (off by default)
  85542. * @param easingFunction defines the easing function to use (linear by default)
  85543. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85544. * @returns the list of animatables created for all nodes
  85545. * @example https://www.babylonjs-playground.com/#MH0VLI
  85546. */
  85547. 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[]>;
  85548. /**
  85549. * Creates a new animation, merges it with the existing animations and starts it
  85550. * @param name Name of the animation
  85551. * @param node Node which contains the scene that begins the animations
  85552. * @param targetProperty Specifies which property to animate
  85553. * @param framePerSecond The frames per second of the animation
  85554. * @param totalFrame The total number of frames
  85555. * @param from The frame at the beginning of the animation
  85556. * @param to The frame at the end of the animation
  85557. * @param loopMode Specifies the loop mode of the animation
  85558. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  85559. * @param onAnimationEnd Callback to run once the animation is complete
  85560. * @returns Nullable animation
  85561. */
  85562. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85563. /**
  85564. * Transition property of an host to the target Value
  85565. * @param property The property to transition
  85566. * @param targetValue The target Value of the property
  85567. * @param host The object where the property to animate belongs
  85568. * @param scene Scene used to run the animation
  85569. * @param frameRate Framerate (in frame/s) to use
  85570. * @param transition The transition type we want to use
  85571. * @param duration The duration of the animation, in milliseconds
  85572. * @param onAnimationEnd Callback trigger at the end of the animation
  85573. * @returns Nullable animation
  85574. */
  85575. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  85576. /**
  85577. * Return the array of runtime animations currently using this animation
  85578. */
  85579. readonly runtimeAnimations: RuntimeAnimation[];
  85580. /**
  85581. * Specifies if any of the runtime animations are currently running
  85582. */
  85583. readonly hasRunningRuntimeAnimations: boolean;
  85584. /**
  85585. * Initializes the animation
  85586. * @param name Name of the animation
  85587. * @param targetProperty Property to animate
  85588. * @param framePerSecond The frames per second of the animation
  85589. * @param dataType The data type of the animation
  85590. * @param loopMode The loop mode of the animation
  85591. * @param enableBlending Specifies if blending should be enabled
  85592. */
  85593. constructor(
  85594. /**Name of the animation */
  85595. name: string,
  85596. /**Property to animate */
  85597. targetProperty: string,
  85598. /**The frames per second of the animation */
  85599. framePerSecond: number,
  85600. /**The data type of the animation */
  85601. dataType: number,
  85602. /**The loop mode of the animation */
  85603. loopMode?: number | undefined,
  85604. /**Specifies if blending should be enabled */
  85605. enableBlending?: boolean | undefined);
  85606. /**
  85607. * Converts the animation to a string
  85608. * @param fullDetails support for multiple levels of logging within scene loading
  85609. * @returns String form of the animation
  85610. */
  85611. toString(fullDetails?: boolean): string;
  85612. /**
  85613. * Add an event to this animation
  85614. * @param event Event to add
  85615. */
  85616. addEvent(event: AnimationEvent): void;
  85617. /**
  85618. * Remove all events found at the given frame
  85619. * @param frame The frame to remove events from
  85620. */
  85621. removeEvents(frame: number): void;
  85622. /**
  85623. * Retrieves all the events from the animation
  85624. * @returns Events from the animation
  85625. */
  85626. getEvents(): AnimationEvent[];
  85627. /**
  85628. * Creates an animation range
  85629. * @param name Name of the animation range
  85630. * @param from Starting frame of the animation range
  85631. * @param to Ending frame of the animation
  85632. */
  85633. createRange(name: string, from: number, to: number): void;
  85634. /**
  85635. * Deletes an animation range by name
  85636. * @param name Name of the animation range to delete
  85637. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  85638. */
  85639. deleteRange(name: string, deleteFrames?: boolean): void;
  85640. /**
  85641. * Gets the animation range by name, or null if not defined
  85642. * @param name Name of the animation range
  85643. * @returns Nullable animation range
  85644. */
  85645. getRange(name: string): Nullable<AnimationRange>;
  85646. /**
  85647. * Gets the key frames from the animation
  85648. * @returns The key frames of the animation
  85649. */
  85650. getKeys(): Array<IAnimationKey>;
  85651. /**
  85652. * Gets the highest frame rate of the animation
  85653. * @returns Highest frame rate of the animation
  85654. */
  85655. getHighestFrame(): number;
  85656. /**
  85657. * Gets the easing function of the animation
  85658. * @returns Easing function of the animation
  85659. */
  85660. getEasingFunction(): IEasingFunction;
  85661. /**
  85662. * Sets the easing function of the animation
  85663. * @param easingFunction A custom mathematical formula for animation
  85664. */
  85665. setEasingFunction(easingFunction: EasingFunction): void;
  85666. /**
  85667. * Interpolates a scalar linearly
  85668. * @param startValue Start value of the animation curve
  85669. * @param endValue End value of the animation curve
  85670. * @param gradient Scalar amount to interpolate
  85671. * @returns Interpolated scalar value
  85672. */
  85673. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  85674. /**
  85675. * Interpolates a scalar cubically
  85676. * @param startValue Start value of the animation curve
  85677. * @param outTangent End tangent of the animation
  85678. * @param endValue End value of the animation curve
  85679. * @param inTangent Start tangent of the animation curve
  85680. * @param gradient Scalar amount to interpolate
  85681. * @returns Interpolated scalar value
  85682. */
  85683. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  85684. /**
  85685. * Interpolates a quaternion using a spherical linear interpolation
  85686. * @param startValue Start value of the animation curve
  85687. * @param endValue End value of the animation curve
  85688. * @param gradient Scalar amount to interpolate
  85689. * @returns Interpolated quaternion value
  85690. */
  85691. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  85692. /**
  85693. * Interpolates a quaternion cubically
  85694. * @param startValue Start value of the animation curve
  85695. * @param outTangent End tangent of the animation curve
  85696. * @param endValue End value of the animation curve
  85697. * @param inTangent Start tangent of the animation curve
  85698. * @param gradient Scalar amount to interpolate
  85699. * @returns Interpolated quaternion value
  85700. */
  85701. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  85702. /**
  85703. * Interpolates a Vector3 linearl
  85704. * @param startValue Start value of the animation curve
  85705. * @param endValue End value of the animation curve
  85706. * @param gradient Scalar amount to interpolate
  85707. * @returns Interpolated scalar value
  85708. */
  85709. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  85710. /**
  85711. * Interpolates a Vector3 cubically
  85712. * @param startValue Start value of the animation curve
  85713. * @param outTangent End tangent of the animation
  85714. * @param endValue End value of the animation curve
  85715. * @param inTangent Start tangent of the animation curve
  85716. * @param gradient Scalar amount to interpolate
  85717. * @returns InterpolatedVector3 value
  85718. */
  85719. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  85720. /**
  85721. * Interpolates a Vector2 linearly
  85722. * @param startValue Start value of the animation curve
  85723. * @param endValue End value of the animation curve
  85724. * @param gradient Scalar amount to interpolate
  85725. * @returns Interpolated Vector2 value
  85726. */
  85727. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  85728. /**
  85729. * Interpolates a Vector2 cubically
  85730. * @param startValue Start value of the animation curve
  85731. * @param outTangent End tangent of the animation
  85732. * @param endValue End value of the animation curve
  85733. * @param inTangent Start tangent of the animation curve
  85734. * @param gradient Scalar amount to interpolate
  85735. * @returns Interpolated Vector2 value
  85736. */
  85737. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  85738. /**
  85739. * Interpolates a size linearly
  85740. * @param startValue Start value of the animation curve
  85741. * @param endValue End value of the animation curve
  85742. * @param gradient Scalar amount to interpolate
  85743. * @returns Interpolated Size value
  85744. */
  85745. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  85746. /**
  85747. * Interpolates a Color3 linearly
  85748. * @param startValue Start value of the animation curve
  85749. * @param endValue End value of the animation curve
  85750. * @param gradient Scalar amount to interpolate
  85751. * @returns Interpolated Color3 value
  85752. */
  85753. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  85754. /**
  85755. * @hidden Internal use only
  85756. */
  85757. _getKeyValue(value: any): any;
  85758. /**
  85759. * @hidden Internal use only
  85760. */
  85761. _interpolate(currentFrame: number, state: _IAnimationState): any;
  85762. /**
  85763. * Defines the function to use to interpolate matrices
  85764. * @param startValue defines the start matrix
  85765. * @param endValue defines the end matrix
  85766. * @param gradient defines the gradient between both matrices
  85767. * @param result defines an optional target matrix where to store the interpolation
  85768. * @returns the interpolated matrix
  85769. */
  85770. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  85771. /**
  85772. * Makes a copy of the animation
  85773. * @returns Cloned animation
  85774. */
  85775. clone(): Animation;
  85776. /**
  85777. * Sets the key frames of the animation
  85778. * @param values The animation key frames to set
  85779. */
  85780. setKeys(values: Array<IAnimationKey>): void;
  85781. /**
  85782. * Serializes the animation to an object
  85783. * @returns Serialized object
  85784. */
  85785. serialize(): any;
  85786. /**
  85787. * Float animation type
  85788. */
  85789. private static _ANIMATIONTYPE_FLOAT;
  85790. /**
  85791. * Vector3 animation type
  85792. */
  85793. private static _ANIMATIONTYPE_VECTOR3;
  85794. /**
  85795. * Quaternion animation type
  85796. */
  85797. private static _ANIMATIONTYPE_QUATERNION;
  85798. /**
  85799. * Matrix animation type
  85800. */
  85801. private static _ANIMATIONTYPE_MATRIX;
  85802. /**
  85803. * Color3 animation type
  85804. */
  85805. private static _ANIMATIONTYPE_COLOR3;
  85806. /**
  85807. * Vector2 animation type
  85808. */
  85809. private static _ANIMATIONTYPE_VECTOR2;
  85810. /**
  85811. * Size animation type
  85812. */
  85813. private static _ANIMATIONTYPE_SIZE;
  85814. /**
  85815. * Relative Loop Mode
  85816. */
  85817. private static _ANIMATIONLOOPMODE_RELATIVE;
  85818. /**
  85819. * Cycle Loop Mode
  85820. */
  85821. private static _ANIMATIONLOOPMODE_CYCLE;
  85822. /**
  85823. * Constant Loop Mode
  85824. */
  85825. private static _ANIMATIONLOOPMODE_CONSTANT;
  85826. /**
  85827. * Get the float animation type
  85828. */
  85829. static readonly ANIMATIONTYPE_FLOAT: number;
  85830. /**
  85831. * Get the Vector3 animation type
  85832. */
  85833. static readonly ANIMATIONTYPE_VECTOR3: number;
  85834. /**
  85835. * Get the Vector2 animation type
  85836. */
  85837. static readonly ANIMATIONTYPE_VECTOR2: number;
  85838. /**
  85839. * Get the Size animation type
  85840. */
  85841. static readonly ANIMATIONTYPE_SIZE: number;
  85842. /**
  85843. * Get the Quaternion animation type
  85844. */
  85845. static readonly ANIMATIONTYPE_QUATERNION: number;
  85846. /**
  85847. * Get the Matrix animation type
  85848. */
  85849. static readonly ANIMATIONTYPE_MATRIX: number;
  85850. /**
  85851. * Get the Color3 animation type
  85852. */
  85853. static readonly ANIMATIONTYPE_COLOR3: number;
  85854. /**
  85855. * Get the Relative Loop Mode
  85856. */
  85857. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  85858. /**
  85859. * Get the Cycle Loop Mode
  85860. */
  85861. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  85862. /**
  85863. * Get the Constant Loop Mode
  85864. */
  85865. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  85866. /** @hidden */
  85867. static _UniversalLerp(left: any, right: any, amount: number): any;
  85868. /**
  85869. * Parses an animation object and creates an animation
  85870. * @param parsedAnimation Parsed animation object
  85871. * @returns Animation object
  85872. */
  85873. static Parse(parsedAnimation: any): Animation;
  85874. /**
  85875. * Appends the serialized animations from the source animations
  85876. * @param source Source containing the animations
  85877. * @param destination Target to store the animations
  85878. */
  85879. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85880. }
  85881. }
  85882. declare module BABYLON {
  85883. /**
  85884. * Base class of all the textures in babylon.
  85885. * It groups all the common properties the materials, post process, lights... might need
  85886. * in order to make a correct use of the texture.
  85887. */
  85888. export class BaseTexture implements IAnimatable {
  85889. /**
  85890. * Default anisotropic filtering level for the application.
  85891. * It is set to 4 as a good tradeoff between perf and quality.
  85892. */
  85893. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  85894. /**
  85895. * Gets or sets the unique id of the texture
  85896. */
  85897. uniqueId: number;
  85898. /**
  85899. * Define the name of the texture.
  85900. */
  85901. name: string;
  85902. /**
  85903. * Gets or sets an object used to store user defined information.
  85904. */
  85905. metadata: any;
  85906. /**
  85907. * For internal use only. Please do not use.
  85908. */
  85909. reservedDataStore: any;
  85910. private _hasAlpha;
  85911. /**
  85912. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  85913. */
  85914. hasAlpha: boolean;
  85915. /**
  85916. * Defines if the alpha value should be determined via the rgb values.
  85917. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  85918. */
  85919. getAlphaFromRGB: boolean;
  85920. /**
  85921. * Intensity or strength of the texture.
  85922. * It is commonly used by materials to fine tune the intensity of the texture
  85923. */
  85924. level: number;
  85925. /**
  85926. * Define the UV chanel to use starting from 0 and defaulting to 0.
  85927. * This is part of the texture as textures usually maps to one uv set.
  85928. */
  85929. coordinatesIndex: number;
  85930. private _coordinatesMode;
  85931. /**
  85932. * How a texture is mapped.
  85933. *
  85934. * | Value | Type | Description |
  85935. * | ----- | ----------------------------------- | ----------- |
  85936. * | 0 | EXPLICIT_MODE | |
  85937. * | 1 | SPHERICAL_MODE | |
  85938. * | 2 | PLANAR_MODE | |
  85939. * | 3 | CUBIC_MODE | |
  85940. * | 4 | PROJECTION_MODE | |
  85941. * | 5 | SKYBOX_MODE | |
  85942. * | 6 | INVCUBIC_MODE | |
  85943. * | 7 | EQUIRECTANGULAR_MODE | |
  85944. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  85945. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  85946. */
  85947. coordinatesMode: number;
  85948. /**
  85949. * | Value | Type | Description |
  85950. * | ----- | ------------------ | ----------- |
  85951. * | 0 | CLAMP_ADDRESSMODE | |
  85952. * | 1 | WRAP_ADDRESSMODE | |
  85953. * | 2 | MIRROR_ADDRESSMODE | |
  85954. */
  85955. wrapU: number;
  85956. /**
  85957. * | Value | Type | Description |
  85958. * | ----- | ------------------ | ----------- |
  85959. * | 0 | CLAMP_ADDRESSMODE | |
  85960. * | 1 | WRAP_ADDRESSMODE | |
  85961. * | 2 | MIRROR_ADDRESSMODE | |
  85962. */
  85963. wrapV: number;
  85964. /**
  85965. * | Value | Type | Description |
  85966. * | ----- | ------------------ | ----------- |
  85967. * | 0 | CLAMP_ADDRESSMODE | |
  85968. * | 1 | WRAP_ADDRESSMODE | |
  85969. * | 2 | MIRROR_ADDRESSMODE | |
  85970. */
  85971. wrapR: number;
  85972. /**
  85973. * With compliant hardware and browser (supporting anisotropic filtering)
  85974. * this defines the level of anisotropic filtering in the texture.
  85975. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  85976. */
  85977. anisotropicFilteringLevel: number;
  85978. /**
  85979. * Define if the texture is a cube texture or if false a 2d texture.
  85980. */
  85981. isCube: boolean;
  85982. /**
  85983. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  85984. */
  85985. is3D: boolean;
  85986. /**
  85987. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  85988. * HDR texture are usually stored in linear space.
  85989. * This only impacts the PBR and Background materials
  85990. */
  85991. gammaSpace: boolean;
  85992. /**
  85993. * Gets whether or not the texture contains RGBD data.
  85994. */
  85995. readonly isRGBD: boolean;
  85996. /**
  85997. * Is Z inverted in the texture (useful in a cube texture).
  85998. */
  85999. invertZ: boolean;
  86000. /**
  86001. * Are mip maps generated for this texture or not.
  86002. */
  86003. readonly noMipmap: boolean;
  86004. /**
  86005. * @hidden
  86006. */
  86007. lodLevelInAlpha: boolean;
  86008. /**
  86009. * With prefiltered texture, defined the offset used during the prefiltering steps.
  86010. */
  86011. lodGenerationOffset: number;
  86012. /**
  86013. * With prefiltered texture, defined the scale used during the prefiltering steps.
  86014. */
  86015. lodGenerationScale: number;
  86016. /**
  86017. * Define if the texture is a render target.
  86018. */
  86019. isRenderTarget: boolean;
  86020. /**
  86021. * Define the unique id of the texture in the scene.
  86022. */
  86023. readonly uid: string;
  86024. /**
  86025. * Return a string representation of the texture.
  86026. * @returns the texture as a string
  86027. */
  86028. toString(): string;
  86029. /**
  86030. * Get the class name of the texture.
  86031. * @returns "BaseTexture"
  86032. */
  86033. getClassName(): string;
  86034. /**
  86035. * Define the list of animation attached to the texture.
  86036. */
  86037. animations: Animation[];
  86038. /**
  86039. * An event triggered when the texture is disposed.
  86040. */
  86041. onDisposeObservable: Observable<BaseTexture>;
  86042. private _onDisposeObserver;
  86043. /**
  86044. * Callback triggered when the texture has been disposed.
  86045. * Kept for back compatibility, you can use the onDisposeObservable instead.
  86046. */
  86047. onDispose: () => void;
  86048. /**
  86049. * Define the current state of the loading sequence when in delayed load mode.
  86050. */
  86051. delayLoadState: number;
  86052. private _scene;
  86053. /** @hidden */
  86054. _texture: Nullable<InternalTexture>;
  86055. private _uid;
  86056. /**
  86057. * Define if the texture is preventinga material to render or not.
  86058. * If not and the texture is not ready, the engine will use a default black texture instead.
  86059. */
  86060. readonly isBlocking: boolean;
  86061. /**
  86062. * Instantiates a new BaseTexture.
  86063. * Base class of all the textures in babylon.
  86064. * It groups all the common properties the materials, post process, lights... might need
  86065. * in order to make a correct use of the texture.
  86066. * @param scene Define the scene the texture blongs to
  86067. */
  86068. constructor(scene: Nullable<Scene>);
  86069. /**
  86070. * Get the scene the texture belongs to.
  86071. * @returns the scene or null if undefined
  86072. */
  86073. getScene(): Nullable<Scene>;
  86074. /**
  86075. * Get the texture transform matrix used to offset tile the texture for istance.
  86076. * @returns the transformation matrix
  86077. */
  86078. getTextureMatrix(): Matrix;
  86079. /**
  86080. * Get the texture reflection matrix used to rotate/transform the reflection.
  86081. * @returns the reflection matrix
  86082. */
  86083. getReflectionTextureMatrix(): Matrix;
  86084. /**
  86085. * Get the underlying lower level texture from Babylon.
  86086. * @returns the insternal texture
  86087. */
  86088. getInternalTexture(): Nullable<InternalTexture>;
  86089. /**
  86090. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  86091. * @returns true if ready or not blocking
  86092. */
  86093. isReadyOrNotBlocking(): boolean;
  86094. /**
  86095. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  86096. * @returns true if fully ready
  86097. */
  86098. isReady(): boolean;
  86099. private _cachedSize;
  86100. /**
  86101. * Get the size of the texture.
  86102. * @returns the texture size.
  86103. */
  86104. getSize(): ISize;
  86105. /**
  86106. * Get the base size of the texture.
  86107. * It can be different from the size if the texture has been resized for POT for instance
  86108. * @returns the base size
  86109. */
  86110. getBaseSize(): ISize;
  86111. /**
  86112. * Update the sampling mode of the texture.
  86113. * Default is Trilinear mode.
  86114. *
  86115. * | Value | Type | Description |
  86116. * | ----- | ------------------ | ----------- |
  86117. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  86118. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  86119. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  86120. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  86121. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  86122. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  86123. * | 7 | NEAREST_LINEAR | |
  86124. * | 8 | NEAREST_NEAREST | |
  86125. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  86126. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  86127. * | 11 | LINEAR_LINEAR | |
  86128. * | 12 | LINEAR_NEAREST | |
  86129. *
  86130. * > _mag_: magnification filter (close to the viewer)
  86131. * > _min_: minification filter (far from the viewer)
  86132. * > _mip_: filter used between mip map levels
  86133. *@param samplingMode Define the new sampling mode of the texture
  86134. */
  86135. updateSamplingMode(samplingMode: number): void;
  86136. /**
  86137. * Scales the texture if is `canRescale()`
  86138. * @param ratio the resize factor we want to use to rescale
  86139. */
  86140. scale(ratio: number): void;
  86141. /**
  86142. * Get if the texture can rescale.
  86143. */
  86144. readonly canRescale: boolean;
  86145. /** @hidden */
  86146. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  86147. /** @hidden */
  86148. _rebuild(): void;
  86149. /**
  86150. * Triggers the load sequence in delayed load mode.
  86151. */
  86152. delayLoad(): void;
  86153. /**
  86154. * Clones the texture.
  86155. * @returns the cloned texture
  86156. */
  86157. clone(): Nullable<BaseTexture>;
  86158. /**
  86159. * Get the texture underlying type (INT, FLOAT...)
  86160. */
  86161. readonly textureType: number;
  86162. /**
  86163. * Get the texture underlying format (RGB, RGBA...)
  86164. */
  86165. readonly textureFormat: number;
  86166. /**
  86167. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  86168. * This will returns an RGBA array buffer containing either in values (0-255) or
  86169. * float values (0-1) depending of the underlying buffer type.
  86170. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  86171. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  86172. * @param buffer defines a user defined buffer to fill with data (can be null)
  86173. * @returns The Array buffer containing the pixels data.
  86174. */
  86175. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  86176. /**
  86177. * Release and destroy the underlying lower level texture aka internalTexture.
  86178. */
  86179. releaseInternalTexture(): void;
  86180. /**
  86181. * Get the polynomial representation of the texture data.
  86182. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  86183. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  86184. */
  86185. sphericalPolynomial: Nullable<SphericalPolynomial>;
  86186. /** @hidden */
  86187. readonly _lodTextureHigh: Nullable<BaseTexture>;
  86188. /** @hidden */
  86189. readonly _lodTextureMid: Nullable<BaseTexture>;
  86190. /** @hidden */
  86191. readonly _lodTextureLow: Nullable<BaseTexture>;
  86192. /**
  86193. * Dispose the texture and release its associated resources.
  86194. */
  86195. dispose(): void;
  86196. /**
  86197. * Serialize the texture into a JSON representation that can be parsed later on.
  86198. * @returns the JSON representation of the texture
  86199. */
  86200. serialize(): any;
  86201. /**
  86202. * Helper function to be called back once a list of texture contains only ready textures.
  86203. * @param textures Define the list of textures to wait for
  86204. * @param callback Define the callback triggered once the entire list will be ready
  86205. */
  86206. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  86207. }
  86208. }
  86209. declare module BABYLON {
  86210. /**
  86211. * Uniform buffer objects.
  86212. *
  86213. * Handles blocks of uniform on the GPU.
  86214. *
  86215. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86216. *
  86217. * For more information, please refer to :
  86218. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86219. */
  86220. export class UniformBuffer {
  86221. private _engine;
  86222. private _buffer;
  86223. private _data;
  86224. private _bufferData;
  86225. private _dynamic?;
  86226. private _uniformLocations;
  86227. private _uniformSizes;
  86228. private _uniformLocationPointer;
  86229. private _needSync;
  86230. private _noUBO;
  86231. private _currentEffect;
  86232. private static _MAX_UNIFORM_SIZE;
  86233. private static _tempBuffer;
  86234. /**
  86235. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86236. * This is dynamic to allow compat with webgl 1 and 2.
  86237. * You will need to pass the name of the uniform as well as the value.
  86238. */
  86239. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86240. /**
  86241. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86242. * This is dynamic to allow compat with webgl 1 and 2.
  86243. * You will need to pass the name of the uniform as well as the value.
  86244. */
  86245. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86246. /**
  86247. * Lambda to Update a single float in a uniform buffer.
  86248. * This is dynamic to allow compat with webgl 1 and 2.
  86249. * You will need to pass the name of the uniform as well as the value.
  86250. */
  86251. updateFloat: (name: string, x: number) => void;
  86252. /**
  86253. * Lambda to Update a vec2 of float in a uniform buffer.
  86254. * This is dynamic to allow compat with webgl 1 and 2.
  86255. * You will need to pass the name of the uniform as well as the value.
  86256. */
  86257. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86258. /**
  86259. * Lambda to Update a vec3 of float in a uniform buffer.
  86260. * This is dynamic to allow compat with webgl 1 and 2.
  86261. * You will need to pass the name of the uniform as well as the value.
  86262. */
  86263. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86264. /**
  86265. * Lambda to Update a vec4 of float in a uniform buffer.
  86266. * This is dynamic to allow compat with webgl 1 and 2.
  86267. * You will need to pass the name of the uniform as well as the value.
  86268. */
  86269. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86270. /**
  86271. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86272. * This is dynamic to allow compat with webgl 1 and 2.
  86273. * You will need to pass the name of the uniform as well as the value.
  86274. */
  86275. updateMatrix: (name: string, mat: Matrix) => void;
  86276. /**
  86277. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86278. * This is dynamic to allow compat with webgl 1 and 2.
  86279. * You will need to pass the name of the uniform as well as the value.
  86280. */
  86281. updateVector3: (name: string, vector: Vector3) => void;
  86282. /**
  86283. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86284. * This is dynamic to allow compat with webgl 1 and 2.
  86285. * You will need to pass the name of the uniform as well as the value.
  86286. */
  86287. updateVector4: (name: string, vector: Vector4) => void;
  86288. /**
  86289. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86290. * This is dynamic to allow compat with webgl 1 and 2.
  86291. * You will need to pass the name of the uniform as well as the value.
  86292. */
  86293. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86294. /**
  86295. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86296. * This is dynamic to allow compat with webgl 1 and 2.
  86297. * You will need to pass the name of the uniform as well as the value.
  86298. */
  86299. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86300. /**
  86301. * Instantiates a new Uniform buffer objects.
  86302. *
  86303. * Handles blocks of uniform on the GPU.
  86304. *
  86305. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86306. *
  86307. * For more information, please refer to :
  86308. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86309. * @param engine Define the engine the buffer is associated with
  86310. * @param data Define the data contained in the buffer
  86311. * @param dynamic Define if the buffer is updatable
  86312. */
  86313. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86314. /**
  86315. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86316. * or just falling back on setUniformXXX calls.
  86317. */
  86318. readonly useUbo: boolean;
  86319. /**
  86320. * Indicates if the WebGL underlying uniform buffer is in sync
  86321. * with the javascript cache data.
  86322. */
  86323. readonly isSync: boolean;
  86324. /**
  86325. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86326. * Also, a dynamic UniformBuffer will disable cache verification and always
  86327. * update the underlying WebGL uniform buffer to the GPU.
  86328. * @returns if Dynamic, otherwise false
  86329. */
  86330. isDynamic(): boolean;
  86331. /**
  86332. * The data cache on JS side.
  86333. * @returns the underlying data as a float array
  86334. */
  86335. getData(): Float32Array;
  86336. /**
  86337. * The underlying WebGL Uniform buffer.
  86338. * @returns the webgl buffer
  86339. */
  86340. getBuffer(): Nullable<DataBuffer>;
  86341. /**
  86342. * std140 layout specifies how to align data within an UBO structure.
  86343. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86344. * for specs.
  86345. */
  86346. private _fillAlignment;
  86347. /**
  86348. * Adds an uniform in the buffer.
  86349. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86350. * for the layout to be correct !
  86351. * @param name Name of the uniform, as used in the uniform block in the shader.
  86352. * @param size Data size, or data directly.
  86353. */
  86354. addUniform(name: string, size: number | number[]): void;
  86355. /**
  86356. * Adds a Matrix 4x4 to the uniform buffer.
  86357. * @param name Name of the uniform, as used in the uniform block in the shader.
  86358. * @param mat A 4x4 matrix.
  86359. */
  86360. addMatrix(name: string, mat: Matrix): void;
  86361. /**
  86362. * Adds a vec2 to the uniform buffer.
  86363. * @param name Name of the uniform, as used in the uniform block in the shader.
  86364. * @param x Define the x component value of the vec2
  86365. * @param y Define the y component value of the vec2
  86366. */
  86367. addFloat2(name: string, x: number, y: number): void;
  86368. /**
  86369. * Adds a vec3 to the uniform buffer.
  86370. * @param name Name of the uniform, as used in the uniform block in the shader.
  86371. * @param x Define the x component value of the vec3
  86372. * @param y Define the y component value of the vec3
  86373. * @param z Define the z component value of the vec3
  86374. */
  86375. addFloat3(name: string, x: number, y: number, z: number): void;
  86376. /**
  86377. * Adds a vec3 to the uniform buffer.
  86378. * @param name Name of the uniform, as used in the uniform block in the shader.
  86379. * @param color Define the vec3 from a Color
  86380. */
  86381. addColor3(name: string, color: Color3): void;
  86382. /**
  86383. * Adds a vec4 to the uniform buffer.
  86384. * @param name Name of the uniform, as used in the uniform block in the shader.
  86385. * @param color Define the rgb components from a Color
  86386. * @param alpha Define the a component of the vec4
  86387. */
  86388. addColor4(name: string, color: Color3, alpha: number): void;
  86389. /**
  86390. * Adds a vec3 to the uniform buffer.
  86391. * @param name Name of the uniform, as used in the uniform block in the shader.
  86392. * @param vector Define the vec3 components from a Vector
  86393. */
  86394. addVector3(name: string, vector: Vector3): void;
  86395. /**
  86396. * Adds a Matrix 3x3 to the uniform buffer.
  86397. * @param name Name of the uniform, as used in the uniform block in the shader.
  86398. */
  86399. addMatrix3x3(name: string): void;
  86400. /**
  86401. * Adds a Matrix 2x2 to the uniform buffer.
  86402. * @param name Name of the uniform, as used in the uniform block in the shader.
  86403. */
  86404. addMatrix2x2(name: string): void;
  86405. /**
  86406. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86407. */
  86408. create(): void;
  86409. /** @hidden */
  86410. _rebuild(): void;
  86411. /**
  86412. * Updates the WebGL Uniform Buffer on the GPU.
  86413. * If the `dynamic` flag is set to true, no cache comparison is done.
  86414. * Otherwise, the buffer will be updated only if the cache differs.
  86415. */
  86416. update(): void;
  86417. /**
  86418. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86419. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86420. * @param data Define the flattened data
  86421. * @param size Define the size of the data.
  86422. */
  86423. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86424. private _updateMatrix3x3ForUniform;
  86425. private _updateMatrix3x3ForEffect;
  86426. private _updateMatrix2x2ForEffect;
  86427. private _updateMatrix2x2ForUniform;
  86428. private _updateFloatForEffect;
  86429. private _updateFloatForUniform;
  86430. private _updateFloat2ForEffect;
  86431. private _updateFloat2ForUniform;
  86432. private _updateFloat3ForEffect;
  86433. private _updateFloat3ForUniform;
  86434. private _updateFloat4ForEffect;
  86435. private _updateFloat4ForUniform;
  86436. private _updateMatrixForEffect;
  86437. private _updateMatrixForUniform;
  86438. private _updateVector3ForEffect;
  86439. private _updateVector3ForUniform;
  86440. private _updateVector4ForEffect;
  86441. private _updateVector4ForUniform;
  86442. private _updateColor3ForEffect;
  86443. private _updateColor3ForUniform;
  86444. private _updateColor4ForEffect;
  86445. private _updateColor4ForUniform;
  86446. /**
  86447. * Sets a sampler uniform on the effect.
  86448. * @param name Define the name of the sampler.
  86449. * @param texture Define the texture to set in the sampler
  86450. */
  86451. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86452. /**
  86453. * Directly updates the value of the uniform in the cache AND on the GPU.
  86454. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86455. * @param data Define the flattened data
  86456. */
  86457. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86458. /**
  86459. * Binds this uniform buffer to an effect.
  86460. * @param effect Define the effect to bind the buffer to
  86461. * @param name Name of the uniform block in the shader.
  86462. */
  86463. bindToEffect(effect: Effect, name: string): void;
  86464. /**
  86465. * Disposes the uniform buffer.
  86466. */
  86467. dispose(): void;
  86468. }
  86469. }
  86470. declare module BABYLON {
  86471. /**
  86472. * Class used to work with sound analyzer using fast fourier transform (FFT)
  86473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86474. */
  86475. export class Analyser {
  86476. /**
  86477. * Gets or sets the smoothing
  86478. * @ignorenaming
  86479. */
  86480. SMOOTHING: number;
  86481. /**
  86482. * Gets or sets the FFT table size
  86483. * @ignorenaming
  86484. */
  86485. FFT_SIZE: number;
  86486. /**
  86487. * Gets or sets the bar graph amplitude
  86488. * @ignorenaming
  86489. */
  86490. BARGRAPHAMPLITUDE: number;
  86491. /**
  86492. * Gets or sets the position of the debug canvas
  86493. * @ignorenaming
  86494. */
  86495. DEBUGCANVASPOS: {
  86496. x: number;
  86497. y: number;
  86498. };
  86499. /**
  86500. * Gets or sets the debug canvas size
  86501. * @ignorenaming
  86502. */
  86503. DEBUGCANVASSIZE: {
  86504. width: number;
  86505. height: number;
  86506. };
  86507. private _byteFreqs;
  86508. private _byteTime;
  86509. private _floatFreqs;
  86510. private _webAudioAnalyser;
  86511. private _debugCanvas;
  86512. private _debugCanvasContext;
  86513. private _scene;
  86514. private _registerFunc;
  86515. private _audioEngine;
  86516. /**
  86517. * Creates a new analyser
  86518. * @param scene defines hosting scene
  86519. */
  86520. constructor(scene: Scene);
  86521. /**
  86522. * Get the number of data values you will have to play with for the visualization
  86523. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  86524. * @returns a number
  86525. */
  86526. getFrequencyBinCount(): number;
  86527. /**
  86528. * Gets the current frequency data as a byte array
  86529. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86530. * @returns a Uint8Array
  86531. */
  86532. getByteFrequencyData(): Uint8Array;
  86533. /**
  86534. * Gets the current waveform as a byte array
  86535. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  86536. * @returns a Uint8Array
  86537. */
  86538. getByteTimeDomainData(): Uint8Array;
  86539. /**
  86540. * Gets the current frequency data as a float array
  86541. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86542. * @returns a Float32Array
  86543. */
  86544. getFloatFrequencyData(): Float32Array;
  86545. /**
  86546. * Renders the debug canvas
  86547. */
  86548. drawDebugCanvas(): void;
  86549. /**
  86550. * Stops rendering the debug canvas and removes it
  86551. */
  86552. stopDebugCanvas(): void;
  86553. /**
  86554. * Connects two audio nodes
  86555. * @param inputAudioNode defines first node to connect
  86556. * @param outputAudioNode defines second node to connect
  86557. */
  86558. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  86559. /**
  86560. * Releases all associated resources
  86561. */
  86562. dispose(): void;
  86563. }
  86564. }
  86565. declare module BABYLON {
  86566. /**
  86567. * This represents an audio engine and it is responsible
  86568. * to play, synchronize and analyse sounds throughout the application.
  86569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86570. */
  86571. export interface IAudioEngine extends IDisposable {
  86572. /**
  86573. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86574. */
  86575. readonly canUseWebAudio: boolean;
  86576. /**
  86577. * Gets the current AudioContext if available.
  86578. */
  86579. readonly audioContext: Nullable<AudioContext>;
  86580. /**
  86581. * The master gain node defines the global audio volume of your audio engine.
  86582. */
  86583. readonly masterGain: GainNode;
  86584. /**
  86585. * Gets whether or not mp3 are supported by your browser.
  86586. */
  86587. readonly isMP3supported: boolean;
  86588. /**
  86589. * Gets whether or not ogg are supported by your browser.
  86590. */
  86591. readonly isOGGsupported: boolean;
  86592. /**
  86593. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86594. * @ignoreNaming
  86595. */
  86596. WarnedWebAudioUnsupported: boolean;
  86597. /**
  86598. * Defines if the audio engine relies on a custom unlocked button.
  86599. * In this case, the embedded button will not be displayed.
  86600. */
  86601. useCustomUnlockedButton: boolean;
  86602. /**
  86603. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  86604. */
  86605. readonly unlocked: boolean;
  86606. /**
  86607. * Event raised when audio has been unlocked on the browser.
  86608. */
  86609. onAudioUnlockedObservable: Observable<AudioEngine>;
  86610. /**
  86611. * Event raised when audio has been locked on the browser.
  86612. */
  86613. onAudioLockedObservable: Observable<AudioEngine>;
  86614. /**
  86615. * Flags the audio engine in Locked state.
  86616. * This happens due to new browser policies preventing audio to autoplay.
  86617. */
  86618. lock(): void;
  86619. /**
  86620. * Unlocks the audio engine once a user action has been done on the dom.
  86621. * This is helpful to resume play once browser policies have been satisfied.
  86622. */
  86623. unlock(): void;
  86624. }
  86625. /**
  86626. * This represents the default audio engine used in babylon.
  86627. * It is responsible to play, synchronize and analyse sounds throughout the application.
  86628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86629. */
  86630. export class AudioEngine implements IAudioEngine {
  86631. private _audioContext;
  86632. private _audioContextInitialized;
  86633. private _muteButton;
  86634. private _hostElement;
  86635. /**
  86636. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86637. */
  86638. canUseWebAudio: boolean;
  86639. /**
  86640. * The master gain node defines the global audio volume of your audio engine.
  86641. */
  86642. masterGain: GainNode;
  86643. /**
  86644. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86645. * @ignoreNaming
  86646. */
  86647. WarnedWebAudioUnsupported: boolean;
  86648. /**
  86649. * Gets whether or not mp3 are supported by your browser.
  86650. */
  86651. isMP3supported: boolean;
  86652. /**
  86653. * Gets whether or not ogg are supported by your browser.
  86654. */
  86655. isOGGsupported: boolean;
  86656. /**
  86657. * Gets whether audio has been unlocked on the device.
  86658. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  86659. * a user interaction has happened.
  86660. */
  86661. unlocked: boolean;
  86662. /**
  86663. * Defines if the audio engine relies on a custom unlocked button.
  86664. * In this case, the embedded button will not be displayed.
  86665. */
  86666. useCustomUnlockedButton: boolean;
  86667. /**
  86668. * Event raised when audio has been unlocked on the browser.
  86669. */
  86670. onAudioUnlockedObservable: Observable<AudioEngine>;
  86671. /**
  86672. * Event raised when audio has been locked on the browser.
  86673. */
  86674. onAudioLockedObservable: Observable<AudioEngine>;
  86675. /**
  86676. * Gets the current AudioContext if available.
  86677. */
  86678. readonly audioContext: Nullable<AudioContext>;
  86679. private _connectedAnalyser;
  86680. /**
  86681. * Instantiates a new audio engine.
  86682. *
  86683. * There should be only one per page as some browsers restrict the number
  86684. * of audio contexts you can create.
  86685. * @param hostElement defines the host element where to display the mute icon if necessary
  86686. */
  86687. constructor(hostElement?: Nullable<HTMLElement>);
  86688. /**
  86689. * Flags the audio engine in Locked state.
  86690. * This happens due to new browser policies preventing audio to autoplay.
  86691. */
  86692. lock(): void;
  86693. /**
  86694. * Unlocks the audio engine once a user action has been done on the dom.
  86695. * This is helpful to resume play once browser policies have been satisfied.
  86696. */
  86697. unlock(): void;
  86698. private _resumeAudioContext;
  86699. private _initializeAudioContext;
  86700. private _tryToRun;
  86701. private _triggerRunningState;
  86702. private _triggerSuspendedState;
  86703. private _displayMuteButton;
  86704. private _moveButtonToTopLeft;
  86705. private _onResize;
  86706. private _hideMuteButton;
  86707. /**
  86708. * Destroy and release the resources associated with the audio ccontext.
  86709. */
  86710. dispose(): void;
  86711. /**
  86712. * Gets the global volume sets on the master gain.
  86713. * @returns the global volume if set or -1 otherwise
  86714. */
  86715. getGlobalVolume(): number;
  86716. /**
  86717. * Sets the global volume of your experience (sets on the master gain).
  86718. * @param newVolume Defines the new global volume of the application
  86719. */
  86720. setGlobalVolume(newVolume: number): void;
  86721. /**
  86722. * Connect the audio engine to an audio analyser allowing some amazing
  86723. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  86724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  86725. * @param analyser The analyser to connect to the engine
  86726. */
  86727. connectToAnalyser(analyser: Analyser): void;
  86728. }
  86729. }
  86730. declare module BABYLON {
  86731. /**
  86732. * Interface used to present a loading screen while loading a scene
  86733. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86734. */
  86735. export interface ILoadingScreen {
  86736. /**
  86737. * Function called to display the loading screen
  86738. */
  86739. displayLoadingUI: () => void;
  86740. /**
  86741. * Function called to hide the loading screen
  86742. */
  86743. hideLoadingUI: () => void;
  86744. /**
  86745. * Gets or sets the color to use for the background
  86746. */
  86747. loadingUIBackgroundColor: string;
  86748. /**
  86749. * Gets or sets the text to display while loading
  86750. */
  86751. loadingUIText: string;
  86752. }
  86753. /**
  86754. * Class used for the default loading screen
  86755. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86756. */
  86757. export class DefaultLoadingScreen implements ILoadingScreen {
  86758. private _renderingCanvas;
  86759. private _loadingText;
  86760. private _loadingDivBackgroundColor;
  86761. private _loadingDiv;
  86762. private _loadingTextDiv;
  86763. /**
  86764. * Creates a new default loading screen
  86765. * @param _renderingCanvas defines the canvas used to render the scene
  86766. * @param _loadingText defines the default text to display
  86767. * @param _loadingDivBackgroundColor defines the default background color
  86768. */
  86769. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  86770. /**
  86771. * Function called to display the loading screen
  86772. */
  86773. displayLoadingUI(): void;
  86774. /**
  86775. * Function called to hide the loading screen
  86776. */
  86777. hideLoadingUI(): void;
  86778. /**
  86779. * Gets or sets the text to display while loading
  86780. */
  86781. loadingUIText: string;
  86782. /**
  86783. * Gets or sets the color to use for the background
  86784. */
  86785. loadingUIBackgroundColor: string;
  86786. private _resizeLoadingUI;
  86787. }
  86788. }
  86789. declare module BABYLON {
  86790. /** @hidden */
  86791. export class WebGLPipelineContext implements IPipelineContext {
  86792. engine: Engine;
  86793. program: Nullable<WebGLProgram>;
  86794. context?: WebGLRenderingContext;
  86795. vertexShader?: WebGLShader;
  86796. fragmentShader?: WebGLShader;
  86797. isParallelCompiled: boolean;
  86798. onCompiled?: () => void;
  86799. transformFeedback?: WebGLTransformFeedback | null;
  86800. readonly isAsync: boolean;
  86801. readonly isReady: boolean;
  86802. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86803. }
  86804. }
  86805. declare module BABYLON {
  86806. /** @hidden */
  86807. export class WebGLDataBuffer extends DataBuffer {
  86808. private _buffer;
  86809. constructor(resource: WebGLBuffer);
  86810. readonly underlyingResource: any;
  86811. }
  86812. }
  86813. declare module BABYLON {
  86814. /**
  86815. * Settings for finer control over video usage
  86816. */
  86817. export interface VideoTextureSettings {
  86818. /**
  86819. * Applies `autoplay` to video, if specified
  86820. */
  86821. autoPlay?: boolean;
  86822. /**
  86823. * Applies `loop` to video, if specified
  86824. */
  86825. loop?: boolean;
  86826. /**
  86827. * Automatically updates internal texture from video at every frame in the render loop
  86828. */
  86829. autoUpdateTexture: boolean;
  86830. /**
  86831. * Image src displayed during the video loading or until the user interacts with the video.
  86832. */
  86833. poster?: string;
  86834. }
  86835. /**
  86836. * If you want to display a video in your scene, this is the special texture for that.
  86837. * This special texture works similar to other textures, with the exception of a few parameters.
  86838. * @see https://doc.babylonjs.com/how_to/video_texture
  86839. */
  86840. export class VideoTexture extends Texture {
  86841. /**
  86842. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86843. */
  86844. readonly autoUpdateTexture: boolean;
  86845. /**
  86846. * The video instance used by the texture internally
  86847. */
  86848. readonly video: HTMLVideoElement;
  86849. private _onUserActionRequestedObservable;
  86850. /**
  86851. * Event triggerd when a dom action is required by the user to play the video.
  86852. * This happens due to recent changes in browser policies preventing video to auto start.
  86853. */
  86854. readonly onUserActionRequestedObservable: Observable<Texture>;
  86855. private _generateMipMaps;
  86856. private _engine;
  86857. private _stillImageCaptured;
  86858. private _displayingPosterTexture;
  86859. private _settings;
  86860. private _createInternalTextureOnEvent;
  86861. /**
  86862. * Creates a video texture.
  86863. * If you want to display a video in your scene, this is the special texture for that.
  86864. * This special texture works similar to other textures, with the exception of a few parameters.
  86865. * @see https://doc.babylonjs.com/how_to/video_texture
  86866. * @param name optional name, will detect from video source, if not defined
  86867. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86868. * @param scene is obviously the current scene.
  86869. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86870. * @param invertY is false by default but can be used to invert video on Y axis
  86871. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86872. * @param settings allows finer control over video usage
  86873. */
  86874. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86875. private _getName;
  86876. private _getVideo;
  86877. private _createInternalTexture;
  86878. private reset;
  86879. /**
  86880. * @hidden Internal method to initiate `update`.
  86881. */
  86882. _rebuild(): void;
  86883. /**
  86884. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86885. */
  86886. update(): void;
  86887. /**
  86888. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86889. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86890. */
  86891. updateTexture(isVisible: boolean): void;
  86892. protected _updateInternalTexture: () => void;
  86893. /**
  86894. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86895. * @param url New url.
  86896. */
  86897. updateURL(url: string): void;
  86898. /**
  86899. * Dispose the texture and release its associated resources.
  86900. */
  86901. dispose(): void;
  86902. /**
  86903. * Creates a video texture straight from a stream.
  86904. * @param scene Define the scene the texture should be created in
  86905. * @param stream Define the stream the texture should be created from
  86906. * @returns The created video texture as a promise
  86907. */
  86908. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86909. /**
  86910. * Creates a video texture straight from your WebCam video feed.
  86911. * @param scene Define the scene the texture should be created in
  86912. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86913. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86914. * @returns The created video texture as a promise
  86915. */
  86916. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86917. minWidth: number;
  86918. maxWidth: number;
  86919. minHeight: number;
  86920. maxHeight: number;
  86921. deviceId: string;
  86922. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86923. /**
  86924. * Creates a video texture straight from your WebCam video feed.
  86925. * @param scene Define the scene the texture should be created in
  86926. * @param onReady Define a callback to triggered once the texture will be ready
  86927. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86928. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86929. */
  86930. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86931. minWidth: number;
  86932. maxWidth: number;
  86933. minHeight: number;
  86934. maxHeight: number;
  86935. deviceId: string;
  86936. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86937. }
  86938. }
  86939. declare module BABYLON {
  86940. /**
  86941. * Interface for attribute information associated with buffer instanciation
  86942. */
  86943. export class InstancingAttributeInfo {
  86944. /**
  86945. * Index/offset of the attribute in the vertex shader
  86946. */
  86947. index: number;
  86948. /**
  86949. * size of the attribute, 1, 2, 3 or 4
  86950. */
  86951. attributeSize: number;
  86952. /**
  86953. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86954. * default is FLOAT
  86955. */
  86956. attribyteType: number;
  86957. /**
  86958. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86959. */
  86960. normalized: boolean;
  86961. /**
  86962. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86963. */
  86964. offset: number;
  86965. /**
  86966. * Name of the GLSL attribute, for debugging purpose only
  86967. */
  86968. attributeName: string;
  86969. }
  86970. /**
  86971. * Define options used to create a depth texture
  86972. */
  86973. export class DepthTextureCreationOptions {
  86974. /** Specifies whether or not a stencil should be allocated in the texture */
  86975. generateStencil?: boolean;
  86976. /** Specifies whether or not bilinear filtering is enable on the texture */
  86977. bilinearFiltering?: boolean;
  86978. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86979. comparisonFunction?: number;
  86980. /** Specifies if the created texture is a cube texture */
  86981. isCube?: boolean;
  86982. }
  86983. /**
  86984. * Class used to describe the capabilities of the engine relatively to the current browser
  86985. */
  86986. export class EngineCapabilities {
  86987. /** Maximum textures units per fragment shader */
  86988. maxTexturesImageUnits: number;
  86989. /** Maximum texture units per vertex shader */
  86990. maxVertexTextureImageUnits: number;
  86991. /** Maximum textures units in the entire pipeline */
  86992. maxCombinedTexturesImageUnits: number;
  86993. /** Maximum texture size */
  86994. maxTextureSize: number;
  86995. /** Maximum cube texture size */
  86996. maxCubemapTextureSize: number;
  86997. /** Maximum render texture size */
  86998. maxRenderTextureSize: number;
  86999. /** Maximum number of vertex attributes */
  87000. maxVertexAttribs: number;
  87001. /** Maximum number of varyings */
  87002. maxVaryingVectors: number;
  87003. /** Maximum number of uniforms per vertex shader */
  87004. maxVertexUniformVectors: number;
  87005. /** Maximum number of uniforms per fragment shader */
  87006. maxFragmentUniformVectors: number;
  87007. /** Defines if standard derivates (dx/dy) are supported */
  87008. standardDerivatives: boolean;
  87009. /** Defines if s3tc texture compression is supported */
  87010. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  87011. /** Defines if pvrtc texture compression is supported */
  87012. pvrtc: any;
  87013. /** Defines if etc1 texture compression is supported */
  87014. etc1: any;
  87015. /** Defines if etc2 texture compression is supported */
  87016. etc2: any;
  87017. /** Defines if astc texture compression is supported */
  87018. astc: any;
  87019. /** Defines if float textures are supported */
  87020. textureFloat: boolean;
  87021. /** Defines if vertex array objects are supported */
  87022. vertexArrayObject: boolean;
  87023. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  87024. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  87025. /** Gets the maximum level of anisotropy supported */
  87026. maxAnisotropy: number;
  87027. /** Defines if instancing is supported */
  87028. instancedArrays: boolean;
  87029. /** Defines if 32 bits indices are supported */
  87030. uintIndices: boolean;
  87031. /** Defines if high precision shaders are supported */
  87032. highPrecisionShaderSupported: boolean;
  87033. /** Defines if depth reading in the fragment shader is supported */
  87034. fragmentDepthSupported: boolean;
  87035. /** Defines if float texture linear filtering is supported*/
  87036. textureFloatLinearFiltering: boolean;
  87037. /** Defines if rendering to float textures is supported */
  87038. textureFloatRender: boolean;
  87039. /** Defines if half float textures are supported*/
  87040. textureHalfFloat: boolean;
  87041. /** Defines if half float texture linear filtering is supported*/
  87042. textureHalfFloatLinearFiltering: boolean;
  87043. /** Defines if rendering to half float textures is supported */
  87044. textureHalfFloatRender: boolean;
  87045. /** Defines if textureLOD shader command is supported */
  87046. textureLOD: boolean;
  87047. /** Defines if draw buffers extension is supported */
  87048. drawBuffersExtension: boolean;
  87049. /** Defines if depth textures are supported */
  87050. depthTextureExtension: boolean;
  87051. /** Defines if float color buffer are supported */
  87052. colorBufferFloat: boolean;
  87053. /** Gets disjoint timer query extension (null if not supported) */
  87054. timerQuery: EXT_disjoint_timer_query;
  87055. /** Defines if timestamp can be used with timer query */
  87056. canUseTimestampForTimerQuery: boolean;
  87057. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  87058. multiview: any;
  87059. /** Function used to let the system compiles shaders in background */
  87060. parallelShaderCompile: {
  87061. COMPLETION_STATUS_KHR: number;
  87062. };
  87063. }
  87064. /** Interface defining initialization parameters for Engine class */
  87065. export interface EngineOptions extends WebGLContextAttributes {
  87066. /**
  87067. * Defines if the engine should no exceed a specified device ratio
  87068. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  87069. */
  87070. limitDeviceRatio?: number;
  87071. /**
  87072. * Defines if webvr should be enabled automatically
  87073. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87074. */
  87075. autoEnableWebVR?: boolean;
  87076. /**
  87077. * Defines if webgl2 should be turned off even if supported
  87078. * @see http://doc.babylonjs.com/features/webgl2
  87079. */
  87080. disableWebGL2Support?: boolean;
  87081. /**
  87082. * Defines if webaudio should be initialized as well
  87083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87084. */
  87085. audioEngine?: boolean;
  87086. /**
  87087. * Defines if animations should run using a deterministic lock step
  87088. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87089. */
  87090. deterministicLockstep?: boolean;
  87091. /** Defines the maximum steps to use with deterministic lock step mode */
  87092. lockstepMaxSteps?: number;
  87093. /**
  87094. * Defines that engine should ignore context lost events
  87095. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  87096. */
  87097. doNotHandleContextLost?: boolean;
  87098. /**
  87099. * Defines that engine should ignore modifying touch action attribute and style
  87100. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  87101. */
  87102. doNotHandleTouchAction?: boolean;
  87103. /**
  87104. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  87105. */
  87106. useHighPrecisionFloats?: boolean;
  87107. }
  87108. /**
  87109. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  87110. */
  87111. export class Engine {
  87112. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  87113. static ExceptionList: ({
  87114. key: string;
  87115. capture: string;
  87116. captureConstraint: number;
  87117. targets: string[];
  87118. } | {
  87119. key: string;
  87120. capture: null;
  87121. captureConstraint: null;
  87122. targets: string[];
  87123. })[];
  87124. /** Gets the list of created engines */
  87125. static readonly Instances: Engine[];
  87126. /**
  87127. * Gets the latest created engine
  87128. */
  87129. static readonly LastCreatedEngine: Nullable<Engine>;
  87130. /**
  87131. * Gets the latest created scene
  87132. */
  87133. static readonly LastCreatedScene: Nullable<Scene>;
  87134. /**
  87135. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  87136. * @param flag defines which part of the materials must be marked as dirty
  87137. * @param predicate defines a predicate used to filter which materials should be affected
  87138. */
  87139. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  87140. /**
  87141. * Hidden
  87142. */
  87143. static _TextureLoaders: IInternalTextureLoader[];
  87144. /** Defines that alpha blending is disabled */
  87145. static readonly ALPHA_DISABLE: number;
  87146. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  87147. static readonly ALPHA_ADD: number;
  87148. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  87149. static readonly ALPHA_COMBINE: number;
  87150. /** Defines that alpha blending to DEST - SRC * DEST */
  87151. static readonly ALPHA_SUBTRACT: number;
  87152. /** Defines that alpha blending to SRC * DEST */
  87153. static readonly ALPHA_MULTIPLY: number;
  87154. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  87155. static readonly ALPHA_MAXIMIZED: number;
  87156. /** Defines that alpha blending to SRC + DEST */
  87157. static readonly ALPHA_ONEONE: number;
  87158. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  87159. static readonly ALPHA_PREMULTIPLIED: number;
  87160. /**
  87161. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  87162. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  87163. */
  87164. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  87165. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  87166. static readonly ALPHA_INTERPOLATE: number;
  87167. /**
  87168. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  87169. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  87170. */
  87171. static readonly ALPHA_SCREENMODE: number;
  87172. /** Defines that the ressource is not delayed*/
  87173. static readonly DELAYLOADSTATE_NONE: number;
  87174. /** Defines that the ressource was successfully delay loaded */
  87175. static readonly DELAYLOADSTATE_LOADED: number;
  87176. /** Defines that the ressource is currently delay loading */
  87177. static readonly DELAYLOADSTATE_LOADING: number;
  87178. /** Defines that the ressource is delayed and has not started loading */
  87179. static readonly DELAYLOADSTATE_NOTLOADED: number;
  87180. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  87181. static readonly NEVER: number;
  87182. /** 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 */
  87183. static readonly ALWAYS: number;
  87184. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  87185. static readonly LESS: number;
  87186. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  87187. static readonly EQUAL: number;
  87188. /** 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 */
  87189. static readonly LEQUAL: number;
  87190. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  87191. static readonly GREATER: number;
  87192. /** 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 */
  87193. static readonly GEQUAL: number;
  87194. /** 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 */
  87195. static readonly NOTEQUAL: number;
  87196. /** Passed to stencilOperation to specify that stencil value must be kept */
  87197. static readonly KEEP: number;
  87198. /** Passed to stencilOperation to specify that stencil value must be replaced */
  87199. static readonly REPLACE: number;
  87200. /** Passed to stencilOperation to specify that stencil value must be incremented */
  87201. static readonly INCR: number;
  87202. /** Passed to stencilOperation to specify that stencil value must be decremented */
  87203. static readonly DECR: number;
  87204. /** Passed to stencilOperation to specify that stencil value must be inverted */
  87205. static readonly INVERT: number;
  87206. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  87207. static readonly INCR_WRAP: number;
  87208. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  87209. static readonly DECR_WRAP: number;
  87210. /** Texture is not repeating outside of 0..1 UVs */
  87211. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  87212. /** Texture is repeating outside of 0..1 UVs */
  87213. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  87214. /** Texture is repeating and mirrored */
  87215. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  87216. /** ALPHA */
  87217. static readonly TEXTUREFORMAT_ALPHA: number;
  87218. /** LUMINANCE */
  87219. static readonly TEXTUREFORMAT_LUMINANCE: number;
  87220. /** LUMINANCE_ALPHA */
  87221. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  87222. /** RGB */
  87223. static readonly TEXTUREFORMAT_RGB: number;
  87224. /** RGBA */
  87225. static readonly TEXTUREFORMAT_RGBA: number;
  87226. /** RED */
  87227. static readonly TEXTUREFORMAT_RED: number;
  87228. /** RED (2nd reference) */
  87229. static readonly TEXTUREFORMAT_R: number;
  87230. /** RG */
  87231. static readonly TEXTUREFORMAT_RG: number;
  87232. /** RED_INTEGER */
  87233. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  87234. /** RED_INTEGER (2nd reference) */
  87235. static readonly TEXTUREFORMAT_R_INTEGER: number;
  87236. /** RG_INTEGER */
  87237. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  87238. /** RGB_INTEGER */
  87239. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  87240. /** RGBA_INTEGER */
  87241. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  87242. /** UNSIGNED_BYTE */
  87243. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  87244. /** UNSIGNED_BYTE (2nd reference) */
  87245. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  87246. /** FLOAT */
  87247. static readonly TEXTURETYPE_FLOAT: number;
  87248. /** HALF_FLOAT */
  87249. static readonly TEXTURETYPE_HALF_FLOAT: number;
  87250. /** BYTE */
  87251. static readonly TEXTURETYPE_BYTE: number;
  87252. /** SHORT */
  87253. static readonly TEXTURETYPE_SHORT: number;
  87254. /** UNSIGNED_SHORT */
  87255. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  87256. /** INT */
  87257. static readonly TEXTURETYPE_INT: number;
  87258. /** UNSIGNED_INT */
  87259. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  87260. /** UNSIGNED_SHORT_4_4_4_4 */
  87261. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  87262. /** UNSIGNED_SHORT_5_5_5_1 */
  87263. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  87264. /** UNSIGNED_SHORT_5_6_5 */
  87265. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  87266. /** UNSIGNED_INT_2_10_10_10_REV */
  87267. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  87268. /** UNSIGNED_INT_24_8 */
  87269. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  87270. /** UNSIGNED_INT_10F_11F_11F_REV */
  87271. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  87272. /** UNSIGNED_INT_5_9_9_9_REV */
  87273. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  87274. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  87275. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  87276. /** nearest is mag = nearest and min = nearest and mip = linear */
  87277. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  87278. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87279. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  87280. /** Trilinear is mag = linear and min = linear and mip = linear */
  87281. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  87282. /** nearest is mag = nearest and min = nearest and mip = linear */
  87283. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  87284. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87285. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  87286. /** Trilinear is mag = linear and min = linear and mip = linear */
  87287. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  87288. /** mag = nearest and min = nearest and mip = nearest */
  87289. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  87290. /** mag = nearest and min = linear and mip = nearest */
  87291. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  87292. /** mag = nearest and min = linear and mip = linear */
  87293. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  87294. /** mag = nearest and min = linear and mip = none */
  87295. static readonly TEXTURE_NEAREST_LINEAR: number;
  87296. /** mag = nearest and min = nearest and mip = none */
  87297. static readonly TEXTURE_NEAREST_NEAREST: number;
  87298. /** mag = linear and min = nearest and mip = nearest */
  87299. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  87300. /** mag = linear and min = nearest and mip = linear */
  87301. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  87302. /** mag = linear and min = linear and mip = none */
  87303. static readonly TEXTURE_LINEAR_LINEAR: number;
  87304. /** mag = linear and min = nearest and mip = none */
  87305. static readonly TEXTURE_LINEAR_NEAREST: number;
  87306. /** Explicit coordinates mode */
  87307. static readonly TEXTURE_EXPLICIT_MODE: number;
  87308. /** Spherical coordinates mode */
  87309. static readonly TEXTURE_SPHERICAL_MODE: number;
  87310. /** Planar coordinates mode */
  87311. static readonly TEXTURE_PLANAR_MODE: number;
  87312. /** Cubic coordinates mode */
  87313. static readonly TEXTURE_CUBIC_MODE: number;
  87314. /** Projection coordinates mode */
  87315. static readonly TEXTURE_PROJECTION_MODE: number;
  87316. /** Skybox coordinates mode */
  87317. static readonly TEXTURE_SKYBOX_MODE: number;
  87318. /** Inverse Cubic coordinates mode */
  87319. static readonly TEXTURE_INVCUBIC_MODE: number;
  87320. /** Equirectangular coordinates mode */
  87321. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  87322. /** Equirectangular Fixed coordinates mode */
  87323. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  87324. /** Equirectangular Fixed Mirrored coordinates mode */
  87325. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  87326. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  87327. static readonly SCALEMODE_FLOOR: number;
  87328. /** Defines that texture rescaling will look for the nearest power of 2 size */
  87329. static readonly SCALEMODE_NEAREST: number;
  87330. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  87331. static readonly SCALEMODE_CEILING: number;
  87332. /**
  87333. * Returns the current npm package of the sdk
  87334. */
  87335. static readonly NpmPackage: string;
  87336. /**
  87337. * Returns the current version of the framework
  87338. */
  87339. static readonly Version: string;
  87340. /**
  87341. * Returns a string describing the current engine
  87342. */
  87343. readonly description: string;
  87344. /**
  87345. * Gets or sets the epsilon value used by collision engine
  87346. */
  87347. static CollisionsEpsilon: number;
  87348. /**
  87349. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87350. */
  87351. static ShadersRepository: string;
  87352. /**
  87353. * Method called to create the default loading screen.
  87354. * This can be overriden in your own app.
  87355. * @param canvas The rendering canvas element
  87356. * @returns The loading screen
  87357. */
  87358. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  87359. /**
  87360. * Method called to create the default rescale post process on each engine.
  87361. */
  87362. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  87363. /**
  87364. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  87365. */
  87366. forcePOTTextures: boolean;
  87367. /**
  87368. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  87369. */
  87370. isFullscreen: boolean;
  87371. /**
  87372. * Gets a boolean indicating if the pointer is currently locked
  87373. */
  87374. isPointerLock: boolean;
  87375. /**
  87376. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  87377. */
  87378. cullBackFaces: boolean;
  87379. /**
  87380. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  87381. */
  87382. renderEvenInBackground: boolean;
  87383. /**
  87384. * Gets or sets a boolean indicating that cache can be kept between frames
  87385. */
  87386. preventCacheWipeBetweenFrames: boolean;
  87387. /**
  87388. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  87389. **/
  87390. enableOfflineSupport: boolean;
  87391. /**
  87392. * 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)
  87393. **/
  87394. disableManifestCheck: boolean;
  87395. /**
  87396. * Gets the list of created scenes
  87397. */
  87398. scenes: Scene[];
  87399. /**
  87400. * Event raised when a new scene is created
  87401. */
  87402. onNewSceneAddedObservable: Observable<Scene>;
  87403. /**
  87404. * Gets the list of created postprocesses
  87405. */
  87406. postProcesses: PostProcess[];
  87407. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  87408. validateShaderPrograms: boolean;
  87409. /**
  87410. * Observable event triggered each time the rendering canvas is resized
  87411. */
  87412. onResizeObservable: Observable<Engine>;
  87413. /**
  87414. * Observable event triggered each time the canvas loses focus
  87415. */
  87416. onCanvasBlurObservable: Observable<Engine>;
  87417. /**
  87418. * Observable event triggered each time the canvas gains focus
  87419. */
  87420. onCanvasFocusObservable: Observable<Engine>;
  87421. /**
  87422. * Observable event triggered each time the canvas receives pointerout event
  87423. */
  87424. onCanvasPointerOutObservable: Observable<PointerEvent>;
  87425. /**
  87426. * Observable event triggered before each texture is initialized
  87427. */
  87428. onBeforeTextureInitObservable: Observable<Texture>;
  87429. /**
  87430. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  87431. */
  87432. disableUniformBuffers: boolean;
  87433. /** @hidden */
  87434. _uniformBuffers: UniformBuffer[];
  87435. /**
  87436. * Gets a boolean indicating that the engine supports uniform buffers
  87437. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87438. */
  87439. readonly supportsUniformBuffers: boolean;
  87440. /**
  87441. * Observable raised when the engine begins a new frame
  87442. */
  87443. onBeginFrameObservable: Observable<Engine>;
  87444. /**
  87445. * If set, will be used to request the next animation frame for the render loop
  87446. */
  87447. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  87448. /**
  87449. * Observable raised when the engine ends the current frame
  87450. */
  87451. onEndFrameObservable: Observable<Engine>;
  87452. /**
  87453. * Observable raised when the engine is about to compile a shader
  87454. */
  87455. onBeforeShaderCompilationObservable: Observable<Engine>;
  87456. /**
  87457. * Observable raised when the engine has jsut compiled a shader
  87458. */
  87459. onAfterShaderCompilationObservable: Observable<Engine>;
  87460. /** @hidden */
  87461. _gl: WebGLRenderingContext;
  87462. private _renderingCanvas;
  87463. private _windowIsBackground;
  87464. private _webGLVersion;
  87465. protected _highPrecisionShadersAllowed: boolean;
  87466. /** @hidden */
  87467. readonly _shouldUseHighPrecisionShader: boolean;
  87468. /**
  87469. * Gets a boolean indicating that only power of 2 textures are supported
  87470. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  87471. */
  87472. readonly needPOTTextures: boolean;
  87473. /** @hidden */
  87474. _badOS: boolean;
  87475. /** @hidden */
  87476. _badDesktopOS: boolean;
  87477. /**
  87478. * Gets the audio engine
  87479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87480. * @ignorenaming
  87481. */
  87482. static audioEngine: IAudioEngine;
  87483. /**
  87484. * Default AudioEngine factory responsible of creating the Audio Engine.
  87485. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  87486. */
  87487. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  87488. /**
  87489. * Default offline support factory responsible of creating a tool used to store data locally.
  87490. * By default, this will create a Database object if the workload has been embedded.
  87491. */
  87492. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  87493. private _onFocus;
  87494. private _onBlur;
  87495. private _onCanvasPointerOut;
  87496. private _onCanvasBlur;
  87497. private _onCanvasFocus;
  87498. private _onFullscreenChange;
  87499. private _onPointerLockChange;
  87500. private _hardwareScalingLevel;
  87501. /** @hidden */
  87502. _caps: EngineCapabilities;
  87503. private _pointerLockRequested;
  87504. private _isStencilEnable;
  87505. private _colorWrite;
  87506. private _loadingScreen;
  87507. /** @hidden */
  87508. _drawCalls: PerfCounter;
  87509. private _glVersion;
  87510. private _glRenderer;
  87511. private _glVendor;
  87512. private _videoTextureSupported;
  87513. private _renderingQueueLaunched;
  87514. private _activeRenderLoops;
  87515. private _deterministicLockstep;
  87516. private _lockstepMaxSteps;
  87517. /**
  87518. * Observable signaled when a context lost event is raised
  87519. */
  87520. onContextLostObservable: Observable<Engine>;
  87521. /**
  87522. * Observable signaled when a context restored event is raised
  87523. */
  87524. onContextRestoredObservable: Observable<Engine>;
  87525. private _onContextLost;
  87526. private _onContextRestored;
  87527. private _contextWasLost;
  87528. /** @hidden */
  87529. _doNotHandleContextLost: boolean;
  87530. /**
  87531. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  87532. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  87533. */
  87534. doNotHandleContextLost: boolean;
  87535. private _performanceMonitor;
  87536. private _fps;
  87537. private _deltaTime;
  87538. /**
  87539. * Turn this value on if you want to pause FPS computation when in background
  87540. */
  87541. disablePerformanceMonitorInBackground: boolean;
  87542. /**
  87543. * Gets the performance monitor attached to this engine
  87544. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  87545. */
  87546. readonly performanceMonitor: PerformanceMonitor;
  87547. /**
  87548. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  87549. */
  87550. disableVertexArrayObjects: boolean;
  87551. /** @hidden */
  87552. protected _depthCullingState: _DepthCullingState;
  87553. /** @hidden */
  87554. protected _stencilState: _StencilState;
  87555. /** @hidden */
  87556. protected _alphaState: _AlphaState;
  87557. /** @hidden */
  87558. protected _alphaMode: number;
  87559. /** @hidden */
  87560. _internalTexturesCache: InternalTexture[];
  87561. /** @hidden */
  87562. protected _activeChannel: number;
  87563. private _currentTextureChannel;
  87564. /** @hidden */
  87565. protected _boundTexturesCache: {
  87566. [key: string]: Nullable<InternalTexture>;
  87567. };
  87568. /** @hidden */
  87569. protected _currentEffect: Nullable<Effect>;
  87570. /** @hidden */
  87571. protected _currentProgram: Nullable<WebGLProgram>;
  87572. private _compiledEffects;
  87573. private _vertexAttribArraysEnabled;
  87574. /** @hidden */
  87575. protected _cachedViewport: Nullable<Viewport>;
  87576. private _cachedVertexArrayObject;
  87577. /** @hidden */
  87578. protected _cachedVertexBuffers: any;
  87579. /** @hidden */
  87580. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  87581. /** @hidden */
  87582. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  87583. /** @hidden */
  87584. _currentRenderTarget: Nullable<InternalTexture>;
  87585. private _uintIndicesCurrentlySet;
  87586. private _currentBoundBuffer;
  87587. /** @hidden */
  87588. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  87589. private _currentBufferPointers;
  87590. private _currentInstanceLocations;
  87591. private _currentInstanceBuffers;
  87592. private _textureUnits;
  87593. /** @hidden */
  87594. _workingCanvas: Nullable<HTMLCanvasElement>;
  87595. /** @hidden */
  87596. _workingContext: Nullable<CanvasRenderingContext2D>;
  87597. private _rescalePostProcess;
  87598. private _dummyFramebuffer;
  87599. private _externalData;
  87600. /** @hidden */
  87601. _bindedRenderFunction: any;
  87602. private _vaoRecordInProgress;
  87603. private _mustWipeVertexAttributes;
  87604. private _emptyTexture;
  87605. private _emptyCubeTexture;
  87606. private _emptyTexture3D;
  87607. /** @hidden */
  87608. _frameHandler: number;
  87609. private _nextFreeTextureSlots;
  87610. private _maxSimultaneousTextures;
  87611. private _activeRequests;
  87612. private _texturesSupported;
  87613. /** @hidden */
  87614. _textureFormatInUse: Nullable<string>;
  87615. /**
  87616. * Gets the list of texture formats supported
  87617. */
  87618. readonly texturesSupported: Array<string>;
  87619. /**
  87620. * Gets the list of texture formats in use
  87621. */
  87622. readonly textureFormatInUse: Nullable<string>;
  87623. /**
  87624. * Gets the current viewport
  87625. */
  87626. readonly currentViewport: Nullable<Viewport>;
  87627. /**
  87628. * Gets the default empty texture
  87629. */
  87630. readonly emptyTexture: InternalTexture;
  87631. /**
  87632. * Gets the default empty 3D texture
  87633. */
  87634. readonly emptyTexture3D: InternalTexture;
  87635. /**
  87636. * Gets the default empty cube texture
  87637. */
  87638. readonly emptyCubeTexture: InternalTexture;
  87639. /**
  87640. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  87641. */
  87642. readonly premultipliedAlpha: boolean;
  87643. /**
  87644. * Creates a new engine
  87645. * @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
  87646. * @param antialias defines enable antialiasing (default: false)
  87647. * @param options defines further options to be sent to the getContext() function
  87648. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  87649. */
  87650. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  87651. /**
  87652. * Initializes a webVR display and starts listening to display change events
  87653. * The onVRDisplayChangedObservable will be notified upon these changes
  87654. * @returns The onVRDisplayChangedObservable
  87655. */
  87656. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87657. /** @hidden */
  87658. _prepareVRComponent(): void;
  87659. /** @hidden */
  87660. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  87661. /** @hidden */
  87662. _submitVRFrame(): void;
  87663. /**
  87664. * Call this function to leave webVR mode
  87665. * Will do nothing if webVR is not supported or if there is no webVR device
  87666. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87667. */
  87668. disableVR(): void;
  87669. /**
  87670. * Gets a boolean indicating that the system is in VR mode and is presenting
  87671. * @returns true if VR mode is engaged
  87672. */
  87673. isVRPresenting(): boolean;
  87674. /** @hidden */
  87675. _requestVRFrame(): void;
  87676. private _disableTouchAction;
  87677. private _rebuildInternalTextures;
  87678. private _rebuildEffects;
  87679. /**
  87680. * Gets a boolean indicating if all created effects are ready
  87681. * @returns true if all effects are ready
  87682. */
  87683. areAllEffectsReady(): boolean;
  87684. private _rebuildBuffers;
  87685. private _initGLContext;
  87686. /**
  87687. * Gets version of the current webGL context
  87688. */
  87689. readonly webGLVersion: number;
  87690. /**
  87691. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  87692. */
  87693. readonly isStencilEnable: boolean;
  87694. /** @hidden */
  87695. _prepareWorkingCanvas(): void;
  87696. /**
  87697. * Reset the texture cache to empty state
  87698. */
  87699. resetTextureCache(): void;
  87700. /**
  87701. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  87702. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87703. * @returns true if engine is in deterministic lock step mode
  87704. */
  87705. isDeterministicLockStep(): boolean;
  87706. /**
  87707. * Gets the max steps when engine is running in deterministic lock step
  87708. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87709. * @returns the max steps
  87710. */
  87711. getLockstepMaxSteps(): number;
  87712. /**
  87713. * Gets an object containing information about the current webGL context
  87714. * @returns an object containing the vender, the renderer and the version of the current webGL context
  87715. */
  87716. getGlInfo(): {
  87717. vendor: string;
  87718. renderer: string;
  87719. version: string;
  87720. };
  87721. /**
  87722. * Gets current aspect ratio
  87723. * @param camera defines the camera to use to get the aspect ratio
  87724. * @param useScreen defines if screen size must be used (or the current render target if any)
  87725. * @returns a number defining the aspect ratio
  87726. */
  87727. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  87728. /**
  87729. * Gets current screen aspect ratio
  87730. * @returns a number defining the aspect ratio
  87731. */
  87732. getScreenAspectRatio(): number;
  87733. /**
  87734. * Gets the current render width
  87735. * @param useScreen defines if screen size must be used (or the current render target if any)
  87736. * @returns a number defining the current render width
  87737. */
  87738. getRenderWidth(useScreen?: boolean): number;
  87739. /**
  87740. * Gets the current render height
  87741. * @param useScreen defines if screen size must be used (or the current render target if any)
  87742. * @returns a number defining the current render height
  87743. */
  87744. getRenderHeight(useScreen?: boolean): number;
  87745. /**
  87746. * Gets the HTML canvas attached with the current webGL context
  87747. * @returns a HTML canvas
  87748. */
  87749. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  87750. /**
  87751. * Gets the client rect of the HTML canvas attached with the current webGL context
  87752. * @returns a client rectanglee
  87753. */
  87754. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  87755. /**
  87756. * Defines the hardware scaling level.
  87757. * By default the hardware scaling level is computed from the window device ratio.
  87758. * 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.
  87759. * @param level defines the level to use
  87760. */
  87761. setHardwareScalingLevel(level: number): void;
  87762. /**
  87763. * Gets the current hardware scaling level.
  87764. * By default the hardware scaling level is computed from the window device ratio.
  87765. * 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.
  87766. * @returns a number indicating the current hardware scaling level
  87767. */
  87768. getHardwareScalingLevel(): number;
  87769. /**
  87770. * Gets the list of loaded textures
  87771. * @returns an array containing all loaded textures
  87772. */
  87773. getLoadedTexturesCache(): InternalTexture[];
  87774. /**
  87775. * Gets the object containing all engine capabilities
  87776. * @returns the EngineCapabilities object
  87777. */
  87778. getCaps(): EngineCapabilities;
  87779. /**
  87780. * Gets the current depth function
  87781. * @returns a number defining the depth function
  87782. */
  87783. getDepthFunction(): Nullable<number>;
  87784. /**
  87785. * Sets the current depth function
  87786. * @param depthFunc defines the function to use
  87787. */
  87788. setDepthFunction(depthFunc: number): void;
  87789. /**
  87790. * Sets the current depth function to GREATER
  87791. */
  87792. setDepthFunctionToGreater(): void;
  87793. /**
  87794. * Sets the current depth function to GEQUAL
  87795. */
  87796. setDepthFunctionToGreaterOrEqual(): void;
  87797. /**
  87798. * Sets the current depth function to LESS
  87799. */
  87800. setDepthFunctionToLess(): void;
  87801. private _cachedStencilBuffer;
  87802. private _cachedStencilFunction;
  87803. private _cachedStencilMask;
  87804. private _cachedStencilOperationPass;
  87805. private _cachedStencilOperationFail;
  87806. private _cachedStencilOperationDepthFail;
  87807. private _cachedStencilReference;
  87808. /**
  87809. * Caches the the state of the stencil buffer
  87810. */
  87811. cacheStencilState(): void;
  87812. /**
  87813. * Restores the state of the stencil buffer
  87814. */
  87815. restoreStencilState(): void;
  87816. /**
  87817. * Sets the current depth function to LEQUAL
  87818. */
  87819. setDepthFunctionToLessOrEqual(): void;
  87820. /**
  87821. * Gets a boolean indicating if stencil buffer is enabled
  87822. * @returns the current stencil buffer state
  87823. */
  87824. getStencilBuffer(): boolean;
  87825. /**
  87826. * Enable or disable the stencil buffer
  87827. * @param enable defines if the stencil buffer must be enabled or disabled
  87828. */
  87829. setStencilBuffer(enable: boolean): void;
  87830. /**
  87831. * Gets the current stencil mask
  87832. * @returns a number defining the new stencil mask to use
  87833. */
  87834. getStencilMask(): number;
  87835. /**
  87836. * Sets the current stencil mask
  87837. * @param mask defines the new stencil mask to use
  87838. */
  87839. setStencilMask(mask: number): void;
  87840. /**
  87841. * Gets the current stencil function
  87842. * @returns a number defining the stencil function to use
  87843. */
  87844. getStencilFunction(): number;
  87845. /**
  87846. * Gets the current stencil reference value
  87847. * @returns a number defining the stencil reference value to use
  87848. */
  87849. getStencilFunctionReference(): number;
  87850. /**
  87851. * Gets the current stencil mask
  87852. * @returns a number defining the stencil mask to use
  87853. */
  87854. getStencilFunctionMask(): number;
  87855. /**
  87856. * Sets the current stencil function
  87857. * @param stencilFunc defines the new stencil function to use
  87858. */
  87859. setStencilFunction(stencilFunc: number): void;
  87860. /**
  87861. * Sets the current stencil reference
  87862. * @param reference defines the new stencil reference to use
  87863. */
  87864. setStencilFunctionReference(reference: number): void;
  87865. /**
  87866. * Sets the current stencil mask
  87867. * @param mask defines the new stencil mask to use
  87868. */
  87869. setStencilFunctionMask(mask: number): void;
  87870. /**
  87871. * Gets the current stencil operation when stencil fails
  87872. * @returns a number defining stencil operation to use when stencil fails
  87873. */
  87874. getStencilOperationFail(): number;
  87875. /**
  87876. * Gets the current stencil operation when depth fails
  87877. * @returns a number defining stencil operation to use when depth fails
  87878. */
  87879. getStencilOperationDepthFail(): number;
  87880. /**
  87881. * Gets the current stencil operation when stencil passes
  87882. * @returns a number defining stencil operation to use when stencil passes
  87883. */
  87884. getStencilOperationPass(): number;
  87885. /**
  87886. * Sets the stencil operation to use when stencil fails
  87887. * @param operation defines the stencil operation to use when stencil fails
  87888. */
  87889. setStencilOperationFail(operation: number): void;
  87890. /**
  87891. * Sets the stencil operation to use when depth fails
  87892. * @param operation defines the stencil operation to use when depth fails
  87893. */
  87894. setStencilOperationDepthFail(operation: number): void;
  87895. /**
  87896. * Sets the stencil operation to use when stencil passes
  87897. * @param operation defines the stencil operation to use when stencil passes
  87898. */
  87899. setStencilOperationPass(operation: number): void;
  87900. /**
  87901. * Sets a boolean indicating if the dithering state is enabled or disabled
  87902. * @param value defines the dithering state
  87903. */
  87904. setDitheringState(value: boolean): void;
  87905. /**
  87906. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87907. * @param value defines the rasterizer state
  87908. */
  87909. setRasterizerState(value: boolean): void;
  87910. /**
  87911. * stop executing a render loop function and remove it from the execution array
  87912. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87913. */
  87914. stopRenderLoop(renderFunction?: () => void): void;
  87915. /** @hidden */
  87916. _renderLoop(): void;
  87917. /**
  87918. * Register and execute a render loop. The engine can have more than one render function
  87919. * @param renderFunction defines the function to continuously execute
  87920. */
  87921. runRenderLoop(renderFunction: () => void): void;
  87922. /**
  87923. * Toggle full screen mode
  87924. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87925. */
  87926. switchFullscreen(requestPointerLock: boolean): void;
  87927. /**
  87928. * Enters full screen mode
  87929. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87930. */
  87931. enterFullscreen(requestPointerLock: boolean): void;
  87932. /**
  87933. * Exits full screen mode
  87934. */
  87935. exitFullscreen(): void;
  87936. /**
  87937. * Clear the current render buffer or the current render target (if any is set up)
  87938. * @param color defines the color to use
  87939. * @param backBuffer defines if the back buffer must be cleared
  87940. * @param depth defines if the depth buffer must be cleared
  87941. * @param stencil defines if the stencil buffer must be cleared
  87942. */
  87943. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87944. /**
  87945. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87946. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87947. * @param y defines the y-coordinate of the corner of the clear rectangle
  87948. * @param width defines the width of the clear rectangle
  87949. * @param height defines the height of the clear rectangle
  87950. * @param clearColor defines the clear color
  87951. */
  87952. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87953. /**
  87954. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87955. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87956. * @param y defines the y-coordinate of the corner of the clear rectangle
  87957. * @param width defines the width of the clear rectangle
  87958. * @param height defines the height of the clear rectangle
  87959. */
  87960. enableScissor(x: number, y: number, width: number, height: number): void;
  87961. /**
  87962. * Disable previously set scissor test rectangle
  87963. */
  87964. disableScissor(): void;
  87965. private _viewportCached;
  87966. /** @hidden */
  87967. _viewport(x: number, y: number, width: number, height: number): void;
  87968. /**
  87969. * Set the WebGL's viewport
  87970. * @param viewport defines the viewport element to be used
  87971. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87972. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87973. */
  87974. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87975. /**
  87976. * Directly set the WebGL Viewport
  87977. * @param x defines the x coordinate of the viewport (in screen space)
  87978. * @param y defines the y coordinate of the viewport (in screen space)
  87979. * @param width defines the width of the viewport (in screen space)
  87980. * @param height defines the height of the viewport (in screen space)
  87981. * @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
  87982. */
  87983. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87984. /**
  87985. * Begin a new frame
  87986. */
  87987. beginFrame(): void;
  87988. /**
  87989. * Enf the current frame
  87990. */
  87991. endFrame(): void;
  87992. /**
  87993. * Resize the view according to the canvas' size
  87994. */
  87995. resize(): void;
  87996. /**
  87997. * Force a specific size of the canvas
  87998. * @param width defines the new canvas' width
  87999. * @param height defines the new canvas' height
  88000. */
  88001. setSize(width: number, height: number): void;
  88002. /**
  88003. * Binds the frame buffer to the specified texture.
  88004. * @param texture The texture to render to or null for the default canvas
  88005. * @param faceIndex The face of the texture to render to in case of cube texture
  88006. * @param requiredWidth The width of the target to render to
  88007. * @param requiredHeight The height of the target to render to
  88008. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  88009. * @param depthStencilTexture The depth stencil texture to use to render
  88010. * @param lodLevel defines le lod level to bind to the frame buffer
  88011. */
  88012. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  88013. /** @hidden */
  88014. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  88015. /**
  88016. * Unbind the current render target texture from the webGL context
  88017. * @param texture defines the render target texture to unbind
  88018. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  88019. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  88020. */
  88021. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  88022. /**
  88023. * Force the mipmap generation for the given render target texture
  88024. * @param texture defines the render target texture to use
  88025. */
  88026. generateMipMapsForCubemap(texture: InternalTexture): void;
  88027. /**
  88028. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  88029. */
  88030. flushFramebuffer(): void;
  88031. /**
  88032. * Unbind the current render target and bind the default framebuffer
  88033. */
  88034. restoreDefaultFramebuffer(): void;
  88035. /**
  88036. * Create an uniform buffer
  88037. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88038. * @param elements defines the content of the uniform buffer
  88039. * @returns the webGL uniform buffer
  88040. */
  88041. createUniformBuffer(elements: FloatArray): DataBuffer;
  88042. /**
  88043. * Create a dynamic uniform buffer
  88044. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88045. * @param elements defines the content of the uniform buffer
  88046. * @returns the webGL uniform buffer
  88047. */
  88048. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88049. /**
  88050. * Update an existing uniform buffer
  88051. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88052. * @param uniformBuffer defines the target uniform buffer
  88053. * @param elements defines the content to update
  88054. * @param offset defines the offset in the uniform buffer where update should start
  88055. * @param count defines the size of the data to update
  88056. */
  88057. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88058. private _resetVertexBufferBinding;
  88059. /**
  88060. * Creates a vertex buffer
  88061. * @param data the data for the vertex buffer
  88062. * @returns the new WebGL static buffer
  88063. */
  88064. createVertexBuffer(data: DataArray): DataBuffer;
  88065. /**
  88066. * Creates a dynamic vertex buffer
  88067. * @param data the data for the dynamic vertex buffer
  88068. * @returns the new WebGL dynamic buffer
  88069. */
  88070. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  88071. /**
  88072. * Update a dynamic index buffer
  88073. * @param indexBuffer defines the target index buffer
  88074. * @param indices defines the data to update
  88075. * @param offset defines the offset in the target index buffer where update should start
  88076. */
  88077. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  88078. /**
  88079. * Updates a dynamic vertex buffer.
  88080. * @param vertexBuffer the vertex buffer to update
  88081. * @param data the data used to update the vertex buffer
  88082. * @param byteOffset the byte offset of the data
  88083. * @param byteLength the byte length of the data
  88084. */
  88085. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  88086. private _resetIndexBufferBinding;
  88087. /**
  88088. * Creates a new index buffer
  88089. * @param indices defines the content of the index buffer
  88090. * @param updatable defines if the index buffer must be updatable
  88091. * @returns a new webGL buffer
  88092. */
  88093. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  88094. /**
  88095. * Bind a webGL buffer to the webGL context
  88096. * @param buffer defines the buffer to bind
  88097. */
  88098. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  88099. /**
  88100. * Bind an uniform buffer to the current webGL context
  88101. * @param buffer defines the buffer to bind
  88102. */
  88103. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88104. /**
  88105. * Bind a buffer to the current webGL context at a given location
  88106. * @param buffer defines the buffer to bind
  88107. * @param location defines the index where to bind the buffer
  88108. */
  88109. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88110. /**
  88111. * Bind a specific block at a given index in a specific shader program
  88112. * @param pipelineContext defines the pipeline context to use
  88113. * @param blockName defines the block name
  88114. * @param index defines the index where to bind the block
  88115. */
  88116. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88117. private bindIndexBuffer;
  88118. private bindBuffer;
  88119. /**
  88120. * update the bound buffer with the given data
  88121. * @param data defines the data to update
  88122. */
  88123. updateArrayBuffer(data: Float32Array): void;
  88124. private _vertexAttribPointer;
  88125. private _bindIndexBufferWithCache;
  88126. private _bindVertexBuffersAttributes;
  88127. /**
  88128. * Records a vertex array object
  88129. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88130. * @param vertexBuffers defines the list of vertex buffers to store
  88131. * @param indexBuffer defines the index buffer to store
  88132. * @param effect defines the effect to store
  88133. * @returns the new vertex array object
  88134. */
  88135. recordVertexArrayObject(vertexBuffers: {
  88136. [key: string]: VertexBuffer;
  88137. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  88138. /**
  88139. * Bind a specific vertex array object
  88140. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88141. * @param vertexArrayObject defines the vertex array object to bind
  88142. * @param indexBuffer defines the index buffer to bind
  88143. */
  88144. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  88145. /**
  88146. * Bind webGl buffers directly to the webGL context
  88147. * @param vertexBuffer defines the vertex buffer to bind
  88148. * @param indexBuffer defines the index buffer to bind
  88149. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  88150. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  88151. * @param effect defines the effect associated with the vertex buffer
  88152. */
  88153. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  88154. private _unbindVertexArrayObject;
  88155. /**
  88156. * Bind a list of vertex buffers to the webGL context
  88157. * @param vertexBuffers defines the list of vertex buffers to bind
  88158. * @param indexBuffer defines the index buffer to bind
  88159. * @param effect defines the effect associated with the vertex buffers
  88160. */
  88161. bindBuffers(vertexBuffers: {
  88162. [key: string]: Nullable<VertexBuffer>;
  88163. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  88164. /**
  88165. * Unbind all instance attributes
  88166. */
  88167. unbindInstanceAttributes(): void;
  88168. /**
  88169. * Release and free the memory of a vertex array object
  88170. * @param vao defines the vertex array object to delete
  88171. */
  88172. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  88173. /** @hidden */
  88174. _releaseBuffer(buffer: DataBuffer): boolean;
  88175. /**
  88176. * Creates a webGL buffer to use with instanciation
  88177. * @param capacity defines the size of the buffer
  88178. * @returns the webGL buffer
  88179. */
  88180. createInstancesBuffer(capacity: number): DataBuffer;
  88181. /**
  88182. * Delete a webGL buffer used with instanciation
  88183. * @param buffer defines the webGL buffer to delete
  88184. */
  88185. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  88186. /**
  88187. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  88188. * @param instancesBuffer defines the webGL buffer to update and bind
  88189. * @param data defines the data to store in the buffer
  88190. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  88191. */
  88192. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  88193. /**
  88194. * Apply all cached states (depth, culling, stencil and alpha)
  88195. */
  88196. applyStates(): void;
  88197. /**
  88198. * Send a draw order
  88199. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88200. * @param indexStart defines the starting index
  88201. * @param indexCount defines the number of index to draw
  88202. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88203. */
  88204. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  88205. /**
  88206. * Draw a list of points
  88207. * @param verticesStart defines the index of first vertex to draw
  88208. * @param verticesCount defines the count of vertices to draw
  88209. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88210. */
  88211. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88212. /**
  88213. * Draw a list of unindexed primitives
  88214. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88215. * @param verticesStart defines the index of first vertex to draw
  88216. * @param verticesCount defines the count of vertices to draw
  88217. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88218. */
  88219. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88220. /**
  88221. * Draw a list of indexed primitives
  88222. * @param fillMode defines the primitive to use
  88223. * @param indexStart defines the starting index
  88224. * @param indexCount defines the number of index to draw
  88225. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88226. */
  88227. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  88228. /**
  88229. * Draw a list of unindexed primitives
  88230. * @param fillMode defines the primitive to use
  88231. * @param verticesStart defines the index of first vertex to draw
  88232. * @param verticesCount defines the count of vertices to draw
  88233. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88234. */
  88235. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88236. private _drawMode;
  88237. /** @hidden */
  88238. _releaseEffect(effect: Effect): void;
  88239. /** @hidden */
  88240. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  88241. /**
  88242. * Create a new effect (used to store vertex/fragment shaders)
  88243. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  88244. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  88245. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  88246. * @param samplers defines an array of string used to represent textures
  88247. * @param defines defines the string containing the defines to use to compile the shaders
  88248. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  88249. * @param onCompiled defines a function to call when the effect creation is successful
  88250. * @param onError defines a function to call when the effect creation has failed
  88251. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  88252. * @returns the new Effect
  88253. */
  88254. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  88255. private _compileShader;
  88256. private _compileRawShader;
  88257. /**
  88258. * Directly creates a webGL program
  88259. * @param pipelineContext defines the pipeline context to attach to
  88260. * @param vertexCode defines the vertex shader code to use
  88261. * @param fragmentCode defines the fragment shader code to use
  88262. * @param context defines the webGL context to use (if not set, the current one will be used)
  88263. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88264. * @returns the new webGL program
  88265. */
  88266. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88267. /**
  88268. * Creates a webGL program
  88269. * @param pipelineContext defines the pipeline context to attach to
  88270. * @param vertexCode defines the vertex shader code to use
  88271. * @param fragmentCode defines the fragment shader code to use
  88272. * @param defines defines the string containing the defines to use to compile the shaders
  88273. * @param context defines the webGL context to use (if not set, the current one will be used)
  88274. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88275. * @returns the new webGL program
  88276. */
  88277. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88278. /**
  88279. * Creates a new pipeline context
  88280. * @returns the new pipeline
  88281. */
  88282. createPipelineContext(): WebGLPipelineContext;
  88283. private _createShaderProgram;
  88284. private _finalizePipelineContext;
  88285. /** @hidden */
  88286. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  88287. /** @hidden */
  88288. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  88289. /** @hidden */
  88290. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  88291. /**
  88292. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  88293. * @param pipelineContext defines the pipeline context to use
  88294. * @param uniformsNames defines the list of uniform names
  88295. * @returns an array of webGL uniform locations
  88296. */
  88297. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  88298. /**
  88299. * Gets the lsit of active attributes for a given webGL program
  88300. * @param pipelineContext defines the pipeline context to use
  88301. * @param attributesNames defines the list of attribute names to get
  88302. * @returns an array of indices indicating the offset of each attribute
  88303. */
  88304. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  88305. /**
  88306. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  88307. * @param effect defines the effect to activate
  88308. */
  88309. enableEffect(effect: Nullable<Effect>): void;
  88310. /**
  88311. * Set the value of an uniform to an array of int32
  88312. * @param uniform defines the webGL uniform location where to store the value
  88313. * @param array defines the array of int32 to store
  88314. */
  88315. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88316. /**
  88317. * Set the value of an uniform to an array of int32 (stored as vec2)
  88318. * @param uniform defines the webGL uniform location where to store the value
  88319. * @param array defines the array of int32 to store
  88320. */
  88321. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88322. /**
  88323. * Set the value of an uniform to an array of int32 (stored as vec3)
  88324. * @param uniform defines the webGL uniform location where to store the value
  88325. * @param array defines the array of int32 to store
  88326. */
  88327. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88328. /**
  88329. * Set the value of an uniform to an array of int32 (stored as vec4)
  88330. * @param uniform defines the webGL uniform location where to store the value
  88331. * @param array defines the array of int32 to store
  88332. */
  88333. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88334. /**
  88335. * Set the value of an uniform to an array of float32
  88336. * @param uniform defines the webGL uniform location where to store the value
  88337. * @param array defines the array of float32 to store
  88338. */
  88339. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88340. /**
  88341. * Set the value of an uniform to an array of float32 (stored as vec2)
  88342. * @param uniform defines the webGL uniform location where to store the value
  88343. * @param array defines the array of float32 to store
  88344. */
  88345. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88346. /**
  88347. * Set the value of an uniform to an array of float32 (stored as vec3)
  88348. * @param uniform defines the webGL uniform location where to store the value
  88349. * @param array defines the array of float32 to store
  88350. */
  88351. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88352. /**
  88353. * Set the value of an uniform to an array of float32 (stored as vec4)
  88354. * @param uniform defines the webGL uniform location where to store the value
  88355. * @param array defines the array of float32 to store
  88356. */
  88357. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88358. /**
  88359. * Set the value of an uniform to an array of number
  88360. * @param uniform defines the webGL uniform location where to store the value
  88361. * @param array defines the array of number to store
  88362. */
  88363. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88364. /**
  88365. * Set the value of an uniform to an array of number (stored as vec2)
  88366. * @param uniform defines the webGL uniform location where to store the value
  88367. * @param array defines the array of number to store
  88368. */
  88369. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88370. /**
  88371. * Set the value of an uniform to an array of number (stored as vec3)
  88372. * @param uniform defines the webGL uniform location where to store the value
  88373. * @param array defines the array of number to store
  88374. */
  88375. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88376. /**
  88377. * Set the value of an uniform to an array of number (stored as vec4)
  88378. * @param uniform defines the webGL uniform location where to store the value
  88379. * @param array defines the array of number to store
  88380. */
  88381. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88382. /**
  88383. * Set the value of an uniform to an array of float32 (stored as matrices)
  88384. * @param uniform defines the webGL uniform location where to store the value
  88385. * @param matrices defines the array of float32 to store
  88386. */
  88387. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  88388. /**
  88389. * Set the value of an uniform to a matrix
  88390. * @param uniform defines the webGL uniform location where to store the value
  88391. * @param matrix defines the matrix to store
  88392. */
  88393. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  88394. /**
  88395. * Set the value of an uniform to a matrix (3x3)
  88396. * @param uniform defines the webGL uniform location where to store the value
  88397. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  88398. */
  88399. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88400. /**
  88401. * Set the value of an uniform to a matrix (2x2)
  88402. * @param uniform defines the webGL uniform location where to store the value
  88403. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  88404. */
  88405. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88406. /**
  88407. * Set the value of an uniform to a number (int)
  88408. * @param uniform defines the webGL uniform location where to store the value
  88409. * @param value defines the int number to store
  88410. */
  88411. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88412. /**
  88413. * Set the value of an uniform to a number (float)
  88414. * @param uniform defines the webGL uniform location where to store the value
  88415. * @param value defines the float number to store
  88416. */
  88417. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88418. /**
  88419. * Set the value of an uniform to a vec2
  88420. * @param uniform defines the webGL uniform location where to store the value
  88421. * @param x defines the 1st component of the value
  88422. * @param y defines the 2nd component of the value
  88423. */
  88424. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  88425. /**
  88426. * Set the value of an uniform to a vec3
  88427. * @param uniform defines the webGL uniform location where to store the value
  88428. * @param x defines the 1st component of the value
  88429. * @param y defines the 2nd component of the value
  88430. * @param z defines the 3rd component of the value
  88431. */
  88432. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  88433. /**
  88434. * Set the value of an uniform to a boolean
  88435. * @param uniform defines the webGL uniform location where to store the value
  88436. * @param bool defines the boolean to store
  88437. */
  88438. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  88439. /**
  88440. * Set the value of an uniform to a vec4
  88441. * @param uniform defines the webGL uniform location where to store the value
  88442. * @param x defines the 1st component of the value
  88443. * @param y defines the 2nd component of the value
  88444. * @param z defines the 3rd component of the value
  88445. * @param w defines the 4th component of the value
  88446. */
  88447. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  88448. /**
  88449. * Set the value of an uniform to a Color3
  88450. * @param uniform defines the webGL uniform location where to store the value
  88451. * @param color3 defines the color to store
  88452. */
  88453. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  88454. /**
  88455. * Set the value of an uniform to a Color3 and an alpha value
  88456. * @param uniform defines the webGL uniform location where to store the value
  88457. * @param color3 defines the color to store
  88458. * @param alpha defines the alpha component to store
  88459. */
  88460. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  88461. /**
  88462. * Sets a Color4 on a uniform variable
  88463. * @param uniform defines the uniform location
  88464. * @param color4 defines the value to be set
  88465. */
  88466. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  88467. /**
  88468. * Set various states to the webGL context
  88469. * @param culling defines backface culling state
  88470. * @param zOffset defines the value to apply to zOffset (0 by default)
  88471. * @param force defines if states must be applied even if cache is up to date
  88472. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  88473. */
  88474. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  88475. /**
  88476. * Set the z offset to apply to current rendering
  88477. * @param value defines the offset to apply
  88478. */
  88479. setZOffset(value: number): void;
  88480. /**
  88481. * Gets the current value of the zOffset
  88482. * @returns the current zOffset state
  88483. */
  88484. getZOffset(): number;
  88485. /**
  88486. * Enable or disable depth buffering
  88487. * @param enable defines the state to set
  88488. */
  88489. setDepthBuffer(enable: boolean): void;
  88490. /**
  88491. * Gets a boolean indicating if depth writing is enabled
  88492. * @returns the current depth writing state
  88493. */
  88494. getDepthWrite(): boolean;
  88495. /**
  88496. * Enable or disable depth writing
  88497. * @param enable defines the state to set
  88498. */
  88499. setDepthWrite(enable: boolean): void;
  88500. /**
  88501. * Enable or disable color writing
  88502. * @param enable defines the state to set
  88503. */
  88504. setColorWrite(enable: boolean): void;
  88505. /**
  88506. * Gets a boolean indicating if color writing is enabled
  88507. * @returns the current color writing state
  88508. */
  88509. getColorWrite(): boolean;
  88510. /**
  88511. * Sets alpha constants used by some alpha blending modes
  88512. * @param r defines the red component
  88513. * @param g defines the green component
  88514. * @param b defines the blue component
  88515. * @param a defines the alpha component
  88516. */
  88517. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  88518. /**
  88519. * Sets the current alpha mode
  88520. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  88521. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  88522. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88523. */
  88524. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  88525. /**
  88526. * Gets the current alpha mode
  88527. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88528. * @returns the current alpha mode
  88529. */
  88530. getAlphaMode(): number;
  88531. /**
  88532. * Clears the list of texture accessible through engine.
  88533. * This can help preventing texture load conflict due to name collision.
  88534. */
  88535. clearInternalTexturesCache(): void;
  88536. /**
  88537. * Force the entire cache to be cleared
  88538. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  88539. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  88540. */
  88541. wipeCaches(bruteForce?: boolean): void;
  88542. /**
  88543. * Set the compressed texture format to use, based on the formats you have, and the formats
  88544. * supported by the hardware / browser.
  88545. *
  88546. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  88547. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  88548. * to API arguments needed to compressed textures. This puts the burden on the container
  88549. * generator to house the arcane code for determining these for current & future formats.
  88550. *
  88551. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  88552. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  88553. *
  88554. * Note: The result of this call is not taken into account when a texture is base64.
  88555. *
  88556. * @param formatsAvailable defines the list of those format families you have created
  88557. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  88558. *
  88559. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  88560. * @returns The extension selected.
  88561. */
  88562. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  88563. /** @hidden */
  88564. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  88565. min: number;
  88566. mag: number;
  88567. };
  88568. /** @hidden */
  88569. _createTexture(): WebGLTexture;
  88570. /**
  88571. * Usually called from Texture.ts.
  88572. * Passed information to create a WebGLTexture
  88573. * @param urlArg defines a value which contains one of the following:
  88574. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  88575. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  88576. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  88577. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  88578. * @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)
  88579. * @param scene needed for loading to the correct scene
  88580. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  88581. * @param onLoad optional callback to be called upon successful completion
  88582. * @param onError optional callback to be called upon failure
  88583. * @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
  88584. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  88585. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  88586. * @param forcedExtension defines the extension to use to pick the right loader
  88587. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  88588. * @returns a InternalTexture for assignment back into BABYLON.Texture
  88589. */
  88590. 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;
  88591. private _rescaleTexture;
  88592. private _unpackFlipYCached;
  88593. /**
  88594. * In case you are sharing the context with other applications, it might
  88595. * be interested to not cache the unpack flip y state to ensure a consistent
  88596. * value would be set.
  88597. */
  88598. enableUnpackFlipYCached: boolean;
  88599. /** @hidden */
  88600. _unpackFlipY(value: boolean): void;
  88601. /** @hidden */
  88602. _getUnpackAlignement(): number;
  88603. /**
  88604. * Creates a dynamic texture
  88605. * @param width defines the width of the texture
  88606. * @param height defines the height of the texture
  88607. * @param generateMipMaps defines if the engine should generate the mip levels
  88608. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88609. * @returns the dynamic texture inside an InternalTexture
  88610. */
  88611. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88612. /**
  88613. * Update the sampling mode of a given texture
  88614. * @param samplingMode defines the required sampling mode
  88615. * @param texture defines the texture to update
  88616. */
  88617. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  88618. /**
  88619. * Update the content of a dynamic texture
  88620. * @param texture defines the texture to update
  88621. * @param canvas defines the canvas containing the source
  88622. * @param invertY defines if data must be stored with Y axis inverted
  88623. * @param premulAlpha defines if alpha is stored as premultiplied
  88624. * @param format defines the format of the data
  88625. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88626. */
  88627. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88628. /**
  88629. * Update a video texture
  88630. * @param texture defines the texture to update
  88631. * @param video defines the video element to use
  88632. * @param invertY defines if data must be stored with Y axis inverted
  88633. */
  88634. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  88635. /**
  88636. * Updates a depth texture Comparison Mode and Function.
  88637. * If the comparison Function is equal to 0, the mode will be set to none.
  88638. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  88639. * @param texture The texture to set the comparison function for
  88640. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  88641. */
  88642. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  88643. /** @hidden */
  88644. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  88645. width: number;
  88646. height: number;
  88647. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  88648. /**
  88649. * Creates a depth stencil texture.
  88650. * This is only available in WebGL 2 or with the depth texture extension available.
  88651. * @param size The size of face edge in the texture.
  88652. * @param options The options defining the texture.
  88653. * @returns The texture
  88654. */
  88655. createDepthStencilTexture(size: number | {
  88656. width: number;
  88657. height: number;
  88658. }, options: DepthTextureCreationOptions): InternalTexture;
  88659. /**
  88660. * Creates a depth stencil texture.
  88661. * This is only available in WebGL 2 or with the depth texture extension available.
  88662. * @param size The size of face edge in the texture.
  88663. * @param options The options defining the texture.
  88664. * @returns The texture
  88665. */
  88666. private _createDepthStencilTexture;
  88667. /**
  88668. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  88669. * @param renderTarget The render target to set the frame buffer for
  88670. */
  88671. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  88672. /**
  88673. * Creates a new render target texture
  88674. * @param size defines the size of the texture
  88675. * @param options defines the options used to create the texture
  88676. * @returns a new render target texture stored in an InternalTexture
  88677. */
  88678. createRenderTargetTexture(size: number | {
  88679. width: number;
  88680. height: number;
  88681. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88682. /** @hidden */
  88683. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  88684. /**
  88685. * Updates the sample count of a render target texture
  88686. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  88687. * @param texture defines the texture to update
  88688. * @param samples defines the sample count to set
  88689. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  88690. */
  88691. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  88692. /** @hidden */
  88693. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88694. /** @hidden */
  88695. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88696. /** @hidden */
  88697. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88698. /** @hidden */
  88699. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  88700. /**
  88701. * @hidden
  88702. */
  88703. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88704. private _prepareWebGLTextureContinuation;
  88705. private _prepareWebGLTexture;
  88706. /** @hidden */
  88707. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  88708. /** @hidden */
  88709. _releaseFramebufferObjects(texture: InternalTexture): void;
  88710. /** @hidden */
  88711. _releaseTexture(texture: InternalTexture): void;
  88712. private setProgram;
  88713. private _boundUniforms;
  88714. /**
  88715. * Binds an effect to the webGL context
  88716. * @param effect defines the effect to bind
  88717. */
  88718. bindSamplers(effect: Effect): void;
  88719. private _activateCurrentTexture;
  88720. /** @hidden */
  88721. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88722. /** @hidden */
  88723. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88724. /**
  88725. * Sets a texture to the webGL context from a postprocess
  88726. * @param channel defines the channel to use
  88727. * @param postProcess defines the source postprocess
  88728. */
  88729. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88730. /**
  88731. * Binds the output of the passed in post process to the texture channel specified
  88732. * @param channel The channel the texture should be bound to
  88733. * @param postProcess The post process which's output should be bound
  88734. */
  88735. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88736. /**
  88737. * Unbind all textures from the webGL context
  88738. */
  88739. unbindAllTextures(): void;
  88740. /**
  88741. * Sets a texture to the according uniform.
  88742. * @param channel The texture channel
  88743. * @param uniform The uniform to set
  88744. * @param texture The texture to apply
  88745. */
  88746. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88747. /**
  88748. * Sets a depth stencil texture from a render target to the according uniform.
  88749. * @param channel The texture channel
  88750. * @param uniform The uniform to set
  88751. * @param texture The render target texture containing the depth stencil texture to apply
  88752. */
  88753. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88754. private _bindSamplerUniformToChannel;
  88755. private _getTextureWrapMode;
  88756. private _setTexture;
  88757. /**
  88758. * Sets an array of texture to the webGL context
  88759. * @param channel defines the channel where the texture array must be set
  88760. * @param uniform defines the associated uniform location
  88761. * @param textures defines the array of textures to bind
  88762. */
  88763. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88764. /** @hidden */
  88765. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88766. private _setTextureParameterFloat;
  88767. private _setTextureParameterInteger;
  88768. /**
  88769. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88770. * @param x defines the x coordinate of the rectangle where pixels must be read
  88771. * @param y defines the y coordinate of the rectangle where pixels must be read
  88772. * @param width defines the width of the rectangle where pixels must be read
  88773. * @param height defines the height of the rectangle where pixels must be read
  88774. * @returns a Uint8Array containing RGBA colors
  88775. */
  88776. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88777. /**
  88778. * Add an externaly attached data from its key.
  88779. * This method call will fail and return false, if such key already exists.
  88780. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88781. * @param key the unique key that identifies the data
  88782. * @param data the data object to associate to the key for this Engine instance
  88783. * @return true if no such key were already present and the data was added successfully, false otherwise
  88784. */
  88785. addExternalData<T>(key: string, data: T): boolean;
  88786. /**
  88787. * Get an externaly attached data from its key
  88788. * @param key the unique key that identifies the data
  88789. * @return the associated data, if present (can be null), or undefined if not present
  88790. */
  88791. getExternalData<T>(key: string): T;
  88792. /**
  88793. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88794. * @param key the unique key that identifies the data
  88795. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88796. * @return the associated data, can be null if the factory returned null.
  88797. */
  88798. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88799. /**
  88800. * Remove an externaly attached data from the Engine instance
  88801. * @param key the unique key that identifies the data
  88802. * @return true if the data was successfully removed, false if it doesn't exist
  88803. */
  88804. removeExternalData(key: string): boolean;
  88805. /**
  88806. * Unbind all vertex attributes from the webGL context
  88807. */
  88808. unbindAllAttributes(): void;
  88809. /**
  88810. * 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
  88811. */
  88812. releaseEffects(): void;
  88813. /**
  88814. * Dispose and release all associated resources
  88815. */
  88816. dispose(): void;
  88817. /**
  88818. * Display the loading screen
  88819. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88820. */
  88821. displayLoadingUI(): void;
  88822. /**
  88823. * Hide the loading screen
  88824. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88825. */
  88826. hideLoadingUI(): void;
  88827. /**
  88828. * Gets the current loading screen object
  88829. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88830. */
  88831. /**
  88832. * Sets the current loading screen object
  88833. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88834. */
  88835. loadingScreen: ILoadingScreen;
  88836. /**
  88837. * Sets the current loading screen text
  88838. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88839. */
  88840. loadingUIText: string;
  88841. /**
  88842. * Sets the current loading screen background color
  88843. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88844. */
  88845. loadingUIBackgroundColor: string;
  88846. /**
  88847. * Attach a new callback raised when context lost event is fired
  88848. * @param callback defines the callback to call
  88849. */
  88850. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88851. /**
  88852. * Attach a new callback raised when context restored event is fired
  88853. * @param callback defines the callback to call
  88854. */
  88855. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88856. /**
  88857. * Gets the source code of the vertex shader associated with a specific webGL program
  88858. * @param program defines the program to use
  88859. * @returns a string containing the source code of the vertex shader associated with the program
  88860. */
  88861. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88862. /**
  88863. * Gets the source code of the fragment shader associated with a specific webGL program
  88864. * @param program defines the program to use
  88865. * @returns a string containing the source code of the fragment shader associated with the program
  88866. */
  88867. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88868. /**
  88869. * Get the current error code of the webGL context
  88870. * @returns the error code
  88871. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88872. */
  88873. getError(): number;
  88874. /**
  88875. * Gets the current framerate
  88876. * @returns a number representing the framerate
  88877. */
  88878. getFps(): number;
  88879. /**
  88880. * Gets the time spent between current and previous frame
  88881. * @returns a number representing the delta time in ms
  88882. */
  88883. getDeltaTime(): number;
  88884. private _measureFps;
  88885. /** @hidden */
  88886. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88887. private _canRenderToFloatFramebuffer;
  88888. private _canRenderToHalfFloatFramebuffer;
  88889. private _canRenderToFramebuffer;
  88890. /** @hidden */
  88891. _getWebGLTextureType(type: number): number;
  88892. /** @hidden */
  88893. _getInternalFormat(format: number): number;
  88894. /** @hidden */
  88895. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88896. /** @hidden */
  88897. _getRGBAMultiSampleBufferFormat(type: number): number;
  88898. /** @hidden */
  88899. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  88900. /** @hidden */
  88901. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88902. /**
  88903. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88904. * @returns true if the engine can be created
  88905. * @ignorenaming
  88906. */
  88907. static isSupported(): boolean;
  88908. }
  88909. }
  88910. declare module BABYLON {
  88911. /**
  88912. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88913. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88914. */
  88915. export class EffectFallbacks {
  88916. private _defines;
  88917. private _currentRank;
  88918. private _maxRank;
  88919. private _mesh;
  88920. /**
  88921. * Removes the fallback from the bound mesh.
  88922. */
  88923. unBindMesh(): void;
  88924. /**
  88925. * Adds a fallback on the specified property.
  88926. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88927. * @param define The name of the define in the shader
  88928. */
  88929. addFallback(rank: number, define: string): void;
  88930. /**
  88931. * Sets the mesh to use CPU skinning when needing to fallback.
  88932. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88933. * @param mesh The mesh to use the fallbacks.
  88934. */
  88935. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88936. /**
  88937. * Checks to see if more fallbacks are still availible.
  88938. */
  88939. readonly isMoreFallbacks: boolean;
  88940. /**
  88941. * Removes the defines that shoould be removed when falling back.
  88942. * @param currentDefines defines the current define statements for the shader.
  88943. * @param effect defines the current effect we try to compile
  88944. * @returns The resulting defines with defines of the current rank removed.
  88945. */
  88946. reduce(currentDefines: string, effect: Effect): string;
  88947. }
  88948. /**
  88949. * Options to be used when creating an effect.
  88950. */
  88951. export class EffectCreationOptions {
  88952. /**
  88953. * Atrributes that will be used in the shader.
  88954. */
  88955. attributes: string[];
  88956. /**
  88957. * Uniform varible names that will be set in the shader.
  88958. */
  88959. uniformsNames: string[];
  88960. /**
  88961. * Uniform buffer varible names that will be set in the shader.
  88962. */
  88963. uniformBuffersNames: string[];
  88964. /**
  88965. * Sampler texture variable names that will be set in the shader.
  88966. */
  88967. samplers: string[];
  88968. /**
  88969. * Define statements that will be set in the shader.
  88970. */
  88971. defines: any;
  88972. /**
  88973. * Possible fallbacks for this effect to improve performance when needed.
  88974. */
  88975. fallbacks: Nullable<EffectFallbacks>;
  88976. /**
  88977. * Callback that will be called when the shader is compiled.
  88978. */
  88979. onCompiled: Nullable<(effect: Effect) => void>;
  88980. /**
  88981. * Callback that will be called if an error occurs during shader compilation.
  88982. */
  88983. onError: Nullable<(effect: Effect, errors: string) => void>;
  88984. /**
  88985. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88986. */
  88987. indexParameters: any;
  88988. /**
  88989. * Max number of lights that can be used in the shader.
  88990. */
  88991. maxSimultaneousLights: number;
  88992. /**
  88993. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88994. */
  88995. transformFeedbackVaryings: Nullable<string[]>;
  88996. }
  88997. /**
  88998. * Effect containing vertex and fragment shader that can be executed on an object.
  88999. */
  89000. export class Effect implements IDisposable {
  89001. /**
  89002. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  89003. */
  89004. static ShadersRepository: string;
  89005. /**
  89006. * Name of the effect.
  89007. */
  89008. name: any;
  89009. /**
  89010. * String container all the define statements that should be set on the shader.
  89011. */
  89012. defines: string;
  89013. /**
  89014. * Callback that will be called when the shader is compiled.
  89015. */
  89016. onCompiled: Nullable<(effect: Effect) => void>;
  89017. /**
  89018. * Callback that will be called if an error occurs during shader compilation.
  89019. */
  89020. onError: Nullable<(effect: Effect, errors: string) => void>;
  89021. /**
  89022. * Callback that will be called when effect is bound.
  89023. */
  89024. onBind: Nullable<(effect: Effect) => void>;
  89025. /**
  89026. * Unique ID of the effect.
  89027. */
  89028. uniqueId: number;
  89029. /**
  89030. * Observable that will be called when the shader is compiled.
  89031. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  89032. */
  89033. onCompileObservable: Observable<Effect>;
  89034. /**
  89035. * Observable that will be called if an error occurs during shader compilation.
  89036. */
  89037. onErrorObservable: Observable<Effect>;
  89038. /** @hidden */
  89039. _onBindObservable: Nullable<Observable<Effect>>;
  89040. /**
  89041. * Observable that will be called when effect is bound.
  89042. */
  89043. readonly onBindObservable: Observable<Effect>;
  89044. /** @hidden */
  89045. _bonesComputationForcedToCPU: boolean;
  89046. private static _uniqueIdSeed;
  89047. private _engine;
  89048. private _uniformBuffersNames;
  89049. private _uniformsNames;
  89050. private _samplerList;
  89051. private _samplers;
  89052. private _isReady;
  89053. private _compilationError;
  89054. private _attributesNames;
  89055. private _attributes;
  89056. private _uniforms;
  89057. /**
  89058. * Key for the effect.
  89059. * @hidden
  89060. */
  89061. _key: string;
  89062. private _indexParameters;
  89063. private _fallbacks;
  89064. private _vertexSourceCode;
  89065. private _fragmentSourceCode;
  89066. private _vertexSourceCodeOverride;
  89067. private _fragmentSourceCodeOverride;
  89068. private _transformFeedbackVaryings;
  89069. /**
  89070. * Compiled shader to webGL program.
  89071. * @hidden
  89072. */
  89073. _pipelineContext: IPipelineContext;
  89074. private _valueCache;
  89075. private static _baseCache;
  89076. /**
  89077. * Instantiates an effect.
  89078. * An effect can be used to create/manage/execute vertex and fragment shaders.
  89079. * @param baseName Name of the effect.
  89080. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  89081. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  89082. * @param samplers List of sampler variables that will be passed to the shader.
  89083. * @param engine Engine to be used to render the effect
  89084. * @param defines Define statements to be added to the shader.
  89085. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  89086. * @param onCompiled Callback that will be called when the shader is compiled.
  89087. * @param onError Callback that will be called if an error occurs during shader compilation.
  89088. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  89089. */
  89090. 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);
  89091. /**
  89092. * Unique key for this effect
  89093. */
  89094. readonly key: string;
  89095. /**
  89096. * If the effect has been compiled and prepared.
  89097. * @returns if the effect is compiled and prepared.
  89098. */
  89099. isReady(): boolean;
  89100. /**
  89101. * The engine the effect was initialized with.
  89102. * @returns the engine.
  89103. */
  89104. getEngine(): Engine;
  89105. /**
  89106. * The pipeline context for this effect
  89107. * @returns the associated pipeline context
  89108. */
  89109. getPipelineContext(): IPipelineContext;
  89110. /**
  89111. * The set of names of attribute variables for the shader.
  89112. * @returns An array of attribute names.
  89113. */
  89114. getAttributesNames(): string[];
  89115. /**
  89116. * Returns the attribute at the given index.
  89117. * @param index The index of the attribute.
  89118. * @returns The location of the attribute.
  89119. */
  89120. getAttributeLocation(index: number): number;
  89121. /**
  89122. * Returns the attribute based on the name of the variable.
  89123. * @param name of the attribute to look up.
  89124. * @returns the attribute location.
  89125. */
  89126. getAttributeLocationByName(name: string): number;
  89127. /**
  89128. * The number of attributes.
  89129. * @returns the numnber of attributes.
  89130. */
  89131. getAttributesCount(): number;
  89132. /**
  89133. * Gets the index of a uniform variable.
  89134. * @param uniformName of the uniform to look up.
  89135. * @returns the index.
  89136. */
  89137. getUniformIndex(uniformName: string): number;
  89138. /**
  89139. * Returns the attribute based on the name of the variable.
  89140. * @param uniformName of the uniform to look up.
  89141. * @returns the location of the uniform.
  89142. */
  89143. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  89144. /**
  89145. * Returns an array of sampler variable names
  89146. * @returns The array of sampler variable neames.
  89147. */
  89148. getSamplers(): string[];
  89149. /**
  89150. * The error from the last compilation.
  89151. * @returns the error string.
  89152. */
  89153. getCompilationError(): string;
  89154. /**
  89155. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  89156. * @param func The callback to be used.
  89157. */
  89158. executeWhenCompiled(func: (effect: Effect) => void): void;
  89159. private _checkIsReady;
  89160. /** @hidden */
  89161. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  89162. /** @hidden */
  89163. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  89164. /** @hidden */
  89165. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  89166. private _processShaderConversion;
  89167. private _processIncludes;
  89168. private _processPrecision;
  89169. /**
  89170. * Recompiles the webGL program
  89171. * @param vertexSourceCode The source code for the vertex shader.
  89172. * @param fragmentSourceCode The source code for the fragment shader.
  89173. * @param onCompiled Callback called when completed.
  89174. * @param onError Callback called on error.
  89175. * @hidden
  89176. */
  89177. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  89178. /**
  89179. * Prepares the effect
  89180. * @hidden
  89181. */
  89182. _prepareEffect(): void;
  89183. /**
  89184. * Checks if the effect is supported. (Must be called after compilation)
  89185. */
  89186. readonly isSupported: boolean;
  89187. /**
  89188. * Binds a texture to the engine to be used as output of the shader.
  89189. * @param channel Name of the output variable.
  89190. * @param texture Texture to bind.
  89191. * @hidden
  89192. */
  89193. _bindTexture(channel: string, texture: InternalTexture): void;
  89194. /**
  89195. * Sets a texture on the engine to be used in the shader.
  89196. * @param channel Name of the sampler variable.
  89197. * @param texture Texture to set.
  89198. */
  89199. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  89200. /**
  89201. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  89202. * @param channel Name of the sampler variable.
  89203. * @param texture Texture to set.
  89204. */
  89205. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  89206. /**
  89207. * Sets an array of textures on the engine to be used in the shader.
  89208. * @param channel Name of the variable.
  89209. * @param textures Textures to set.
  89210. */
  89211. setTextureArray(channel: string, textures: BaseTexture[]): void;
  89212. /**
  89213. * 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)
  89214. * @param channel Name of the sampler variable.
  89215. * @param postProcess Post process to get the input texture from.
  89216. */
  89217. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  89218. /**
  89219. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  89220. * 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)
  89221. * @param channel Name of the sampler variable.
  89222. * @param postProcess Post process to get the output texture from.
  89223. */
  89224. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  89225. /** @hidden */
  89226. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  89227. /** @hidden */
  89228. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  89229. /** @hidden */
  89230. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  89231. /** @hidden */
  89232. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  89233. /**
  89234. * Binds a buffer to a uniform.
  89235. * @param buffer Buffer to bind.
  89236. * @param name Name of the uniform variable to bind to.
  89237. */
  89238. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  89239. /**
  89240. * Binds block to a uniform.
  89241. * @param blockName Name of the block to bind.
  89242. * @param index Index to bind.
  89243. */
  89244. bindUniformBlock(blockName: string, index: number): void;
  89245. /**
  89246. * Sets an interger value on a uniform variable.
  89247. * @param uniformName Name of the variable.
  89248. * @param value Value to be set.
  89249. * @returns this effect.
  89250. */
  89251. setInt(uniformName: string, value: number): Effect;
  89252. /**
  89253. * Sets an int array on a uniform variable.
  89254. * @param uniformName Name of the variable.
  89255. * @param array array to be set.
  89256. * @returns this effect.
  89257. */
  89258. setIntArray(uniformName: string, array: Int32Array): Effect;
  89259. /**
  89260. * 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)
  89261. * @param uniformName Name of the variable.
  89262. * @param array array to be set.
  89263. * @returns this effect.
  89264. */
  89265. setIntArray2(uniformName: string, array: Int32Array): Effect;
  89266. /**
  89267. * 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)
  89268. * @param uniformName Name of the variable.
  89269. * @param array array to be set.
  89270. * @returns this effect.
  89271. */
  89272. setIntArray3(uniformName: string, array: Int32Array): Effect;
  89273. /**
  89274. * 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)
  89275. * @param uniformName Name of the variable.
  89276. * @param array array to be set.
  89277. * @returns this effect.
  89278. */
  89279. setIntArray4(uniformName: string, array: Int32Array): Effect;
  89280. /**
  89281. * Sets an float array on a uniform variable.
  89282. * @param uniformName Name of the variable.
  89283. * @param array array to be set.
  89284. * @returns this effect.
  89285. */
  89286. setFloatArray(uniformName: string, array: Float32Array): Effect;
  89287. /**
  89288. * 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)
  89289. * @param uniformName Name of the variable.
  89290. * @param array array to be set.
  89291. * @returns this effect.
  89292. */
  89293. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  89294. /**
  89295. * 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)
  89296. * @param uniformName Name of the variable.
  89297. * @param array array to be set.
  89298. * @returns this effect.
  89299. */
  89300. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  89301. /**
  89302. * 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)
  89303. * @param uniformName Name of the variable.
  89304. * @param array array to be set.
  89305. * @returns this effect.
  89306. */
  89307. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  89308. /**
  89309. * Sets an array on a uniform variable.
  89310. * @param uniformName Name of the variable.
  89311. * @param array array to be set.
  89312. * @returns this effect.
  89313. */
  89314. setArray(uniformName: string, array: number[]): Effect;
  89315. /**
  89316. * 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)
  89317. * @param uniformName Name of the variable.
  89318. * @param array array to be set.
  89319. * @returns this effect.
  89320. */
  89321. setArray2(uniformName: string, array: number[]): Effect;
  89322. /**
  89323. * 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)
  89324. * @param uniformName Name of the variable.
  89325. * @param array array to be set.
  89326. * @returns this effect.
  89327. */
  89328. setArray3(uniformName: string, array: number[]): Effect;
  89329. /**
  89330. * 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)
  89331. * @param uniformName Name of the variable.
  89332. * @param array array to be set.
  89333. * @returns this effect.
  89334. */
  89335. setArray4(uniformName: string, array: number[]): Effect;
  89336. /**
  89337. * Sets matrices on a uniform variable.
  89338. * @param uniformName Name of the variable.
  89339. * @param matrices matrices to be set.
  89340. * @returns this effect.
  89341. */
  89342. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  89343. /**
  89344. * Sets matrix on a uniform variable.
  89345. * @param uniformName Name of the variable.
  89346. * @param matrix matrix to be set.
  89347. * @returns this effect.
  89348. */
  89349. setMatrix(uniformName: string, matrix: Matrix): Effect;
  89350. /**
  89351. * 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)
  89352. * @param uniformName Name of the variable.
  89353. * @param matrix matrix to be set.
  89354. * @returns this effect.
  89355. */
  89356. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  89357. /**
  89358. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  89359. * @param uniformName Name of the variable.
  89360. * @param matrix matrix to be set.
  89361. * @returns this effect.
  89362. */
  89363. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  89364. /**
  89365. * Sets a float on a uniform variable.
  89366. * @param uniformName Name of the variable.
  89367. * @param value value to be set.
  89368. * @returns this effect.
  89369. */
  89370. setFloat(uniformName: string, value: number): Effect;
  89371. /**
  89372. * Sets a boolean on a uniform variable.
  89373. * @param uniformName Name of the variable.
  89374. * @param bool value to be set.
  89375. * @returns this effect.
  89376. */
  89377. setBool(uniformName: string, bool: boolean): Effect;
  89378. /**
  89379. * Sets a Vector2 on a uniform variable.
  89380. * @param uniformName Name of the variable.
  89381. * @param vector2 vector2 to be set.
  89382. * @returns this effect.
  89383. */
  89384. setVector2(uniformName: string, vector2: Vector2): Effect;
  89385. /**
  89386. * Sets a float2 on a uniform variable.
  89387. * @param uniformName Name of the variable.
  89388. * @param x First float in float2.
  89389. * @param y Second float in float2.
  89390. * @returns this effect.
  89391. */
  89392. setFloat2(uniformName: string, x: number, y: number): Effect;
  89393. /**
  89394. * Sets a Vector3 on a uniform variable.
  89395. * @param uniformName Name of the variable.
  89396. * @param vector3 Value to be set.
  89397. * @returns this effect.
  89398. */
  89399. setVector3(uniformName: string, vector3: Vector3): Effect;
  89400. /**
  89401. * Sets a float3 on a uniform variable.
  89402. * @param uniformName Name of the variable.
  89403. * @param x First float in float3.
  89404. * @param y Second float in float3.
  89405. * @param z Third float in float3.
  89406. * @returns this effect.
  89407. */
  89408. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  89409. /**
  89410. * Sets a Vector4 on a uniform variable.
  89411. * @param uniformName Name of the variable.
  89412. * @param vector4 Value to be set.
  89413. * @returns this effect.
  89414. */
  89415. setVector4(uniformName: string, vector4: Vector4): Effect;
  89416. /**
  89417. * Sets a float4 on a uniform variable.
  89418. * @param uniformName Name of the variable.
  89419. * @param x First float in float4.
  89420. * @param y Second float in float4.
  89421. * @param z Third float in float4.
  89422. * @param w Fourth float in float4.
  89423. * @returns this effect.
  89424. */
  89425. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  89426. /**
  89427. * Sets a Color3 on a uniform variable.
  89428. * @param uniformName Name of the variable.
  89429. * @param color3 Value to be set.
  89430. * @returns this effect.
  89431. */
  89432. setColor3(uniformName: string, color3: Color3): Effect;
  89433. /**
  89434. * Sets a Color4 on a uniform variable.
  89435. * @param uniformName Name of the variable.
  89436. * @param color3 Value to be set.
  89437. * @param alpha Alpha value to be set.
  89438. * @returns this effect.
  89439. */
  89440. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  89441. /**
  89442. * Sets a Color4 on a uniform variable
  89443. * @param uniformName defines the name of the variable
  89444. * @param color4 defines the value to be set
  89445. * @returns this effect.
  89446. */
  89447. setDirectColor4(uniformName: string, color4: Color4): Effect;
  89448. /** Release all associated resources */
  89449. dispose(): void;
  89450. /**
  89451. * This function will add a new shader to the shader store
  89452. * @param name the name of the shader
  89453. * @param pixelShader optional pixel shader content
  89454. * @param vertexShader optional vertex shader content
  89455. */
  89456. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  89457. /**
  89458. * Store of each shader (The can be looked up using effect.key)
  89459. */
  89460. static ShadersStore: {
  89461. [key: string]: string;
  89462. };
  89463. /**
  89464. * Store of each included file for a shader (The can be looked up using effect.key)
  89465. */
  89466. static IncludesShadersStore: {
  89467. [key: string]: string;
  89468. };
  89469. /**
  89470. * Resets the cache of effects.
  89471. */
  89472. static ResetCache(): void;
  89473. }
  89474. }
  89475. declare module BABYLON {
  89476. /**
  89477. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89478. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89479. * 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;
  89480. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89481. */
  89482. export class ColorCurves {
  89483. private _dirty;
  89484. private _tempColor;
  89485. private _globalCurve;
  89486. private _highlightsCurve;
  89487. private _midtonesCurve;
  89488. private _shadowsCurve;
  89489. private _positiveCurve;
  89490. private _negativeCurve;
  89491. private _globalHue;
  89492. private _globalDensity;
  89493. private _globalSaturation;
  89494. private _globalExposure;
  89495. /**
  89496. * Gets the global Hue value.
  89497. * 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).
  89498. */
  89499. /**
  89500. * Sets the global Hue value.
  89501. * 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).
  89502. */
  89503. globalHue: number;
  89504. /**
  89505. * Gets the global Density value.
  89506. * 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.
  89507. * Values less than zero provide a filter of opposite hue.
  89508. */
  89509. /**
  89510. * Sets the global Density value.
  89511. * 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.
  89512. * Values less than zero provide a filter of opposite hue.
  89513. */
  89514. globalDensity: number;
  89515. /**
  89516. * Gets the global Saturation value.
  89517. * 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.
  89518. */
  89519. /**
  89520. * Sets the global Saturation value.
  89521. * 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.
  89522. */
  89523. globalSaturation: number;
  89524. /**
  89525. * Gets the global Exposure value.
  89526. * 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.
  89527. */
  89528. /**
  89529. * Sets the global Exposure value.
  89530. * 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.
  89531. */
  89532. globalExposure: number;
  89533. private _highlightsHue;
  89534. private _highlightsDensity;
  89535. private _highlightsSaturation;
  89536. private _highlightsExposure;
  89537. /**
  89538. * Gets the highlights Hue value.
  89539. * 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).
  89540. */
  89541. /**
  89542. * Sets the highlights Hue value.
  89543. * 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).
  89544. */
  89545. highlightsHue: number;
  89546. /**
  89547. * Gets the highlights Density value.
  89548. * 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.
  89549. * Values less than zero provide a filter of opposite hue.
  89550. */
  89551. /**
  89552. * Sets the highlights Density value.
  89553. * 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.
  89554. * Values less than zero provide a filter of opposite hue.
  89555. */
  89556. highlightsDensity: number;
  89557. /**
  89558. * Gets the highlights Saturation value.
  89559. * 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.
  89560. */
  89561. /**
  89562. * Sets the highlights Saturation value.
  89563. * 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.
  89564. */
  89565. highlightsSaturation: number;
  89566. /**
  89567. * Gets the highlights Exposure value.
  89568. * 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.
  89569. */
  89570. /**
  89571. * Sets the highlights Exposure value.
  89572. * 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.
  89573. */
  89574. highlightsExposure: number;
  89575. private _midtonesHue;
  89576. private _midtonesDensity;
  89577. private _midtonesSaturation;
  89578. private _midtonesExposure;
  89579. /**
  89580. * Gets the midtones Hue value.
  89581. * 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).
  89582. */
  89583. /**
  89584. * Sets the midtones Hue value.
  89585. * 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).
  89586. */
  89587. midtonesHue: number;
  89588. /**
  89589. * Gets the midtones Density value.
  89590. * 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.
  89591. * Values less than zero provide a filter of opposite hue.
  89592. */
  89593. /**
  89594. * Sets the midtones Density value.
  89595. * 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.
  89596. * Values less than zero provide a filter of opposite hue.
  89597. */
  89598. midtonesDensity: number;
  89599. /**
  89600. * Gets the midtones Saturation value.
  89601. * 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.
  89602. */
  89603. /**
  89604. * Sets the midtones Saturation value.
  89605. * 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.
  89606. */
  89607. midtonesSaturation: number;
  89608. /**
  89609. * Gets the midtones Exposure value.
  89610. * 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.
  89611. */
  89612. /**
  89613. * Sets the midtones Exposure value.
  89614. * 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.
  89615. */
  89616. midtonesExposure: number;
  89617. private _shadowsHue;
  89618. private _shadowsDensity;
  89619. private _shadowsSaturation;
  89620. private _shadowsExposure;
  89621. /**
  89622. * Gets the shadows Hue value.
  89623. * 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).
  89624. */
  89625. /**
  89626. * Sets the shadows Hue value.
  89627. * 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).
  89628. */
  89629. shadowsHue: number;
  89630. /**
  89631. * Gets the shadows Density value.
  89632. * 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.
  89633. * Values less than zero provide a filter of opposite hue.
  89634. */
  89635. /**
  89636. * Sets the shadows Density value.
  89637. * 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.
  89638. * Values less than zero provide a filter of opposite hue.
  89639. */
  89640. shadowsDensity: number;
  89641. /**
  89642. * Gets the shadows Saturation value.
  89643. * 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.
  89644. */
  89645. /**
  89646. * Sets the shadows Saturation value.
  89647. * 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.
  89648. */
  89649. shadowsSaturation: number;
  89650. /**
  89651. * Gets the shadows Exposure value.
  89652. * 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.
  89653. */
  89654. /**
  89655. * Sets the shadows Exposure value.
  89656. * 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.
  89657. */
  89658. shadowsExposure: number;
  89659. /**
  89660. * Returns the class name
  89661. * @returns The class name
  89662. */
  89663. getClassName(): string;
  89664. /**
  89665. * Binds the color curves to the shader.
  89666. * @param colorCurves The color curve to bind
  89667. * @param effect The effect to bind to
  89668. * @param positiveUniform The positive uniform shader parameter
  89669. * @param neutralUniform The neutral uniform shader parameter
  89670. * @param negativeUniform The negative uniform shader parameter
  89671. */
  89672. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89673. /**
  89674. * Prepare the list of uniforms associated with the ColorCurves effects.
  89675. * @param uniformsList The list of uniforms used in the effect
  89676. */
  89677. static PrepareUniforms(uniformsList: string[]): void;
  89678. /**
  89679. * Returns color grading data based on a hue, density, saturation and exposure value.
  89680. * @param filterHue The hue of the color filter.
  89681. * @param filterDensity The density of the color filter.
  89682. * @param saturation The saturation.
  89683. * @param exposure The exposure.
  89684. * @param result The result data container.
  89685. */
  89686. private getColorGradingDataToRef;
  89687. /**
  89688. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89689. * @param value The input slider value in range [-100,100].
  89690. * @returns Adjusted value.
  89691. */
  89692. private static applyColorGradingSliderNonlinear;
  89693. /**
  89694. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89695. * @param hue The hue (H) input.
  89696. * @param saturation The saturation (S) input.
  89697. * @param brightness The brightness (B) input.
  89698. * @result An RGBA color represented as Vector4.
  89699. */
  89700. private static fromHSBToRef;
  89701. /**
  89702. * Returns a value clamped between min and max
  89703. * @param value The value to clamp
  89704. * @param min The minimum of value
  89705. * @param max The maximum of value
  89706. * @returns The clamped value.
  89707. */
  89708. private static clamp;
  89709. /**
  89710. * Clones the current color curve instance.
  89711. * @return The cloned curves
  89712. */
  89713. clone(): ColorCurves;
  89714. /**
  89715. * Serializes the current color curve instance to a json representation.
  89716. * @return a JSON representation
  89717. */
  89718. serialize(): any;
  89719. /**
  89720. * Parses the color curve from a json representation.
  89721. * @param source the JSON source to parse
  89722. * @return The parsed curves
  89723. */
  89724. static Parse(source: any): ColorCurves;
  89725. }
  89726. }
  89727. declare module BABYLON {
  89728. /**
  89729. * Interface to follow in your material defines to integrate easily the
  89730. * Image proccessing functions.
  89731. * @hidden
  89732. */
  89733. export interface IImageProcessingConfigurationDefines {
  89734. IMAGEPROCESSING: boolean;
  89735. VIGNETTE: boolean;
  89736. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89737. VIGNETTEBLENDMODEOPAQUE: boolean;
  89738. TONEMAPPING: boolean;
  89739. TONEMAPPING_ACES: boolean;
  89740. CONTRAST: boolean;
  89741. EXPOSURE: boolean;
  89742. COLORCURVES: boolean;
  89743. COLORGRADING: boolean;
  89744. COLORGRADING3D: boolean;
  89745. SAMPLER3DGREENDEPTH: boolean;
  89746. SAMPLER3DBGRMAP: boolean;
  89747. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89748. }
  89749. /**
  89750. * @hidden
  89751. */
  89752. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89753. IMAGEPROCESSING: boolean;
  89754. VIGNETTE: boolean;
  89755. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89756. VIGNETTEBLENDMODEOPAQUE: boolean;
  89757. TONEMAPPING: boolean;
  89758. TONEMAPPING_ACES: boolean;
  89759. CONTRAST: boolean;
  89760. COLORCURVES: boolean;
  89761. COLORGRADING: boolean;
  89762. COLORGRADING3D: boolean;
  89763. SAMPLER3DGREENDEPTH: boolean;
  89764. SAMPLER3DBGRMAP: boolean;
  89765. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89766. EXPOSURE: boolean;
  89767. constructor();
  89768. }
  89769. /**
  89770. * This groups together the common properties used for image processing either in direct forward pass
  89771. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89772. * or not.
  89773. */
  89774. export class ImageProcessingConfiguration {
  89775. /**
  89776. * Default tone mapping applied in BabylonJS.
  89777. */
  89778. static readonly TONEMAPPING_STANDARD: number;
  89779. /**
  89780. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89781. * to other engines rendering to increase portability.
  89782. */
  89783. static readonly TONEMAPPING_ACES: number;
  89784. /**
  89785. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89786. */
  89787. colorCurves: Nullable<ColorCurves>;
  89788. private _colorCurvesEnabled;
  89789. /**
  89790. * Gets wether the color curves effect is enabled.
  89791. */
  89792. /**
  89793. * Sets wether the color curves effect is enabled.
  89794. */
  89795. colorCurvesEnabled: boolean;
  89796. private _colorGradingTexture;
  89797. /**
  89798. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89799. */
  89800. /**
  89801. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89802. */
  89803. colorGradingTexture: Nullable<BaseTexture>;
  89804. private _colorGradingEnabled;
  89805. /**
  89806. * Gets wether the color grading effect is enabled.
  89807. */
  89808. /**
  89809. * Sets wether the color grading effect is enabled.
  89810. */
  89811. colorGradingEnabled: boolean;
  89812. private _colorGradingWithGreenDepth;
  89813. /**
  89814. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89815. */
  89816. /**
  89817. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89818. */
  89819. colorGradingWithGreenDepth: boolean;
  89820. private _colorGradingBGR;
  89821. /**
  89822. * Gets wether the color grading texture contains BGR values.
  89823. */
  89824. /**
  89825. * Sets wether the color grading texture contains BGR values.
  89826. */
  89827. colorGradingBGR: boolean;
  89828. /** @hidden */
  89829. _exposure: number;
  89830. /**
  89831. * Gets the Exposure used in the effect.
  89832. */
  89833. /**
  89834. * Sets the Exposure used in the effect.
  89835. */
  89836. exposure: number;
  89837. private _toneMappingEnabled;
  89838. /**
  89839. * Gets wether the tone mapping effect is enabled.
  89840. */
  89841. /**
  89842. * Sets wether the tone mapping effect is enabled.
  89843. */
  89844. toneMappingEnabled: boolean;
  89845. private _toneMappingType;
  89846. /**
  89847. * Gets the type of tone mapping effect.
  89848. */
  89849. /**
  89850. * Sets the type of tone mapping effect used in BabylonJS.
  89851. */
  89852. toneMappingType: number;
  89853. protected _contrast: number;
  89854. /**
  89855. * Gets the contrast used in the effect.
  89856. */
  89857. /**
  89858. * Sets the contrast used in the effect.
  89859. */
  89860. contrast: number;
  89861. /**
  89862. * Vignette stretch size.
  89863. */
  89864. vignetteStretch: number;
  89865. /**
  89866. * Vignette centre X Offset.
  89867. */
  89868. vignetteCentreX: number;
  89869. /**
  89870. * Vignette centre Y Offset.
  89871. */
  89872. vignetteCentreY: number;
  89873. /**
  89874. * Vignette weight or intensity of the vignette effect.
  89875. */
  89876. vignetteWeight: number;
  89877. /**
  89878. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89879. * if vignetteEnabled is set to true.
  89880. */
  89881. vignetteColor: Color4;
  89882. /**
  89883. * Camera field of view used by the Vignette effect.
  89884. */
  89885. vignetteCameraFov: number;
  89886. private _vignetteBlendMode;
  89887. /**
  89888. * Gets the vignette blend mode allowing different kind of effect.
  89889. */
  89890. /**
  89891. * Sets the vignette blend mode allowing different kind of effect.
  89892. */
  89893. vignetteBlendMode: number;
  89894. private _vignetteEnabled;
  89895. /**
  89896. * Gets wether the vignette effect is enabled.
  89897. */
  89898. /**
  89899. * Sets wether the vignette effect is enabled.
  89900. */
  89901. vignetteEnabled: boolean;
  89902. private _applyByPostProcess;
  89903. /**
  89904. * Gets wether the image processing is applied through a post process or not.
  89905. */
  89906. /**
  89907. * Sets wether the image processing is applied through a post process or not.
  89908. */
  89909. applyByPostProcess: boolean;
  89910. private _isEnabled;
  89911. /**
  89912. * Gets wether the image processing is enabled or not.
  89913. */
  89914. /**
  89915. * Sets wether the image processing is enabled or not.
  89916. */
  89917. isEnabled: boolean;
  89918. /**
  89919. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89920. */
  89921. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89922. /**
  89923. * Method called each time the image processing information changes requires to recompile the effect.
  89924. */
  89925. protected _updateParameters(): void;
  89926. /**
  89927. * Gets the current class name.
  89928. * @return "ImageProcessingConfiguration"
  89929. */
  89930. getClassName(): string;
  89931. /**
  89932. * Prepare the list of uniforms associated with the Image Processing effects.
  89933. * @param uniforms The list of uniforms used in the effect
  89934. * @param defines the list of defines currently in use
  89935. */
  89936. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89937. /**
  89938. * Prepare the list of samplers associated with the Image Processing effects.
  89939. * @param samplersList The list of uniforms used in the effect
  89940. * @param defines the list of defines currently in use
  89941. */
  89942. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89943. /**
  89944. * Prepare the list of defines associated to the shader.
  89945. * @param defines the list of defines to complete
  89946. * @param forPostProcess Define if we are currently in post process mode or not
  89947. */
  89948. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89949. /**
  89950. * Returns true if all the image processing information are ready.
  89951. * @returns True if ready, otherwise, false
  89952. */
  89953. isReady(): boolean;
  89954. /**
  89955. * Binds the image processing to the shader.
  89956. * @param effect The effect to bind to
  89957. * @param aspectRatio Define the current aspect ratio of the effect
  89958. */
  89959. bind(effect: Effect, aspectRatio?: number): void;
  89960. /**
  89961. * Clones the current image processing instance.
  89962. * @return The cloned image processing
  89963. */
  89964. clone(): ImageProcessingConfiguration;
  89965. /**
  89966. * Serializes the current image processing instance to a json representation.
  89967. * @return a JSON representation
  89968. */
  89969. serialize(): any;
  89970. /**
  89971. * Parses the image processing from a json representation.
  89972. * @param source the JSON source to parse
  89973. * @return The parsed image processing
  89974. */
  89975. static Parse(source: any): ImageProcessingConfiguration;
  89976. private static _VIGNETTEMODE_MULTIPLY;
  89977. private static _VIGNETTEMODE_OPAQUE;
  89978. /**
  89979. * Used to apply the vignette as a mix with the pixel color.
  89980. */
  89981. static readonly VIGNETTEMODE_MULTIPLY: number;
  89982. /**
  89983. * Used to apply the vignette as a replacement of the pixel color.
  89984. */
  89985. static readonly VIGNETTEMODE_OPAQUE: number;
  89986. }
  89987. }
  89988. declare module BABYLON {
  89989. /**
  89990. * This represents all the required information to add a fresnel effect on a material:
  89991. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89992. */
  89993. export class FresnelParameters {
  89994. private _isEnabled;
  89995. /**
  89996. * Define if the fresnel effect is enable or not.
  89997. */
  89998. isEnabled: boolean;
  89999. /**
  90000. * Define the color used on edges (grazing angle)
  90001. */
  90002. leftColor: Color3;
  90003. /**
  90004. * Define the color used on center
  90005. */
  90006. rightColor: Color3;
  90007. /**
  90008. * Define bias applied to computed fresnel term
  90009. */
  90010. bias: number;
  90011. /**
  90012. * Defined the power exponent applied to fresnel term
  90013. */
  90014. power: number;
  90015. /**
  90016. * Clones the current fresnel and its valuues
  90017. * @returns a clone fresnel configuration
  90018. */
  90019. clone(): FresnelParameters;
  90020. /**
  90021. * Serializes the current fresnel parameters to a JSON representation.
  90022. * @return the JSON serialization
  90023. */
  90024. serialize(): any;
  90025. /**
  90026. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  90027. * @param parsedFresnelParameters Define the JSON representation
  90028. * @returns the parsed parameters
  90029. */
  90030. static Parse(parsedFresnelParameters: any): FresnelParameters;
  90031. }
  90032. }
  90033. declare module BABYLON {
  90034. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  90035. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90036. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90037. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90038. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90039. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90040. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90041. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90042. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90043. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90044. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90045. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90046. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90047. /**
  90048. * Decorator used to define property that can be serialized as reference to a camera
  90049. * @param sourceName defines the name of the property to decorate
  90050. */
  90051. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90052. /**
  90053. * Class used to help serialization objects
  90054. */
  90055. export class SerializationHelper {
  90056. /** hidden */
  90057. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  90058. /** hidden */
  90059. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  90060. /** hidden */
  90061. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  90062. /** hidden */
  90063. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  90064. /**
  90065. * Appends the serialized animations from the source animations
  90066. * @param source Source containing the animations
  90067. * @param destination Target to store the animations
  90068. */
  90069. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  90070. /**
  90071. * Static function used to serialized a specific entity
  90072. * @param entity defines the entity to serialize
  90073. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  90074. * @returns a JSON compatible object representing the serialization of the entity
  90075. */
  90076. static Serialize<T>(entity: T, serializationObject?: any): any;
  90077. /**
  90078. * Creates a new entity from a serialization data object
  90079. * @param creationFunction defines a function used to instanciated the new entity
  90080. * @param source defines the source serialization data
  90081. * @param scene defines the hosting scene
  90082. * @param rootUrl defines the root url for resources
  90083. * @returns a new entity
  90084. */
  90085. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  90086. /**
  90087. * Clones an object
  90088. * @param creationFunction defines the function used to instanciate the new object
  90089. * @param source defines the source object
  90090. * @returns the cloned object
  90091. */
  90092. static Clone<T>(creationFunction: () => T, source: T): T;
  90093. /**
  90094. * Instanciates a new object based on a source one (some data will be shared between both object)
  90095. * @param creationFunction defines the function used to instanciate the new object
  90096. * @param source defines the source object
  90097. * @returns the new object
  90098. */
  90099. static Instanciate<T>(creationFunction: () => T, source: T): T;
  90100. }
  90101. }
  90102. declare module BABYLON {
  90103. /**
  90104. * This is the base class of all the camera used in the application.
  90105. * @see http://doc.babylonjs.com/features/cameras
  90106. */
  90107. export class Camera extends Node {
  90108. /** @hidden */
  90109. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90110. /**
  90111. * This is the default projection mode used by the cameras.
  90112. * It helps recreating a feeling of perspective and better appreciate depth.
  90113. * This is the best way to simulate real life cameras.
  90114. */
  90115. static readonly PERSPECTIVE_CAMERA: number;
  90116. /**
  90117. * This helps creating camera with an orthographic mode.
  90118. * 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.
  90119. */
  90120. static readonly ORTHOGRAPHIC_CAMERA: number;
  90121. /**
  90122. * This is the default FOV mode for perspective cameras.
  90123. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90124. */
  90125. static readonly FOVMODE_VERTICAL_FIXED: number;
  90126. /**
  90127. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90128. */
  90129. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90130. /**
  90131. * This specifies ther is no need for a camera rig.
  90132. * Basically only one eye is rendered corresponding to the camera.
  90133. */
  90134. static readonly RIG_MODE_NONE: number;
  90135. /**
  90136. * Simulates a camera Rig with one blue eye and one red eye.
  90137. * This can be use with 3d blue and red glasses.
  90138. */
  90139. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90140. /**
  90141. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90142. */
  90143. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90144. /**
  90145. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90146. */
  90147. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90148. /**
  90149. * Defines that both eyes of the camera will be rendered over under each other.
  90150. */
  90151. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90152. /**
  90153. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90154. */
  90155. static readonly RIG_MODE_VR: number;
  90156. /**
  90157. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90158. */
  90159. static readonly RIG_MODE_WEBVR: number;
  90160. /**
  90161. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90162. */
  90163. static readonly RIG_MODE_CUSTOM: number;
  90164. /**
  90165. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90166. */
  90167. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90168. /**
  90169. * Define the input manager associated with the camera.
  90170. */
  90171. inputs: CameraInputsManager<Camera>;
  90172. /** @hidden */
  90173. _position: Vector3;
  90174. /**
  90175. * Define the current local position of the camera in the scene
  90176. */
  90177. position: Vector3;
  90178. /**
  90179. * The vector the camera should consider as up.
  90180. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90181. */
  90182. upVector: Vector3;
  90183. /**
  90184. * Define the current limit on the left side for an orthographic camera
  90185. * In scene unit
  90186. */
  90187. orthoLeft: Nullable<number>;
  90188. /**
  90189. * Define the current limit on the right side for an orthographic camera
  90190. * In scene unit
  90191. */
  90192. orthoRight: Nullable<number>;
  90193. /**
  90194. * Define the current limit on the bottom side for an orthographic camera
  90195. * In scene unit
  90196. */
  90197. orthoBottom: Nullable<number>;
  90198. /**
  90199. * Define the current limit on the top side for an orthographic camera
  90200. * In scene unit
  90201. */
  90202. orthoTop: Nullable<number>;
  90203. /**
  90204. * Field Of View is set in Radians. (default is 0.8)
  90205. */
  90206. fov: number;
  90207. /**
  90208. * Define the minimum distance the camera can see from.
  90209. * This is important to note that the depth buffer are not infinite and the closer it starts
  90210. * the more your scene might encounter depth fighting issue.
  90211. */
  90212. minZ: number;
  90213. /**
  90214. * Define the maximum distance the camera can see to.
  90215. * This is important to note that the depth buffer are not infinite and the further it end
  90216. * the more your scene might encounter depth fighting issue.
  90217. */
  90218. maxZ: number;
  90219. /**
  90220. * Define the default inertia of the camera.
  90221. * This helps giving a smooth feeling to the camera movement.
  90222. */
  90223. inertia: number;
  90224. /**
  90225. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  90226. */
  90227. mode: number;
  90228. /**
  90229. * Define wether the camera is intermediate.
  90230. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90231. */
  90232. isIntermediate: boolean;
  90233. /**
  90234. * Define the viewport of the camera.
  90235. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90236. */
  90237. viewport: Viewport;
  90238. /**
  90239. * Restricts the camera to viewing objects with the same layerMask.
  90240. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90241. */
  90242. layerMask: number;
  90243. /**
  90244. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90245. */
  90246. fovMode: number;
  90247. /**
  90248. * Rig mode of the camera.
  90249. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90250. * This is normally controlled byt the camera themselves as internal use.
  90251. */
  90252. cameraRigMode: number;
  90253. /**
  90254. * Defines the distance between both "eyes" in case of a RIG
  90255. */
  90256. interaxialDistance: number;
  90257. /**
  90258. * Defines if stereoscopic rendering is done side by side or over under.
  90259. */
  90260. isStereoscopicSideBySide: boolean;
  90261. /**
  90262. * 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
  90263. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90264. * else in the scene.
  90265. */
  90266. customRenderTargets: RenderTargetTexture[];
  90267. /**
  90268. * When set, the camera will render to this render target instead of the default canvas
  90269. */
  90270. outputRenderTarget: Nullable<RenderTargetTexture>;
  90271. /**
  90272. * Observable triggered when the camera view matrix has changed.
  90273. */
  90274. onViewMatrixChangedObservable: Observable<Camera>;
  90275. /**
  90276. * Observable triggered when the camera Projection matrix has changed.
  90277. */
  90278. onProjectionMatrixChangedObservable: Observable<Camera>;
  90279. /**
  90280. * Observable triggered when the inputs have been processed.
  90281. */
  90282. onAfterCheckInputsObservable: Observable<Camera>;
  90283. /**
  90284. * Observable triggered when reset has been called and applied to the camera.
  90285. */
  90286. onRestoreStateObservable: Observable<Camera>;
  90287. /** @hidden */
  90288. _cameraRigParams: any;
  90289. /** @hidden */
  90290. _rigCameras: Camera[];
  90291. /** @hidden */
  90292. _rigPostProcess: Nullable<PostProcess>;
  90293. protected _webvrViewMatrix: Matrix;
  90294. /** @hidden */
  90295. _skipRendering: boolean;
  90296. /** @hidden */
  90297. _projectionMatrix: Matrix;
  90298. /** @hidden */
  90299. _postProcesses: Nullable<PostProcess>[];
  90300. /** @hidden */
  90301. _activeMeshes: SmartArray<AbstractMesh>;
  90302. protected _globalPosition: Vector3;
  90303. /** hidden */
  90304. _computedViewMatrix: Matrix;
  90305. private _doNotComputeProjectionMatrix;
  90306. private _transformMatrix;
  90307. private _frustumPlanes;
  90308. private _refreshFrustumPlanes;
  90309. private _storedFov;
  90310. private _stateStored;
  90311. /**
  90312. * Instantiates a new camera object.
  90313. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90314. * @see http://doc.babylonjs.com/features/cameras
  90315. * @param name Defines the name of the camera in the scene
  90316. * @param position Defines the position of the camera
  90317. * @param scene Defines the scene the camera belongs too
  90318. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90319. */
  90320. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90321. /**
  90322. * Store current camera state (fov, position, etc..)
  90323. * @returns the camera
  90324. */
  90325. storeState(): Camera;
  90326. /**
  90327. * Restores the camera state values if it has been stored. You must call storeState() first
  90328. */
  90329. protected _restoreStateValues(): boolean;
  90330. /**
  90331. * Restored camera state. You must call storeState() first.
  90332. * @returns true if restored and false otherwise
  90333. */
  90334. restoreState(): boolean;
  90335. /**
  90336. * Gets the class name of the camera.
  90337. * @returns the class name
  90338. */
  90339. getClassName(): string;
  90340. /** @hidden */
  90341. readonly _isCamera: boolean;
  90342. /**
  90343. * Gets a string representation of the camera useful for debug purpose.
  90344. * @param fullDetails Defines that a more verboe level of logging is required
  90345. * @returns the string representation
  90346. */
  90347. toString(fullDetails?: boolean): string;
  90348. /**
  90349. * Gets the current world space position of the camera.
  90350. */
  90351. readonly globalPosition: Vector3;
  90352. /**
  90353. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90354. * @returns the active meshe list
  90355. */
  90356. getActiveMeshes(): SmartArray<AbstractMesh>;
  90357. /**
  90358. * Check wether a mesh is part of the current active mesh list of the camera
  90359. * @param mesh Defines the mesh to check
  90360. * @returns true if active, false otherwise
  90361. */
  90362. isActiveMesh(mesh: Mesh): boolean;
  90363. /**
  90364. * Is this camera ready to be used/rendered
  90365. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90366. * @return true if the camera is ready
  90367. */
  90368. isReady(completeCheck?: boolean): boolean;
  90369. /** @hidden */
  90370. _initCache(): void;
  90371. /** @hidden */
  90372. _updateCache(ignoreParentClass?: boolean): void;
  90373. /** @hidden */
  90374. _isSynchronized(): boolean;
  90375. /** @hidden */
  90376. _isSynchronizedViewMatrix(): boolean;
  90377. /** @hidden */
  90378. _isSynchronizedProjectionMatrix(): boolean;
  90379. /**
  90380. * Attach the input controls to a specific dom element to get the input from.
  90381. * @param element Defines the element the controls should be listened from
  90382. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90383. */
  90384. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90385. /**
  90386. * Detach the current controls from the specified dom element.
  90387. * @param element Defines the element to stop listening the inputs from
  90388. */
  90389. detachControl(element: HTMLElement): void;
  90390. /**
  90391. * Update the camera state according to the different inputs gathered during the frame.
  90392. */
  90393. update(): void;
  90394. /** @hidden */
  90395. _checkInputs(): void;
  90396. /** @hidden */
  90397. readonly rigCameras: Camera[];
  90398. /**
  90399. * Gets the post process used by the rig cameras
  90400. */
  90401. readonly rigPostProcess: Nullable<PostProcess>;
  90402. /**
  90403. * Internal, gets the first post proces.
  90404. * @returns the first post process to be run on this camera.
  90405. */
  90406. _getFirstPostProcess(): Nullable<PostProcess>;
  90407. private _cascadePostProcessesToRigCams;
  90408. /**
  90409. * Attach a post process to the camera.
  90410. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90411. * @param postProcess The post process to attach to the camera
  90412. * @param insertAt The position of the post process in case several of them are in use in the scene
  90413. * @returns the position the post process has been inserted at
  90414. */
  90415. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90416. /**
  90417. * Detach a post process to the camera.
  90418. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90419. * @param postProcess The post process to detach from the camera
  90420. */
  90421. detachPostProcess(postProcess: PostProcess): void;
  90422. /**
  90423. * Gets the current world matrix of the camera
  90424. */
  90425. getWorldMatrix(): Matrix;
  90426. /** @hidden */
  90427. _getViewMatrix(): Matrix;
  90428. /**
  90429. * Gets the current view matrix of the camera.
  90430. * @param force forces the camera to recompute the matrix without looking at the cached state
  90431. * @returns the view matrix
  90432. */
  90433. getViewMatrix(force?: boolean): Matrix;
  90434. /**
  90435. * Freeze the projection matrix.
  90436. * It will prevent the cache check of the camera projection compute and can speed up perf
  90437. * if no parameter of the camera are meant to change
  90438. * @param projection Defines manually a projection if necessary
  90439. */
  90440. freezeProjectionMatrix(projection?: Matrix): void;
  90441. /**
  90442. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90443. */
  90444. unfreezeProjectionMatrix(): void;
  90445. /**
  90446. * Gets the current projection matrix of the camera.
  90447. * @param force forces the camera to recompute the matrix without looking at the cached state
  90448. * @returns the projection matrix
  90449. */
  90450. getProjectionMatrix(force?: boolean): Matrix;
  90451. /**
  90452. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90453. * @returns a Matrix
  90454. */
  90455. getTransformationMatrix(): Matrix;
  90456. private _updateFrustumPlanes;
  90457. /**
  90458. * Checks if a cullable object (mesh...) is in the camera frustum
  90459. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90460. * @param target The object to check
  90461. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90462. * @returns true if the object is in frustum otherwise false
  90463. */
  90464. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90465. /**
  90466. * Checks if a cullable object (mesh...) is in the camera frustum
  90467. * Unlike isInFrustum this cheks the full bounding box
  90468. * @param target The object to check
  90469. * @returns true if the object is in frustum otherwise false
  90470. */
  90471. isCompletelyInFrustum(target: ICullable): boolean;
  90472. /**
  90473. * Gets a ray in the forward direction from the camera.
  90474. * @param length Defines the length of the ray to create
  90475. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90476. * @param origin Defines the start point of the ray which defaults to the camera position
  90477. * @returns the forward ray
  90478. */
  90479. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90480. /**
  90481. * Releases resources associated with this node.
  90482. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90483. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90484. */
  90485. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90486. /** @hidden */
  90487. _isLeftCamera: boolean;
  90488. /**
  90489. * Gets the left camera of a rig setup in case of Rigged Camera
  90490. */
  90491. readonly isLeftCamera: boolean;
  90492. /** @hidden */
  90493. _isRightCamera: boolean;
  90494. /**
  90495. * Gets the right camera of a rig setup in case of Rigged Camera
  90496. */
  90497. readonly isRightCamera: boolean;
  90498. /**
  90499. * Gets the left camera of a rig setup in case of Rigged Camera
  90500. */
  90501. readonly leftCamera: Nullable<FreeCamera>;
  90502. /**
  90503. * Gets the right camera of a rig setup in case of Rigged Camera
  90504. */
  90505. readonly rightCamera: Nullable<FreeCamera>;
  90506. /**
  90507. * Gets the left camera target of a rig setup in case of Rigged Camera
  90508. * @returns the target position
  90509. */
  90510. getLeftTarget(): Nullable<Vector3>;
  90511. /**
  90512. * Gets the right camera target of a rig setup in case of Rigged Camera
  90513. * @returns the target position
  90514. */
  90515. getRightTarget(): Nullable<Vector3>;
  90516. /**
  90517. * @hidden
  90518. */
  90519. setCameraRigMode(mode: number, rigParams: any): void;
  90520. /** @hidden */
  90521. static _setStereoscopicRigMode(camera: Camera): void;
  90522. /** @hidden */
  90523. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90524. /** @hidden */
  90525. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90526. /** @hidden */
  90527. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90528. /** @hidden */
  90529. _getVRProjectionMatrix(): Matrix;
  90530. protected _updateCameraRotationMatrix(): void;
  90531. protected _updateWebVRCameraRotationMatrix(): void;
  90532. /**
  90533. * This function MUST be overwritten by the different WebVR cameras available.
  90534. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90535. * @hidden
  90536. */
  90537. _getWebVRProjectionMatrix(): Matrix;
  90538. /**
  90539. * This function MUST be overwritten by the different WebVR cameras available.
  90540. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90541. * @hidden
  90542. */
  90543. _getWebVRViewMatrix(): Matrix;
  90544. /** @hidden */
  90545. setCameraRigParameter(name: string, value: any): void;
  90546. /**
  90547. * needs to be overridden by children so sub has required properties to be copied
  90548. * @hidden
  90549. */
  90550. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90551. /**
  90552. * May need to be overridden by children
  90553. * @hidden
  90554. */
  90555. _updateRigCameras(): void;
  90556. /** @hidden */
  90557. _setupInputs(): void;
  90558. /**
  90559. * Serialiaze the camera setup to a json represention
  90560. * @returns the JSON representation
  90561. */
  90562. serialize(): any;
  90563. /**
  90564. * Clones the current camera.
  90565. * @param name The cloned camera name
  90566. * @returns the cloned camera
  90567. */
  90568. clone(name: string): Camera;
  90569. /**
  90570. * Gets the direction of the camera relative to a given local axis.
  90571. * @param localAxis Defines the reference axis to provide a relative direction.
  90572. * @return the direction
  90573. */
  90574. getDirection(localAxis: Vector3): Vector3;
  90575. /**
  90576. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90577. * @param localAxis Defines the reference axis to provide a relative direction.
  90578. * @param result Defines the vector to store the result in
  90579. */
  90580. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90581. /**
  90582. * Gets a camera constructor for a given camera type
  90583. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90584. * @param name The name of the camera the result will be able to instantiate
  90585. * @param scene The scene the result will construct the camera in
  90586. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90587. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90588. * @returns a factory method to construc the camera
  90589. */
  90590. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90591. /**
  90592. * Compute the world matrix of the camera.
  90593. * @returns the camera workd matrix
  90594. */
  90595. computeWorldMatrix(): Matrix;
  90596. /**
  90597. * Parse a JSON and creates the camera from the parsed information
  90598. * @param parsedCamera The JSON to parse
  90599. * @param scene The scene to instantiate the camera in
  90600. * @returns the newly constructed camera
  90601. */
  90602. static Parse(parsedCamera: any, scene: Scene): Camera;
  90603. }
  90604. }
  90605. declare module BABYLON {
  90606. /**
  90607. * Interface for any object that can request an animation frame
  90608. */
  90609. export interface ICustomAnimationFrameRequester {
  90610. /**
  90611. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  90612. */
  90613. renderFunction?: Function;
  90614. /**
  90615. * Called to request the next frame to render to
  90616. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  90617. */
  90618. requestAnimationFrame: Function;
  90619. /**
  90620. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  90621. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  90622. */
  90623. requestID?: number;
  90624. }
  90625. /**
  90626. * Interface containing an array of animations
  90627. */
  90628. export interface IAnimatable {
  90629. /**
  90630. * Array of animations
  90631. */
  90632. animations: Nullable<Array<Animation>>;
  90633. }
  90634. /** Interface used by value gradients (color, factor, ...) */
  90635. export interface IValueGradient {
  90636. /**
  90637. * Gets or sets the gradient value (between 0 and 1)
  90638. */
  90639. gradient: number;
  90640. }
  90641. /** Class used to store color4 gradient */
  90642. export class ColorGradient implements IValueGradient {
  90643. /**
  90644. * Gets or sets the gradient value (between 0 and 1)
  90645. */
  90646. gradient: number;
  90647. /**
  90648. * Gets or sets first associated color
  90649. */
  90650. color1: Color4;
  90651. /**
  90652. * Gets or sets second associated color
  90653. */
  90654. color2?: Color4;
  90655. /**
  90656. * Will get a color picked randomly between color1 and color2.
  90657. * If color2 is undefined then color1 will be used
  90658. * @param result defines the target Color4 to store the result in
  90659. */
  90660. getColorToRef(result: Color4): void;
  90661. }
  90662. /** Class used to store color 3 gradient */
  90663. export class Color3Gradient implements IValueGradient {
  90664. /**
  90665. * Gets or sets the gradient value (between 0 and 1)
  90666. */
  90667. gradient: number;
  90668. /**
  90669. * Gets or sets the associated color
  90670. */
  90671. color: Color3;
  90672. }
  90673. /** Class used to store factor gradient */
  90674. export class FactorGradient implements IValueGradient {
  90675. /**
  90676. * Gets or sets the gradient value (between 0 and 1)
  90677. */
  90678. gradient: number;
  90679. /**
  90680. * Gets or sets first associated factor
  90681. */
  90682. factor1: number;
  90683. /**
  90684. * Gets or sets second associated factor
  90685. */
  90686. factor2?: number;
  90687. /**
  90688. * Will get a number picked randomly between factor1 and factor2.
  90689. * If factor2 is undefined then factor1 will be used
  90690. * @returns the picked number
  90691. */
  90692. getFactor(): number;
  90693. }
  90694. /**
  90695. * @ignore
  90696. * Application error to support additional information when loading a file
  90697. */
  90698. export class LoadFileError extends Error {
  90699. /** defines the optional web request */
  90700. request?: WebRequest | undefined;
  90701. private static _setPrototypeOf;
  90702. /**
  90703. * Creates a new LoadFileError
  90704. * @param message defines the message of the error
  90705. * @param request defines the optional web request
  90706. */
  90707. constructor(message: string,
  90708. /** defines the optional web request */
  90709. request?: WebRequest | undefined);
  90710. }
  90711. /**
  90712. * Class used to define a retry strategy when error happens while loading assets
  90713. */
  90714. export class RetryStrategy {
  90715. /**
  90716. * Function used to defines an exponential back off strategy
  90717. * @param maxRetries defines the maximum number of retries (3 by default)
  90718. * @param baseInterval defines the interval between retries
  90719. * @returns the strategy function to use
  90720. */
  90721. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90722. }
  90723. /**
  90724. * File request interface
  90725. */
  90726. export interface IFileRequest {
  90727. /**
  90728. * Raised when the request is complete (success or error).
  90729. */
  90730. onCompleteObservable: Observable<IFileRequest>;
  90731. /**
  90732. * Aborts the request for a file.
  90733. */
  90734. abort: () => void;
  90735. }
  90736. /**
  90737. * Class containing a set of static utilities functions
  90738. */
  90739. export class Tools {
  90740. /**
  90741. * Gets or sets the base URL to use to load assets
  90742. */
  90743. static BaseUrl: string;
  90744. /**
  90745. * Enable/Disable Custom HTTP Request Headers globally.
  90746. * default = false
  90747. * @see CustomRequestHeaders
  90748. */
  90749. static UseCustomRequestHeaders: boolean;
  90750. /**
  90751. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90752. * i.e. when loading files, where the server/service expects an Authorization header
  90753. */
  90754. static CustomRequestHeaders: {
  90755. [key: string]: string;
  90756. };
  90757. /**
  90758. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90759. */
  90760. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90761. /**
  90762. * Default behaviour for cors in the application.
  90763. * It can be a string if the expected behavior is identical in the entire app.
  90764. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90765. */
  90766. static CorsBehavior: string | ((url: string | string[]) => string);
  90767. /**
  90768. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90769. * @ignorenaming
  90770. */
  90771. static UseFallbackTexture: boolean;
  90772. /**
  90773. * Use this object to register external classes like custom textures or material
  90774. * to allow the laoders to instantiate them
  90775. */
  90776. static RegisteredExternalClasses: {
  90777. [key: string]: Object;
  90778. };
  90779. /**
  90780. * Texture content used if a texture cannot loaded
  90781. * @ignorenaming
  90782. */
  90783. static fallbackTexture: string;
  90784. /**
  90785. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90786. * @param u defines the coordinate on X axis
  90787. * @param v defines the coordinate on Y axis
  90788. * @param width defines the width of the source data
  90789. * @param height defines the height of the source data
  90790. * @param pixels defines the source byte array
  90791. * @param color defines the output color
  90792. */
  90793. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90794. /**
  90795. * Interpolates between a and b via alpha
  90796. * @param a The lower value (returned when alpha = 0)
  90797. * @param b The upper value (returned when alpha = 1)
  90798. * @param alpha The interpolation-factor
  90799. * @return The mixed value
  90800. */
  90801. static Mix(a: number, b: number, alpha: number): number;
  90802. /**
  90803. * Tries to instantiate a new object from a given class name
  90804. * @param className defines the class name to instantiate
  90805. * @returns the new object or null if the system was not able to do the instantiation
  90806. */
  90807. static Instantiate(className: string): any;
  90808. /**
  90809. * Provides a slice function that will work even on IE
  90810. * @param data defines the array to slice
  90811. * @param start defines the start of the data (optional)
  90812. * @param end defines the end of the data (optional)
  90813. * @returns the new sliced array
  90814. */
  90815. static Slice<T>(data: T, start?: number, end?: number): T;
  90816. /**
  90817. * Polyfill for setImmediate
  90818. * @param action defines the action to execute after the current execution block
  90819. */
  90820. static SetImmediate(action: () => void): void;
  90821. /**
  90822. * Function indicating if a number is an exponent of 2
  90823. * @param value defines the value to test
  90824. * @returns true if the value is an exponent of 2
  90825. */
  90826. static IsExponentOfTwo(value: number): boolean;
  90827. private static _tmpFloatArray;
  90828. /**
  90829. * Returns the nearest 32-bit single precision float representation of a Number
  90830. * @param value A Number. If the parameter is of a different type, it will get converted
  90831. * to a number or to NaN if it cannot be converted
  90832. * @returns number
  90833. */
  90834. static FloatRound(value: number): number;
  90835. /**
  90836. * Find the next highest power of two.
  90837. * @param x Number to start search from.
  90838. * @return Next highest power of two.
  90839. */
  90840. static CeilingPOT(x: number): number;
  90841. /**
  90842. * Find the next lowest power of two.
  90843. * @param x Number to start search from.
  90844. * @return Next lowest power of two.
  90845. */
  90846. static FloorPOT(x: number): number;
  90847. /**
  90848. * Find the nearest power of two.
  90849. * @param x Number to start search from.
  90850. * @return Next nearest power of two.
  90851. */
  90852. static NearestPOT(x: number): number;
  90853. /**
  90854. * Get the closest exponent of two
  90855. * @param value defines the value to approximate
  90856. * @param max defines the maximum value to return
  90857. * @param mode defines how to define the closest value
  90858. * @returns closest exponent of two of the given value
  90859. */
  90860. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90861. /**
  90862. * Extracts the filename from a path
  90863. * @param path defines the path to use
  90864. * @returns the filename
  90865. */
  90866. static GetFilename(path: string): string;
  90867. /**
  90868. * Extracts the "folder" part of a path (everything before the filename).
  90869. * @param uri The URI to extract the info from
  90870. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90871. * @returns The "folder" part of the path
  90872. */
  90873. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90874. /**
  90875. * Extracts text content from a DOM element hierarchy
  90876. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90877. */
  90878. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90879. /**
  90880. * Convert an angle in radians to degrees
  90881. * @param angle defines the angle to convert
  90882. * @returns the angle in degrees
  90883. */
  90884. static ToDegrees(angle: number): number;
  90885. /**
  90886. * Convert an angle in degrees to radians
  90887. * @param angle defines the angle to convert
  90888. * @returns the angle in radians
  90889. */
  90890. static ToRadians(angle: number): number;
  90891. /**
  90892. * Encode a buffer to a base64 string
  90893. * @param buffer defines the buffer to encode
  90894. * @returns the encoded string
  90895. */
  90896. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90897. /**
  90898. * Extracts minimum and maximum values from a list of indexed positions
  90899. * @param positions defines the positions to use
  90900. * @param indices defines the indices to the positions
  90901. * @param indexStart defines the start index
  90902. * @param indexCount defines the end index
  90903. * @param bias defines bias value to add to the result
  90904. * @return minimum and maximum values
  90905. */
  90906. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90907. minimum: Vector3;
  90908. maximum: Vector3;
  90909. };
  90910. /**
  90911. * Extracts minimum and maximum values from a list of positions
  90912. * @param positions defines the positions to use
  90913. * @param start defines the start index in the positions array
  90914. * @param count defines the number of positions to handle
  90915. * @param bias defines bias value to add to the result
  90916. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90917. * @return minimum and maximum values
  90918. */
  90919. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90920. minimum: Vector3;
  90921. maximum: Vector3;
  90922. };
  90923. /**
  90924. * Returns an array if obj is not an array
  90925. * @param obj defines the object to evaluate as an array
  90926. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90927. * @returns either obj directly if obj is an array or a new array containing obj
  90928. */
  90929. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90930. /**
  90931. * Gets the pointer prefix to use
  90932. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90933. */
  90934. static GetPointerPrefix(): string;
  90935. /**
  90936. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90937. * @param func - the function to be called
  90938. * @param requester - the object that will request the next frame. Falls back to window.
  90939. * @returns frame number
  90940. */
  90941. static QueueNewFrame(func: () => void, requester?: any): number;
  90942. /**
  90943. * Ask the browser to promote the current element to fullscreen rendering mode
  90944. * @param element defines the DOM element to promote
  90945. */
  90946. static RequestFullscreen(element: HTMLElement): void;
  90947. /**
  90948. * Asks the browser to exit fullscreen mode
  90949. */
  90950. static ExitFullscreen(): void;
  90951. /**
  90952. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90953. * @param url define the url we are trying
  90954. * @param element define the dom element where to configure the cors policy
  90955. */
  90956. static SetCorsBehavior(url: string | string[], element: {
  90957. crossOrigin: string | null;
  90958. }): void;
  90959. /**
  90960. * Removes unwanted characters from an url
  90961. * @param url defines the url to clean
  90962. * @returns the cleaned url
  90963. */
  90964. static CleanUrl(url: string): string;
  90965. /**
  90966. * Gets or sets a function used to pre-process url before using them to load assets
  90967. */
  90968. static PreprocessUrl: (url: string) => string;
  90969. /**
  90970. * Loads an image as an HTMLImageElement.
  90971. * @param input url string, ArrayBuffer, or Blob to load
  90972. * @param onLoad callback called when the image successfully loads
  90973. * @param onError callback called when the image fails to load
  90974. * @param offlineProvider offline provider for caching
  90975. * @returns the HTMLImageElement of the loaded image
  90976. */
  90977. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90978. /**
  90979. * Loads a file
  90980. * @param url url string, ArrayBuffer, or Blob to load
  90981. * @param onSuccess callback called when the file successfully loads
  90982. * @param onProgress callback called while file is loading (if the server supports this mode)
  90983. * @param offlineProvider defines the offline provider for caching
  90984. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90985. * @param onError callback called when the file fails to load
  90986. * @returns a file request object
  90987. */
  90988. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  90989. /**
  90990. * Load a script (identified by an url). When the url returns, the
  90991. * content of this file is added into a new script element, attached to the DOM (body element)
  90992. * @param scriptUrl defines the url of the script to laod
  90993. * @param onSuccess defines the callback called when the script is loaded
  90994. * @param onError defines the callback to call if an error occurs
  90995. * @param scriptId defines the id of the script element
  90996. */
  90997. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90998. /**
  90999. * Load an asynchronous script (identified by an url). When the url returns, the
  91000. * content of this file is added into a new script element, attached to the DOM (body element)
  91001. * @param scriptUrl defines the url of the script to laod
  91002. * @param scriptId defines the id of the script element
  91003. * @returns a promise request object
  91004. */
  91005. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  91006. /**
  91007. * Loads a file from a blob
  91008. * @param fileToLoad defines the blob to use
  91009. * @param callback defines the callback to call when data is loaded
  91010. * @param progressCallback defines the callback to call during loading process
  91011. * @returns a file request object
  91012. */
  91013. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  91014. /**
  91015. * Loads a file
  91016. * @param fileToLoad defines the file to load
  91017. * @param callback defines the callback to call when data is loaded
  91018. * @param progressCallBack defines the callback to call during loading process
  91019. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  91020. * @returns a file request object
  91021. */
  91022. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  91023. /**
  91024. * Creates a data url from a given string content
  91025. * @param content defines the content to convert
  91026. * @returns the new data url link
  91027. */
  91028. static FileAsURL(content: string): string;
  91029. /**
  91030. * Format the given number to a specific decimal format
  91031. * @param value defines the number to format
  91032. * @param decimals defines the number of decimals to use
  91033. * @returns the formatted string
  91034. */
  91035. static Format(value: number, decimals?: number): string;
  91036. /**
  91037. * Checks if a given vector is inside a specific range
  91038. * @param v defines the vector to test
  91039. * @param min defines the minimum range
  91040. * @param max defines the maximum range
  91041. */
  91042. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  91043. /**
  91044. * Tries to copy an object by duplicating every property
  91045. * @param source defines the source object
  91046. * @param destination defines the target object
  91047. * @param doNotCopyList defines a list of properties to avoid
  91048. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  91049. */
  91050. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  91051. /**
  91052. * Gets a boolean indicating if the given object has no own property
  91053. * @param obj defines the object to test
  91054. * @returns true if object has no own property
  91055. */
  91056. static IsEmpty(obj: any): boolean;
  91057. /**
  91058. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  91059. * @param str Source string
  91060. * @param suffix Suffix to search for in the source string
  91061. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  91062. */
  91063. static EndsWith(str: string, suffix: string): boolean;
  91064. /**
  91065. * Function used to register events at window level
  91066. * @param events defines the events to register
  91067. */
  91068. static RegisterTopRootEvents(events: {
  91069. name: string;
  91070. handler: Nullable<(e: FocusEvent) => any>;
  91071. }[]): void;
  91072. /**
  91073. * Function used to unregister events from window level
  91074. * @param events defines the events to unregister
  91075. */
  91076. static UnregisterTopRootEvents(events: {
  91077. name: string;
  91078. handler: Nullable<(e: FocusEvent) => any>;
  91079. }[]): void;
  91080. /**
  91081. * @ignore
  91082. */
  91083. static _ScreenshotCanvas: HTMLCanvasElement;
  91084. /**
  91085. * Dumps the current bound framebuffer
  91086. * @param width defines the rendering width
  91087. * @param height defines the rendering height
  91088. * @param engine defines the hosting engine
  91089. * @param successCallback defines the callback triggered once the data are available
  91090. * @param mimeType defines the mime type of the result
  91091. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  91092. */
  91093. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91094. /**
  91095. * Converts the canvas data to blob.
  91096. * This acts as a polyfill for browsers not supporting the to blob function.
  91097. * @param canvas Defines the canvas to extract the data from
  91098. * @param successCallback Defines the callback triggered once the data are available
  91099. * @param mimeType Defines the mime type of the result
  91100. */
  91101. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  91102. /**
  91103. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  91104. * @param successCallback defines the callback triggered once the data are available
  91105. * @param mimeType defines the mime type of the result
  91106. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  91107. */
  91108. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91109. /**
  91110. * Downloads a blob in the browser
  91111. * @param blob defines the blob to download
  91112. * @param fileName defines the name of the downloaded file
  91113. */
  91114. static Download(blob: Blob, fileName: string): void;
  91115. /**
  91116. * Captures a screenshot of the current rendering
  91117. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91118. * @param engine defines the rendering engine
  91119. * @param camera defines the source camera
  91120. * @param size This parameter can be set to a single number or to an object with the
  91121. * following (optional) properties: precision, width, height. If a single number is passed,
  91122. * it will be used for both width and height. If an object is passed, the screenshot size
  91123. * will be derived from the parameters. The precision property is a multiplier allowing
  91124. * rendering at a higher or lower resolution
  91125. * @param successCallback defines the callback receives a single parameter which contains the
  91126. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91127. * src parameter of an <img> to display it
  91128. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  91129. * Check your browser for supported MIME types
  91130. */
  91131. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  91132. /**
  91133. * Generates an image screenshot from the specified camera.
  91134. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91135. * @param engine The engine to use for rendering
  91136. * @param camera The camera to use for rendering
  91137. * @param size This parameter can be set to a single number or to an object with the
  91138. * following (optional) properties: precision, width, height. If a single number is passed,
  91139. * it will be used for both width and height. If an object is passed, the screenshot size
  91140. * will be derived from the parameters. The precision property is a multiplier allowing
  91141. * rendering at a higher or lower resolution
  91142. * @param successCallback The callback receives a single parameter which contains the
  91143. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91144. * src parameter of an <img> to display it
  91145. * @param mimeType The MIME type of the screenshot image (default: image/png).
  91146. * Check your browser for supported MIME types
  91147. * @param samples Texture samples (default: 1)
  91148. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  91149. * @param fileName A name for for the downloaded file.
  91150. */
  91151. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  91152. /**
  91153. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91154. * Be aware Math.random() could cause collisions, but:
  91155. * "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"
  91156. * @returns a pseudo random id
  91157. */
  91158. static RandomId(): string;
  91159. /**
  91160. * Test if the given uri is a base64 string
  91161. * @param uri The uri to test
  91162. * @return True if the uri is a base64 string or false otherwise
  91163. */
  91164. static IsBase64(uri: string): boolean;
  91165. /**
  91166. * Decode the given base64 uri.
  91167. * @param uri The uri to decode
  91168. * @return The decoded base64 data.
  91169. */
  91170. static DecodeBase64(uri: string): ArrayBuffer;
  91171. /**
  91172. * Gets the absolute url.
  91173. * @param url the input url
  91174. * @return the absolute url
  91175. */
  91176. static GetAbsoluteUrl(url: string): string;
  91177. /**
  91178. * No log
  91179. */
  91180. static readonly NoneLogLevel: number;
  91181. /**
  91182. * Only message logs
  91183. */
  91184. static readonly MessageLogLevel: number;
  91185. /**
  91186. * Only warning logs
  91187. */
  91188. static readonly WarningLogLevel: number;
  91189. /**
  91190. * Only error logs
  91191. */
  91192. static readonly ErrorLogLevel: number;
  91193. /**
  91194. * All logs
  91195. */
  91196. static readonly AllLogLevel: number;
  91197. /**
  91198. * Gets a value indicating the number of loading errors
  91199. * @ignorenaming
  91200. */
  91201. static readonly errorsCount: number;
  91202. /**
  91203. * Callback called when a new log is added
  91204. */
  91205. static OnNewCacheEntry: (entry: string) => void;
  91206. /**
  91207. * Log a message to the console
  91208. * @param message defines the message to log
  91209. */
  91210. static Log(message: string): void;
  91211. /**
  91212. * Write a warning message to the console
  91213. * @param message defines the message to log
  91214. */
  91215. static Warn(message: string): void;
  91216. /**
  91217. * Write an error message to the console
  91218. * @param message defines the message to log
  91219. */
  91220. static Error(message: string): void;
  91221. /**
  91222. * Gets current log cache (list of logs)
  91223. */
  91224. static readonly LogCache: string;
  91225. /**
  91226. * Clears the log cache
  91227. */
  91228. static ClearLogCache(): void;
  91229. /**
  91230. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  91231. */
  91232. static LogLevels: number;
  91233. /**
  91234. * Checks if the loaded document was accessed via `file:`-Protocol.
  91235. * @returns boolean
  91236. */
  91237. static IsFileURL(): boolean;
  91238. /**
  91239. * Checks if the window object exists
  91240. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  91241. */
  91242. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  91243. /**
  91244. * No performance log
  91245. */
  91246. static readonly PerformanceNoneLogLevel: number;
  91247. /**
  91248. * Use user marks to log performance
  91249. */
  91250. static readonly PerformanceUserMarkLogLevel: number;
  91251. /**
  91252. * Log performance to the console
  91253. */
  91254. static readonly PerformanceConsoleLogLevel: number;
  91255. private static _performance;
  91256. /**
  91257. * Sets the current performance log level
  91258. */
  91259. static PerformanceLogLevel: number;
  91260. private static _StartPerformanceCounterDisabled;
  91261. private static _EndPerformanceCounterDisabled;
  91262. private static _StartUserMark;
  91263. private static _EndUserMark;
  91264. private static _StartPerformanceConsole;
  91265. private static _EndPerformanceConsole;
  91266. /**
  91267. * Starts a performance counter
  91268. */
  91269. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91270. /**
  91271. * Ends a specific performance coutner
  91272. */
  91273. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91274. /**
  91275. * Gets either window.performance.now() if supported or Date.now() else
  91276. */
  91277. static readonly Now: number;
  91278. /**
  91279. * This method will return the name of the class used to create the instance of the given object.
  91280. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  91281. * @param object the object to get the class name from
  91282. * @param isType defines if the object is actually a type
  91283. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  91284. */
  91285. static GetClassName(object: any, isType?: boolean): string;
  91286. /**
  91287. * Gets the first element of an array satisfying a given predicate
  91288. * @param array defines the array to browse
  91289. * @param predicate defines the predicate to use
  91290. * @returns null if not found or the element
  91291. */
  91292. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  91293. /**
  91294. * This method will return the name of the full name of the class, including its owning module (if any).
  91295. * 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).
  91296. * @param object the object to get the class name from
  91297. * @param isType defines if the object is actually a type
  91298. * @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.
  91299. * @ignorenaming
  91300. */
  91301. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  91302. /**
  91303. * Returns a promise that resolves after the given amount of time.
  91304. * @param delay Number of milliseconds to delay
  91305. * @returns Promise that resolves after the given amount of time
  91306. */
  91307. static DelayAsync(delay: number): Promise<void>;
  91308. /**
  91309. * Gets the current gradient from an array of IValueGradient
  91310. * @param ratio defines the current ratio to get
  91311. * @param gradients defines the array of IValueGradient
  91312. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91313. */
  91314. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91315. }
  91316. /**
  91317. * This class is used to track a performance counter which is number based.
  91318. * The user has access to many properties which give statistics of different nature.
  91319. *
  91320. * The implementer can track two kinds of Performance Counter: time and count.
  91321. * 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.
  91322. * 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.
  91323. */
  91324. export class PerfCounter {
  91325. /**
  91326. * Gets or sets a global boolean to turn on and off all the counters
  91327. */
  91328. static Enabled: boolean;
  91329. /**
  91330. * Returns the smallest value ever
  91331. */
  91332. readonly min: number;
  91333. /**
  91334. * Returns the biggest value ever
  91335. */
  91336. readonly max: number;
  91337. /**
  91338. * Returns the average value since the performance counter is running
  91339. */
  91340. readonly average: number;
  91341. /**
  91342. * Returns the average value of the last second the counter was monitored
  91343. */
  91344. readonly lastSecAverage: number;
  91345. /**
  91346. * Returns the current value
  91347. */
  91348. readonly current: number;
  91349. /**
  91350. * Gets the accumulated total
  91351. */
  91352. readonly total: number;
  91353. /**
  91354. * Gets the total value count
  91355. */
  91356. readonly count: number;
  91357. /**
  91358. * Creates a new counter
  91359. */
  91360. constructor();
  91361. /**
  91362. * Call this method to start monitoring a new frame.
  91363. * 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.
  91364. */
  91365. fetchNewFrame(): void;
  91366. /**
  91367. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  91368. * @param newCount the count value to add to the monitored count
  91369. * @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.
  91370. */
  91371. addCount(newCount: number, fetchResult: boolean): void;
  91372. /**
  91373. * Start monitoring this performance counter
  91374. */
  91375. beginMonitoring(): void;
  91376. /**
  91377. * Compute the time lapsed since the previous beginMonitoring() call.
  91378. * @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
  91379. */
  91380. endMonitoring(newFrame?: boolean): void;
  91381. private _fetchResult;
  91382. private _startMonitoringTime;
  91383. private _min;
  91384. private _max;
  91385. private _average;
  91386. private _current;
  91387. private _totalValueCount;
  91388. private _totalAccumulated;
  91389. private _lastSecAverage;
  91390. private _lastSecAccumulated;
  91391. private _lastSecTime;
  91392. private _lastSecValueCount;
  91393. }
  91394. /**
  91395. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  91396. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  91397. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  91398. * @param name The name of the class, case should be preserved
  91399. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  91400. */
  91401. export function className(name: string, module?: string): (target: Object) => void;
  91402. /**
  91403. * An implementation of a loop for asynchronous functions.
  91404. */
  91405. export class AsyncLoop {
  91406. /**
  91407. * Defines the number of iterations for the loop
  91408. */
  91409. iterations: number;
  91410. /**
  91411. * Defines the current index of the loop.
  91412. */
  91413. index: number;
  91414. private _done;
  91415. private _fn;
  91416. private _successCallback;
  91417. /**
  91418. * Constructor.
  91419. * @param iterations the number of iterations.
  91420. * @param func the function to run each iteration
  91421. * @param successCallback the callback that will be called upon succesful execution
  91422. * @param offset starting offset.
  91423. */
  91424. constructor(
  91425. /**
  91426. * Defines the number of iterations for the loop
  91427. */
  91428. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  91429. /**
  91430. * Execute the next iteration. Must be called after the last iteration was finished.
  91431. */
  91432. executeNext(): void;
  91433. /**
  91434. * Break the loop and run the success callback.
  91435. */
  91436. breakLoop(): void;
  91437. /**
  91438. * Create and run an async loop.
  91439. * @param iterations the number of iterations.
  91440. * @param fn the function to run each iteration
  91441. * @param successCallback the callback that will be called upon succesful execution
  91442. * @param offset starting offset.
  91443. * @returns the created async loop object
  91444. */
  91445. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  91446. /**
  91447. * A for-loop that will run a given number of iterations synchronous and the rest async.
  91448. * @param iterations total number of iterations
  91449. * @param syncedIterations number of synchronous iterations in each async iteration.
  91450. * @param fn the function to call each iteration.
  91451. * @param callback a success call back that will be called when iterating stops.
  91452. * @param breakFunction a break condition (optional)
  91453. * @param timeout timeout settings for the setTimeout function. default - 0.
  91454. * @returns the created async loop object
  91455. */
  91456. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  91457. }
  91458. }
  91459. declare module BABYLON {
  91460. /** @hidden */
  91461. export interface ICollisionCoordinator {
  91462. createCollider(): Collider;
  91463. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91464. init(scene: Scene): void;
  91465. }
  91466. /** @hidden */
  91467. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  91468. private _scene;
  91469. private _scaledPosition;
  91470. private _scaledVelocity;
  91471. private _finalPosition;
  91472. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91473. createCollider(): Collider;
  91474. init(scene: Scene): void;
  91475. private _collideWithWorld;
  91476. }
  91477. }
  91478. declare module BABYLON {
  91479. /**
  91480. * Class used to manage all inputs for the scene.
  91481. */
  91482. export class InputManager {
  91483. /** The distance in pixel that you have to move to prevent some events */
  91484. static DragMovementThreshold: number;
  91485. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91486. static LongPressDelay: number;
  91487. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91488. static DoubleClickDelay: number;
  91489. /** If you need to check double click without raising a single click at first click, enable this flag */
  91490. static ExclusiveDoubleClickMode: boolean;
  91491. private _wheelEventName;
  91492. private _onPointerMove;
  91493. private _onPointerDown;
  91494. private _onPointerUp;
  91495. private _initClickEvent;
  91496. private _initActionManager;
  91497. private _delayedSimpleClick;
  91498. private _delayedSimpleClickTimeout;
  91499. private _previousDelayedSimpleClickTimeout;
  91500. private _meshPickProceed;
  91501. private _previousButtonPressed;
  91502. private _currentPickResult;
  91503. private _previousPickResult;
  91504. private _totalPointersPressed;
  91505. private _doubleClickOccured;
  91506. private _pointerOverMesh;
  91507. private _pickedDownMesh;
  91508. private _pickedUpMesh;
  91509. private _pointerX;
  91510. private _pointerY;
  91511. private _unTranslatedPointerX;
  91512. private _unTranslatedPointerY;
  91513. private _startingPointerPosition;
  91514. private _previousStartingPointerPosition;
  91515. private _startingPointerTime;
  91516. private _previousStartingPointerTime;
  91517. private _pointerCaptures;
  91518. private _onKeyDown;
  91519. private _onKeyUp;
  91520. private _onCanvasFocusObserver;
  91521. private _onCanvasBlurObserver;
  91522. private _scene;
  91523. /**
  91524. * Creates a new InputManager
  91525. * @param scene defines the hosting scene
  91526. */
  91527. constructor(scene: Scene);
  91528. /**
  91529. * Gets the mesh that is currently under the pointer
  91530. */
  91531. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91532. /**
  91533. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  91534. */
  91535. readonly unTranslatedPointer: Vector2;
  91536. /**
  91537. * Gets or sets the current on-screen X position of the pointer
  91538. */
  91539. pointerX: number;
  91540. /**
  91541. * Gets or sets the current on-screen Y position of the pointer
  91542. */
  91543. pointerY: number;
  91544. private _updatePointerPosition;
  91545. private _processPointerMove;
  91546. private _setRayOnPointerInfo;
  91547. private _checkPrePointerObservable;
  91548. /**
  91549. * Use this method to simulate a pointer move on a mesh
  91550. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91551. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91552. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91553. */
  91554. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91555. /**
  91556. * Use this method to simulate a pointer down on a mesh
  91557. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91558. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91559. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91560. */
  91561. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91562. private _processPointerDown;
  91563. /** @hidden */
  91564. _isPointerSwiping(): boolean;
  91565. /**
  91566. * Use this method to simulate a pointer up on a mesh
  91567. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91568. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91569. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91570. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91571. */
  91572. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  91573. private _processPointerUp;
  91574. /**
  91575. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91576. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91577. * @returns true if the pointer was captured
  91578. */
  91579. isPointerCaptured(pointerId?: number): boolean;
  91580. /**
  91581. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91582. * @param attachUp defines if you want to attach events to pointerup
  91583. * @param attachDown defines if you want to attach events to pointerdown
  91584. * @param attachMove defines if you want to attach events to pointermove
  91585. */
  91586. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91587. /**
  91588. * Detaches all event handlers
  91589. */
  91590. detachControl(): void;
  91591. /**
  91592. * Force the value of meshUnderPointer
  91593. * @param mesh defines the mesh to use
  91594. */
  91595. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91596. /**
  91597. * Gets the mesh under the pointer
  91598. * @returns a Mesh or null if no mesh is under the pointer
  91599. */
  91600. getPointerOverMesh(): Nullable<AbstractMesh>;
  91601. }
  91602. }
  91603. declare module BABYLON {
  91604. /**
  91605. * This class defines the direct association between an animation and a target
  91606. */
  91607. export class TargetedAnimation {
  91608. /**
  91609. * Animation to perform
  91610. */
  91611. animation: Animation;
  91612. /**
  91613. * Target to animate
  91614. */
  91615. target: any;
  91616. }
  91617. /**
  91618. * Use this class to create coordinated animations on multiple targets
  91619. */
  91620. export class AnimationGroup implements IDisposable {
  91621. /** The name of the animation group */
  91622. name: string;
  91623. private _scene;
  91624. private _targetedAnimations;
  91625. private _animatables;
  91626. private _from;
  91627. private _to;
  91628. private _isStarted;
  91629. private _isPaused;
  91630. private _speedRatio;
  91631. /**
  91632. * Gets or sets the unique id of the node
  91633. */
  91634. uniqueId: number;
  91635. /**
  91636. * This observable will notify when one animation have ended
  91637. */
  91638. onAnimationEndObservable: Observable<TargetedAnimation>;
  91639. /**
  91640. * Observer raised when one animation loops
  91641. */
  91642. onAnimationLoopObservable: Observable<TargetedAnimation>;
  91643. /**
  91644. * This observable will notify when all animations have ended.
  91645. */
  91646. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  91647. /**
  91648. * This observable will notify when all animations have paused.
  91649. */
  91650. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  91651. /**
  91652. * This observable will notify when all animations are playing.
  91653. */
  91654. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  91655. /**
  91656. * Gets the first frame
  91657. */
  91658. readonly from: number;
  91659. /**
  91660. * Gets the last frame
  91661. */
  91662. readonly to: number;
  91663. /**
  91664. * Define if the animations are started
  91665. */
  91666. readonly isStarted: boolean;
  91667. /**
  91668. * Gets a value indicating that the current group is playing
  91669. */
  91670. readonly isPlaying: boolean;
  91671. /**
  91672. * Gets or sets the speed ratio to use for all animations
  91673. */
  91674. /**
  91675. * Gets or sets the speed ratio to use for all animations
  91676. */
  91677. speedRatio: number;
  91678. /**
  91679. * Gets the targeted animations for this animation group
  91680. */
  91681. readonly targetedAnimations: Array<TargetedAnimation>;
  91682. /**
  91683. * returning the list of animatables controlled by this animation group.
  91684. */
  91685. readonly animatables: Array<Animatable>;
  91686. /**
  91687. * Instantiates a new Animation Group.
  91688. * This helps managing several animations at once.
  91689. * @see http://doc.babylonjs.com/how_to/group
  91690. * @param name Defines the name of the group
  91691. * @param scene Defines the scene the group belongs to
  91692. */
  91693. constructor(
  91694. /** The name of the animation group */
  91695. name: string, scene?: Nullable<Scene>);
  91696. /**
  91697. * Add an animation (with its target) in the group
  91698. * @param animation defines the animation we want to add
  91699. * @param target defines the target of the animation
  91700. * @returns the TargetedAnimation object
  91701. */
  91702. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  91703. /**
  91704. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  91705. * It can add constant keys at begin or end
  91706. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  91707. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  91708. * @returns the animation group
  91709. */
  91710. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  91711. /**
  91712. * Start all animations on given targets
  91713. * @param loop defines if animations must loop
  91714. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  91715. * @param from defines the from key (optional)
  91716. * @param to defines the to key (optional)
  91717. * @returns the current animation group
  91718. */
  91719. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  91720. /**
  91721. * Pause all animations
  91722. * @returns the animation group
  91723. */
  91724. pause(): AnimationGroup;
  91725. /**
  91726. * Play all animations to initial state
  91727. * This function will start() the animations if they were not started or will restart() them if they were paused
  91728. * @param loop defines if animations must loop
  91729. * @returns the animation group
  91730. */
  91731. play(loop?: boolean): AnimationGroup;
  91732. /**
  91733. * Reset all animations to initial state
  91734. * @returns the animation group
  91735. */
  91736. reset(): AnimationGroup;
  91737. /**
  91738. * Restart animations from key 0
  91739. * @returns the animation group
  91740. */
  91741. restart(): AnimationGroup;
  91742. /**
  91743. * Stop all animations
  91744. * @returns the animation group
  91745. */
  91746. stop(): AnimationGroup;
  91747. /**
  91748. * Set animation weight for all animatables
  91749. * @param weight defines the weight to use
  91750. * @return the animationGroup
  91751. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91752. */
  91753. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91754. /**
  91755. * Synchronize and normalize all animatables with a source animatable
  91756. * @param root defines the root animatable to synchronize with
  91757. * @return the animationGroup
  91758. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91759. */
  91760. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91761. /**
  91762. * Goes to a specific frame in this animation group
  91763. * @param frame the frame number to go to
  91764. * @return the animationGroup
  91765. */
  91766. goToFrame(frame: number): AnimationGroup;
  91767. /**
  91768. * Dispose all associated resources
  91769. */
  91770. dispose(): void;
  91771. private _checkAnimationGroupEnded;
  91772. /**
  91773. * Clone the current animation group and returns a copy
  91774. * @param newName defines the name of the new group
  91775. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91776. * @returns the new aniamtion group
  91777. */
  91778. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91779. /**
  91780. * Returns a new AnimationGroup object parsed from the source provided.
  91781. * @param parsedAnimationGroup defines the source
  91782. * @param scene defines the scene that will receive the animationGroup
  91783. * @returns a new AnimationGroup
  91784. */
  91785. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91786. /**
  91787. * Returns the string "AnimationGroup"
  91788. * @returns "AnimationGroup"
  91789. */
  91790. getClassName(): string;
  91791. /**
  91792. * Creates a detailled string about the object
  91793. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91794. * @returns a string representing the object
  91795. */
  91796. toString(fullDetails?: boolean): string;
  91797. }
  91798. }
  91799. declare module BABYLON {
  91800. /**
  91801. * Define an interface for all classes that will hold resources
  91802. */
  91803. export interface IDisposable {
  91804. /**
  91805. * Releases all held resources
  91806. */
  91807. dispose(): void;
  91808. }
  91809. /** Interface defining initialization parameters for Scene class */
  91810. export interface SceneOptions {
  91811. /**
  91812. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91813. * It will improve performance when the number of geometries becomes important.
  91814. */
  91815. useGeometryUniqueIdsMap?: boolean;
  91816. /**
  91817. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91818. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91819. */
  91820. useMaterialMeshMap?: boolean;
  91821. /**
  91822. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91823. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91824. */
  91825. useClonedMeshhMap?: boolean;
  91826. }
  91827. /**
  91828. * Represents a scene to be rendered by the engine.
  91829. * @see http://doc.babylonjs.com/features/scene
  91830. */
  91831. export class Scene extends AbstractScene implements IAnimatable {
  91832. private static _uniqueIdCounter;
  91833. /** The fog is deactivated */
  91834. static readonly FOGMODE_NONE: number;
  91835. /** The fog density is following an exponential function */
  91836. static readonly FOGMODE_EXP: number;
  91837. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91838. static readonly FOGMODE_EXP2: number;
  91839. /** The fog density is following a linear function. */
  91840. static readonly FOGMODE_LINEAR: number;
  91841. /**
  91842. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91843. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91844. */
  91845. static MinDeltaTime: number;
  91846. /**
  91847. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91848. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91849. */
  91850. static MaxDeltaTime: number;
  91851. /**
  91852. * Factory used to create the default material.
  91853. * @param name The name of the material to create
  91854. * @param scene The scene to create the material for
  91855. * @returns The default material
  91856. */
  91857. static DefaultMaterialFactory(scene: Scene): Material;
  91858. /**
  91859. * Factory used to create the a collision coordinator.
  91860. * @returns The collision coordinator
  91861. */
  91862. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91863. /** @hidden */
  91864. _inputManager: InputManager;
  91865. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91866. cameraToUseForPointers: Nullable<Camera>;
  91867. /** @hidden */
  91868. readonly _isScene: boolean;
  91869. /**
  91870. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91871. */
  91872. autoClear: boolean;
  91873. /**
  91874. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91875. */
  91876. autoClearDepthAndStencil: boolean;
  91877. /**
  91878. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91879. */
  91880. clearColor: Color4;
  91881. /**
  91882. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91883. */
  91884. ambientColor: Color3;
  91885. /**
  91886. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91887. * It should only be one of the following (if not the default embedded one):
  91888. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91889. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91890. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91891. * The material properties need to be setup according to the type of texture in use.
  91892. */
  91893. environmentBRDFTexture: BaseTexture;
  91894. /** @hidden */
  91895. protected _environmentTexture: Nullable<BaseTexture>;
  91896. /**
  91897. * Texture used in all pbr material as the reflection texture.
  91898. * As in the majority of the scene they are the same (exception for multi room and so on),
  91899. * this is easier to reference from here than from all the materials.
  91900. */
  91901. /**
  91902. * Texture used in all pbr material as the reflection texture.
  91903. * As in the majority of the scene they are the same (exception for multi room and so on),
  91904. * this is easier to set here than in all the materials.
  91905. */
  91906. environmentTexture: Nullable<BaseTexture>;
  91907. /** @hidden */
  91908. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91909. /**
  91910. * Default image processing configuration used either in the rendering
  91911. * Forward main pass or through the imageProcessingPostProcess if present.
  91912. * As in the majority of the scene they are the same (exception for multi camera),
  91913. * this is easier to reference from here than from all the materials and post process.
  91914. *
  91915. * No setter as we it is a shared configuration, you can set the values instead.
  91916. */
  91917. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91918. private _forceWireframe;
  91919. /**
  91920. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91921. */
  91922. forceWireframe: boolean;
  91923. private _forcePointsCloud;
  91924. /**
  91925. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91926. */
  91927. forcePointsCloud: boolean;
  91928. /**
  91929. * Gets or sets the active clipplane 1
  91930. */
  91931. clipPlane: Nullable<Plane>;
  91932. /**
  91933. * Gets or sets the active clipplane 2
  91934. */
  91935. clipPlane2: Nullable<Plane>;
  91936. /**
  91937. * Gets or sets the active clipplane 3
  91938. */
  91939. clipPlane3: Nullable<Plane>;
  91940. /**
  91941. * Gets or sets the active clipplane 4
  91942. */
  91943. clipPlane4: Nullable<Plane>;
  91944. /**
  91945. * Gets or sets a boolean indicating if animations are enabled
  91946. */
  91947. animationsEnabled: boolean;
  91948. private _animationPropertiesOverride;
  91949. /**
  91950. * Gets or sets the animation properties override
  91951. */
  91952. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91953. /**
  91954. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91955. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91956. */
  91957. useConstantAnimationDeltaTime: boolean;
  91958. /**
  91959. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91960. * Please note that it requires to run a ray cast through the scene on every frame
  91961. */
  91962. constantlyUpdateMeshUnderPointer: boolean;
  91963. /**
  91964. * Defines the HTML cursor to use when hovering over interactive elements
  91965. */
  91966. hoverCursor: string;
  91967. /**
  91968. * Defines the HTML default cursor to use (empty by default)
  91969. */
  91970. defaultCursor: string;
  91971. /**
  91972. * This is used to call preventDefault() on pointer down
  91973. * in order to block unwanted artifacts like system double clicks
  91974. */
  91975. preventDefaultOnPointerDown: boolean;
  91976. /**
  91977. * This is used to call preventDefault() on pointer up
  91978. * in order to block unwanted artifacts like system double clicks
  91979. */
  91980. preventDefaultOnPointerUp: boolean;
  91981. /**
  91982. * Gets or sets user defined metadata
  91983. */
  91984. metadata: any;
  91985. /**
  91986. * For internal use only. Please do not use.
  91987. */
  91988. reservedDataStore: any;
  91989. /**
  91990. * Gets the name of the plugin used to load this scene (null by default)
  91991. */
  91992. loadingPluginName: string;
  91993. /**
  91994. * Use this array to add regular expressions used to disable offline support for specific urls
  91995. */
  91996. disableOfflineSupportExceptionRules: RegExp[];
  91997. /**
  91998. * An event triggered when the scene is disposed.
  91999. */
  92000. onDisposeObservable: Observable<Scene>;
  92001. private _onDisposeObserver;
  92002. /** Sets a function to be executed when this scene is disposed. */
  92003. onDispose: () => void;
  92004. /**
  92005. * An event triggered before rendering the scene (right after animations and physics)
  92006. */
  92007. onBeforeRenderObservable: Observable<Scene>;
  92008. private _onBeforeRenderObserver;
  92009. /** Sets a function to be executed before rendering this scene */
  92010. beforeRender: Nullable<() => void>;
  92011. /**
  92012. * An event triggered after rendering the scene
  92013. */
  92014. onAfterRenderObservable: Observable<Scene>;
  92015. private _onAfterRenderObserver;
  92016. /** Sets a function to be executed after rendering this scene */
  92017. afterRender: Nullable<() => void>;
  92018. /**
  92019. * An event triggered before animating the scene
  92020. */
  92021. onBeforeAnimationsObservable: Observable<Scene>;
  92022. /**
  92023. * An event triggered after animations processing
  92024. */
  92025. onAfterAnimationsObservable: Observable<Scene>;
  92026. /**
  92027. * An event triggered before draw calls are ready to be sent
  92028. */
  92029. onBeforeDrawPhaseObservable: Observable<Scene>;
  92030. /**
  92031. * An event triggered after draw calls have been sent
  92032. */
  92033. onAfterDrawPhaseObservable: Observable<Scene>;
  92034. /**
  92035. * An event triggered when the scene is ready
  92036. */
  92037. onReadyObservable: Observable<Scene>;
  92038. /**
  92039. * An event triggered before rendering a camera
  92040. */
  92041. onBeforeCameraRenderObservable: Observable<Camera>;
  92042. private _onBeforeCameraRenderObserver;
  92043. /** Sets a function to be executed before rendering a camera*/
  92044. beforeCameraRender: () => void;
  92045. /**
  92046. * An event triggered after rendering a camera
  92047. */
  92048. onAfterCameraRenderObservable: Observable<Camera>;
  92049. private _onAfterCameraRenderObserver;
  92050. /** Sets a function to be executed after rendering a camera*/
  92051. afterCameraRender: () => void;
  92052. /**
  92053. * An event triggered when active meshes evaluation is about to start
  92054. */
  92055. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  92056. /**
  92057. * An event triggered when active meshes evaluation is done
  92058. */
  92059. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  92060. /**
  92061. * An event triggered when particles rendering is about to start
  92062. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92063. */
  92064. onBeforeParticlesRenderingObservable: Observable<Scene>;
  92065. /**
  92066. * An event triggered when particles rendering is done
  92067. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92068. */
  92069. onAfterParticlesRenderingObservable: Observable<Scene>;
  92070. /**
  92071. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  92072. */
  92073. onDataLoadedObservable: Observable<Scene>;
  92074. /**
  92075. * An event triggered when a camera is created
  92076. */
  92077. onNewCameraAddedObservable: Observable<Camera>;
  92078. /**
  92079. * An event triggered when a camera is removed
  92080. */
  92081. onCameraRemovedObservable: Observable<Camera>;
  92082. /**
  92083. * An event triggered when a light is created
  92084. */
  92085. onNewLightAddedObservable: Observable<Light>;
  92086. /**
  92087. * An event triggered when a light is removed
  92088. */
  92089. onLightRemovedObservable: Observable<Light>;
  92090. /**
  92091. * An event triggered when a geometry is created
  92092. */
  92093. onNewGeometryAddedObservable: Observable<Geometry>;
  92094. /**
  92095. * An event triggered when a geometry is removed
  92096. */
  92097. onGeometryRemovedObservable: Observable<Geometry>;
  92098. /**
  92099. * An event triggered when a transform node is created
  92100. */
  92101. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  92102. /**
  92103. * An event triggered when a transform node is removed
  92104. */
  92105. onTransformNodeRemovedObservable: Observable<TransformNode>;
  92106. /**
  92107. * An event triggered when a mesh is created
  92108. */
  92109. onNewMeshAddedObservable: Observable<AbstractMesh>;
  92110. /**
  92111. * An event triggered when a mesh is removed
  92112. */
  92113. onMeshRemovedObservable: Observable<AbstractMesh>;
  92114. /**
  92115. * An event triggered when a skeleton is created
  92116. */
  92117. onNewSkeletonAddedObservable: Observable<Skeleton>;
  92118. /**
  92119. * An event triggered when a skeleton is removed
  92120. */
  92121. onSkeletonRemovedObservable: Observable<Skeleton>;
  92122. /**
  92123. * An event triggered when a material is created
  92124. */
  92125. onNewMaterialAddedObservable: Observable<Material>;
  92126. /**
  92127. * An event triggered when a material is removed
  92128. */
  92129. onMaterialRemovedObservable: Observable<Material>;
  92130. /**
  92131. * An event triggered when a texture is created
  92132. */
  92133. onNewTextureAddedObservable: Observable<BaseTexture>;
  92134. /**
  92135. * An event triggered when a texture is removed
  92136. */
  92137. onTextureRemovedObservable: Observable<BaseTexture>;
  92138. /**
  92139. * An event triggered when render targets are about to be rendered
  92140. * Can happen multiple times per frame.
  92141. */
  92142. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  92143. /**
  92144. * An event triggered when render targets were rendered.
  92145. * Can happen multiple times per frame.
  92146. */
  92147. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  92148. /**
  92149. * An event triggered before calculating deterministic simulation step
  92150. */
  92151. onBeforeStepObservable: Observable<Scene>;
  92152. /**
  92153. * An event triggered after calculating deterministic simulation step
  92154. */
  92155. onAfterStepObservable: Observable<Scene>;
  92156. /**
  92157. * An event triggered when the activeCamera property is updated
  92158. */
  92159. onActiveCameraChanged: Observable<Scene>;
  92160. /**
  92161. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  92162. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92163. * 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)
  92164. */
  92165. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92166. /**
  92167. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  92168. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92169. * 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)
  92170. */
  92171. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92172. /**
  92173. * This Observable will when a mesh has been imported into the scene.
  92174. */
  92175. onMeshImportedObservable: Observable<AbstractMesh>;
  92176. /**
  92177. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  92178. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  92179. */
  92180. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  92181. /** @hidden */
  92182. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  92183. /**
  92184. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  92185. */
  92186. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  92187. /**
  92188. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  92189. */
  92190. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  92191. /**
  92192. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  92193. */
  92194. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  92195. /** Callback called when a pointer move is detected */
  92196. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92197. /** Callback called when a pointer down is detected */
  92198. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92199. /** Callback called when a pointer up is detected */
  92200. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  92201. /** Callback called when a pointer pick is detected */
  92202. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  92203. /**
  92204. * 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).
  92205. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  92206. */
  92207. onPrePointerObservable: Observable<PointerInfoPre>;
  92208. /**
  92209. * Observable event triggered each time an input event is received from the rendering canvas
  92210. */
  92211. onPointerObservable: Observable<PointerInfo>;
  92212. /**
  92213. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  92214. */
  92215. readonly unTranslatedPointer: Vector2;
  92216. /**
  92217. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  92218. */
  92219. static DragMovementThreshold: number;
  92220. /**
  92221. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  92222. */
  92223. static LongPressDelay: number;
  92224. /**
  92225. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  92226. */
  92227. static DoubleClickDelay: number;
  92228. /** If you need to check double click without raising a single click at first click, enable this flag */
  92229. static ExclusiveDoubleClickMode: boolean;
  92230. /** @hidden */
  92231. _mirroredCameraPosition: Nullable<Vector3>;
  92232. /**
  92233. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  92234. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  92235. */
  92236. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  92237. /**
  92238. * Observable event triggered each time an keyboard event is received from the hosting window
  92239. */
  92240. onKeyboardObservable: Observable<KeyboardInfo>;
  92241. private _useRightHandedSystem;
  92242. /**
  92243. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  92244. */
  92245. useRightHandedSystem: boolean;
  92246. private _timeAccumulator;
  92247. private _currentStepId;
  92248. private _currentInternalStep;
  92249. /**
  92250. * Sets the step Id used by deterministic lock step
  92251. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92252. * @param newStepId defines the step Id
  92253. */
  92254. setStepId(newStepId: number): void;
  92255. /**
  92256. * Gets the step Id used by deterministic lock step
  92257. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92258. * @returns the step Id
  92259. */
  92260. getStepId(): number;
  92261. /**
  92262. * Gets the internal step used by deterministic lock step
  92263. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92264. * @returns the internal step
  92265. */
  92266. getInternalStep(): number;
  92267. private _fogEnabled;
  92268. /**
  92269. * Gets or sets a boolean indicating if fog is enabled on this scene
  92270. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92271. * (Default is true)
  92272. */
  92273. fogEnabled: boolean;
  92274. private _fogMode;
  92275. /**
  92276. * Gets or sets the fog mode to use
  92277. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92278. * | mode | value |
  92279. * | --- | --- |
  92280. * | FOGMODE_NONE | 0 |
  92281. * | FOGMODE_EXP | 1 |
  92282. * | FOGMODE_EXP2 | 2 |
  92283. * | FOGMODE_LINEAR | 3 |
  92284. */
  92285. fogMode: number;
  92286. /**
  92287. * Gets or sets the fog color to use
  92288. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92289. * (Default is Color3(0.2, 0.2, 0.3))
  92290. */
  92291. fogColor: Color3;
  92292. /**
  92293. * Gets or sets the fog density to use
  92294. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92295. * (Default is 0.1)
  92296. */
  92297. fogDensity: number;
  92298. /**
  92299. * Gets or sets the fog start distance to use
  92300. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92301. * (Default is 0)
  92302. */
  92303. fogStart: number;
  92304. /**
  92305. * Gets or sets the fog end distance to use
  92306. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92307. * (Default is 1000)
  92308. */
  92309. fogEnd: number;
  92310. private _shadowsEnabled;
  92311. /**
  92312. * Gets or sets a boolean indicating if shadows are enabled on this scene
  92313. */
  92314. shadowsEnabled: boolean;
  92315. private _lightsEnabled;
  92316. /**
  92317. * Gets or sets a boolean indicating if lights are enabled on this scene
  92318. */
  92319. lightsEnabled: boolean;
  92320. /** All of the active cameras added to this scene. */
  92321. activeCameras: Camera[];
  92322. /** @hidden */
  92323. _activeCamera: Nullable<Camera>;
  92324. /** Gets or sets the current active camera */
  92325. activeCamera: Nullable<Camera>;
  92326. private _defaultMaterial;
  92327. /** The default material used on meshes when no material is affected */
  92328. /** The default material used on meshes when no material is affected */
  92329. defaultMaterial: Material;
  92330. private _texturesEnabled;
  92331. /**
  92332. * Gets or sets a boolean indicating if textures are enabled on this scene
  92333. */
  92334. texturesEnabled: boolean;
  92335. /**
  92336. * Gets or sets a boolean indicating if particles are enabled on this scene
  92337. */
  92338. particlesEnabled: boolean;
  92339. /**
  92340. * Gets or sets a boolean indicating if sprites are enabled on this scene
  92341. */
  92342. spritesEnabled: boolean;
  92343. private _skeletonsEnabled;
  92344. /**
  92345. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  92346. */
  92347. skeletonsEnabled: boolean;
  92348. /**
  92349. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  92350. */
  92351. lensFlaresEnabled: boolean;
  92352. /**
  92353. * Gets or sets a boolean indicating if collisions are enabled on this scene
  92354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92355. */
  92356. collisionsEnabled: boolean;
  92357. private _collisionCoordinator;
  92358. /** @hidden */
  92359. readonly collisionCoordinator: ICollisionCoordinator;
  92360. /**
  92361. * Defines the gravity applied to this scene (used only for collisions)
  92362. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92363. */
  92364. gravity: Vector3;
  92365. /**
  92366. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  92367. */
  92368. postProcessesEnabled: boolean;
  92369. /**
  92370. * The list of postprocesses added to the scene
  92371. */
  92372. postProcesses: PostProcess[];
  92373. /**
  92374. * Gets the current postprocess manager
  92375. */
  92376. postProcessManager: PostProcessManager;
  92377. /**
  92378. * Gets or sets a boolean indicating if render targets are enabled on this scene
  92379. */
  92380. renderTargetsEnabled: boolean;
  92381. /**
  92382. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  92383. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  92384. */
  92385. dumpNextRenderTargets: boolean;
  92386. /**
  92387. * The list of user defined render targets added to the scene
  92388. */
  92389. customRenderTargets: RenderTargetTexture[];
  92390. /**
  92391. * Defines if texture loading must be delayed
  92392. * If true, textures will only be loaded when they need to be rendered
  92393. */
  92394. useDelayedTextureLoading: boolean;
  92395. /**
  92396. * Gets the list of meshes imported to the scene through SceneLoader
  92397. */
  92398. importedMeshesFiles: String[];
  92399. /**
  92400. * Gets or sets a boolean indicating if probes are enabled on this scene
  92401. */
  92402. probesEnabled: boolean;
  92403. /**
  92404. * Gets or sets the current offline provider to use to store scene data
  92405. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  92406. */
  92407. offlineProvider: IOfflineProvider;
  92408. /**
  92409. * Gets or sets the action manager associated with the scene
  92410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92411. */
  92412. actionManager: AbstractActionManager;
  92413. private _meshesForIntersections;
  92414. /**
  92415. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  92416. */
  92417. proceduralTexturesEnabled: boolean;
  92418. private _engine;
  92419. private _totalVertices;
  92420. /** @hidden */
  92421. _activeIndices: PerfCounter;
  92422. /** @hidden */
  92423. _activeParticles: PerfCounter;
  92424. /** @hidden */
  92425. _activeBones: PerfCounter;
  92426. private _animationRatio;
  92427. /** @hidden */
  92428. _animationTimeLast: number;
  92429. /** @hidden */
  92430. _animationTime: number;
  92431. /**
  92432. * Gets or sets a general scale for animation speed
  92433. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  92434. */
  92435. animationTimeScale: number;
  92436. /** @hidden */
  92437. _cachedMaterial: Nullable<Material>;
  92438. /** @hidden */
  92439. _cachedEffect: Nullable<Effect>;
  92440. /** @hidden */
  92441. _cachedVisibility: Nullable<number>;
  92442. private _renderId;
  92443. private _frameId;
  92444. private _executeWhenReadyTimeoutId;
  92445. private _intermediateRendering;
  92446. private _viewUpdateFlag;
  92447. private _projectionUpdateFlag;
  92448. /** @hidden */
  92449. _toBeDisposed: Nullable<IDisposable>[];
  92450. private _activeRequests;
  92451. /** @hidden */
  92452. _pendingData: any[];
  92453. private _isDisposed;
  92454. /**
  92455. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  92456. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  92457. */
  92458. dispatchAllSubMeshesOfActiveMeshes: boolean;
  92459. private _activeMeshes;
  92460. private _processedMaterials;
  92461. private _renderTargets;
  92462. /** @hidden */
  92463. _activeParticleSystems: SmartArray<IParticleSystem>;
  92464. private _activeSkeletons;
  92465. private _softwareSkinnedMeshes;
  92466. private _renderingManager;
  92467. /** @hidden */
  92468. _activeAnimatables: Animatable[];
  92469. private _transformMatrix;
  92470. private _sceneUbo;
  92471. /** @hidden */
  92472. _viewMatrix: Matrix;
  92473. private _projectionMatrix;
  92474. /** @hidden */
  92475. _forcedViewPosition: Nullable<Vector3>;
  92476. /** @hidden */
  92477. _frustumPlanes: Plane[];
  92478. /**
  92479. * Gets the list of frustum planes (built from the active camera)
  92480. */
  92481. readonly frustumPlanes: Plane[];
  92482. /**
  92483. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  92484. * This is useful if there are more lights that the maximum simulteanous authorized
  92485. */
  92486. requireLightSorting: boolean;
  92487. /** @hidden */
  92488. readonly useMaterialMeshMap: boolean;
  92489. /** @hidden */
  92490. readonly useClonedMeshhMap: boolean;
  92491. private _externalData;
  92492. private _uid;
  92493. /**
  92494. * @hidden
  92495. * Backing store of defined scene components.
  92496. */
  92497. _components: ISceneComponent[];
  92498. /**
  92499. * @hidden
  92500. * Backing store of defined scene components.
  92501. */
  92502. _serializableComponents: ISceneSerializableComponent[];
  92503. /**
  92504. * List of components to register on the next registration step.
  92505. */
  92506. private _transientComponents;
  92507. /**
  92508. * Registers the transient components if needed.
  92509. */
  92510. private _registerTransientComponents;
  92511. /**
  92512. * @hidden
  92513. * Add a component to the scene.
  92514. * Note that the ccomponent could be registered on th next frame if this is called after
  92515. * the register component stage.
  92516. * @param component Defines the component to add to the scene
  92517. */
  92518. _addComponent(component: ISceneComponent): void;
  92519. /**
  92520. * @hidden
  92521. * Gets a component from the scene.
  92522. * @param name defines the name of the component to retrieve
  92523. * @returns the component or null if not present
  92524. */
  92525. _getComponent(name: string): Nullable<ISceneComponent>;
  92526. /**
  92527. * @hidden
  92528. * Defines the actions happening before camera updates.
  92529. */
  92530. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  92531. /**
  92532. * @hidden
  92533. * Defines the actions happening before clear the canvas.
  92534. */
  92535. _beforeClearStage: Stage<SimpleStageAction>;
  92536. /**
  92537. * @hidden
  92538. * Defines the actions when collecting render targets for the frame.
  92539. */
  92540. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92541. /**
  92542. * @hidden
  92543. * Defines the actions happening for one camera in the frame.
  92544. */
  92545. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92546. /**
  92547. * @hidden
  92548. * Defines the actions happening during the per mesh ready checks.
  92549. */
  92550. _isReadyForMeshStage: Stage<MeshStageAction>;
  92551. /**
  92552. * @hidden
  92553. * Defines the actions happening before evaluate active mesh checks.
  92554. */
  92555. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  92556. /**
  92557. * @hidden
  92558. * Defines the actions happening during the evaluate sub mesh checks.
  92559. */
  92560. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  92561. /**
  92562. * @hidden
  92563. * Defines the actions happening during the active mesh stage.
  92564. */
  92565. _activeMeshStage: Stage<ActiveMeshStageAction>;
  92566. /**
  92567. * @hidden
  92568. * Defines the actions happening during the per camera render target step.
  92569. */
  92570. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  92571. /**
  92572. * @hidden
  92573. * Defines the actions happening just before the active camera is drawing.
  92574. */
  92575. _beforeCameraDrawStage: Stage<CameraStageAction>;
  92576. /**
  92577. * @hidden
  92578. * Defines the actions happening just before a render target is drawing.
  92579. */
  92580. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92581. /**
  92582. * @hidden
  92583. * Defines the actions happening just before a rendering group is drawing.
  92584. */
  92585. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92586. /**
  92587. * @hidden
  92588. * Defines the actions happening just before a mesh is drawing.
  92589. */
  92590. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92591. /**
  92592. * @hidden
  92593. * Defines the actions happening just after a mesh has been drawn.
  92594. */
  92595. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92596. /**
  92597. * @hidden
  92598. * Defines the actions happening just after a rendering group has been drawn.
  92599. */
  92600. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92601. /**
  92602. * @hidden
  92603. * Defines the actions happening just after the active camera has been drawn.
  92604. */
  92605. _afterCameraDrawStage: Stage<CameraStageAction>;
  92606. /**
  92607. * @hidden
  92608. * Defines the actions happening just after a render target has been drawn.
  92609. */
  92610. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92611. /**
  92612. * @hidden
  92613. * Defines the actions happening just after rendering all cameras and computing intersections.
  92614. */
  92615. _afterRenderStage: Stage<SimpleStageAction>;
  92616. /**
  92617. * @hidden
  92618. * Defines the actions happening when a pointer move event happens.
  92619. */
  92620. _pointerMoveStage: Stage<PointerMoveStageAction>;
  92621. /**
  92622. * @hidden
  92623. * Defines the actions happening when a pointer down event happens.
  92624. */
  92625. _pointerDownStage: Stage<PointerUpDownStageAction>;
  92626. /**
  92627. * @hidden
  92628. * Defines the actions happening when a pointer up event happens.
  92629. */
  92630. _pointerUpStage: Stage<PointerUpDownStageAction>;
  92631. /**
  92632. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  92633. */
  92634. private geometriesByUniqueId;
  92635. /**
  92636. * Creates a new Scene
  92637. * @param engine defines the engine to use to render this scene
  92638. * @param options defines the scene options
  92639. */
  92640. constructor(engine: Engine, options?: SceneOptions);
  92641. /**
  92642. * Gets a string idenfifying the name of the class
  92643. * @returns "Scene" string
  92644. */
  92645. getClassName(): string;
  92646. private _defaultMeshCandidates;
  92647. /**
  92648. * @hidden
  92649. */
  92650. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  92651. private _defaultSubMeshCandidates;
  92652. /**
  92653. * @hidden
  92654. */
  92655. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  92656. /**
  92657. * Sets the default candidate providers for the scene.
  92658. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  92659. * and getCollidingSubMeshCandidates to their default function
  92660. */
  92661. setDefaultCandidateProviders(): void;
  92662. /**
  92663. * Gets the mesh that is currently under the pointer
  92664. */
  92665. readonly meshUnderPointer: Nullable<AbstractMesh>;
  92666. /**
  92667. * Gets or sets the current on-screen X position of the pointer
  92668. */
  92669. pointerX: number;
  92670. /**
  92671. * Gets or sets the current on-screen Y position of the pointer
  92672. */
  92673. pointerY: number;
  92674. /**
  92675. * Gets the cached material (ie. the latest rendered one)
  92676. * @returns the cached material
  92677. */
  92678. getCachedMaterial(): Nullable<Material>;
  92679. /**
  92680. * Gets the cached effect (ie. the latest rendered one)
  92681. * @returns the cached effect
  92682. */
  92683. getCachedEffect(): Nullable<Effect>;
  92684. /**
  92685. * Gets the cached visibility state (ie. the latest rendered one)
  92686. * @returns the cached visibility state
  92687. */
  92688. getCachedVisibility(): Nullable<number>;
  92689. /**
  92690. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  92691. * @param material defines the current material
  92692. * @param effect defines the current effect
  92693. * @param visibility defines the current visibility state
  92694. * @returns true if one parameter is not cached
  92695. */
  92696. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  92697. /**
  92698. * Gets the engine associated with the scene
  92699. * @returns an Engine
  92700. */
  92701. getEngine(): Engine;
  92702. /**
  92703. * Gets the total number of vertices rendered per frame
  92704. * @returns the total number of vertices rendered per frame
  92705. */
  92706. getTotalVertices(): number;
  92707. /**
  92708. * Gets the performance counter for total vertices
  92709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92710. */
  92711. readonly totalVerticesPerfCounter: PerfCounter;
  92712. /**
  92713. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  92714. * @returns the total number of active indices rendered per frame
  92715. */
  92716. getActiveIndices(): number;
  92717. /**
  92718. * Gets the performance counter for active indices
  92719. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92720. */
  92721. readonly totalActiveIndicesPerfCounter: PerfCounter;
  92722. /**
  92723. * Gets the total number of active particles rendered per frame
  92724. * @returns the total number of active particles rendered per frame
  92725. */
  92726. getActiveParticles(): number;
  92727. /**
  92728. * Gets the performance counter for active particles
  92729. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92730. */
  92731. readonly activeParticlesPerfCounter: PerfCounter;
  92732. /**
  92733. * Gets the total number of active bones rendered per frame
  92734. * @returns the total number of active bones rendered per frame
  92735. */
  92736. getActiveBones(): number;
  92737. /**
  92738. * Gets the performance counter for active bones
  92739. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92740. */
  92741. readonly activeBonesPerfCounter: PerfCounter;
  92742. /**
  92743. * Gets the array of active meshes
  92744. * @returns an array of AbstractMesh
  92745. */
  92746. getActiveMeshes(): SmartArray<AbstractMesh>;
  92747. /**
  92748. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92749. * @returns a number
  92750. */
  92751. getAnimationRatio(): number;
  92752. /**
  92753. * Gets an unique Id for the current render phase
  92754. * @returns a number
  92755. */
  92756. getRenderId(): number;
  92757. /**
  92758. * Gets an unique Id for the current frame
  92759. * @returns a number
  92760. */
  92761. getFrameId(): number;
  92762. /** Call this function if you want to manually increment the render Id*/
  92763. incrementRenderId(): void;
  92764. private _createUbo;
  92765. /**
  92766. * Use this method to simulate a pointer move on a mesh
  92767. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92768. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92769. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92770. * @returns the current scene
  92771. */
  92772. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92773. /**
  92774. * Use this method to simulate a pointer down on a mesh
  92775. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92776. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92777. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92778. * @returns the current scene
  92779. */
  92780. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92781. /**
  92782. * Use this method to simulate a pointer up on a mesh
  92783. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92784. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92785. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92786. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92787. * @returns the current scene
  92788. */
  92789. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92790. /**
  92791. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92792. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92793. * @returns true if the pointer was captured
  92794. */
  92795. isPointerCaptured(pointerId?: number): boolean;
  92796. /**
  92797. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92798. * @param attachUp defines if you want to attach events to pointerup
  92799. * @param attachDown defines if you want to attach events to pointerdown
  92800. * @param attachMove defines if you want to attach events to pointermove
  92801. */
  92802. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92803. /** Detaches all event handlers*/
  92804. detachControl(): void;
  92805. /**
  92806. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92807. * Delay loaded resources are not taking in account
  92808. * @return true if all required resources are ready
  92809. */
  92810. isReady(): boolean;
  92811. /** Resets all cached information relative to material (including effect and visibility) */
  92812. resetCachedMaterial(): void;
  92813. /**
  92814. * Registers a function to be called before every frame render
  92815. * @param func defines the function to register
  92816. */
  92817. registerBeforeRender(func: () => void): void;
  92818. /**
  92819. * Unregisters a function called before every frame render
  92820. * @param func defines the function to unregister
  92821. */
  92822. unregisterBeforeRender(func: () => void): void;
  92823. /**
  92824. * Registers a function to be called after every frame render
  92825. * @param func defines the function to register
  92826. */
  92827. registerAfterRender(func: () => void): void;
  92828. /**
  92829. * Unregisters a function called after every frame render
  92830. * @param func defines the function to unregister
  92831. */
  92832. unregisterAfterRender(func: () => void): void;
  92833. private _executeOnceBeforeRender;
  92834. /**
  92835. * The provided function will run before render once and will be disposed afterwards.
  92836. * A timeout delay can be provided so that the function will be executed in N ms.
  92837. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92838. * @param func The function to be executed.
  92839. * @param timeout optional delay in ms
  92840. */
  92841. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92842. /** @hidden */
  92843. _addPendingData(data: any): void;
  92844. /** @hidden */
  92845. _removePendingData(data: any): void;
  92846. /**
  92847. * Returns the number of items waiting to be loaded
  92848. * @returns the number of items waiting to be loaded
  92849. */
  92850. getWaitingItemsCount(): number;
  92851. /**
  92852. * Returns a boolean indicating if the scene is still loading data
  92853. */
  92854. readonly isLoading: boolean;
  92855. /**
  92856. * Registers a function to be executed when the scene is ready
  92857. * @param {Function} func - the function to be executed
  92858. */
  92859. executeWhenReady(func: () => void): void;
  92860. /**
  92861. * Returns a promise that resolves when the scene is ready
  92862. * @returns A promise that resolves when the scene is ready
  92863. */
  92864. whenReadyAsync(): Promise<void>;
  92865. /** @hidden */
  92866. _checkIsReady(): void;
  92867. /**
  92868. * Gets all animatable attached to the scene
  92869. */
  92870. readonly animatables: Animatable[];
  92871. /**
  92872. * Resets the last animation time frame.
  92873. * Useful to override when animations start running when loading a scene for the first time.
  92874. */
  92875. resetLastAnimationTimeFrame(): void;
  92876. /**
  92877. * Gets the current view matrix
  92878. * @returns a Matrix
  92879. */
  92880. getViewMatrix(): Matrix;
  92881. /**
  92882. * Gets the current projection matrix
  92883. * @returns a Matrix
  92884. */
  92885. getProjectionMatrix(): Matrix;
  92886. /**
  92887. * Gets the current transform matrix
  92888. * @returns a Matrix made of View * Projection
  92889. */
  92890. getTransformMatrix(): Matrix;
  92891. /**
  92892. * Sets the current transform matrix
  92893. * @param viewL defines the View matrix to use
  92894. * @param projectionL defines the Projection matrix to use
  92895. * @param viewR defines the right View matrix to use (if provided)
  92896. * @param projectionR defines the right Projection matrix to use (if provided)
  92897. */
  92898. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92899. /**
  92900. * Gets the uniform buffer used to store scene data
  92901. * @returns a UniformBuffer
  92902. */
  92903. getSceneUniformBuffer(): UniformBuffer;
  92904. /**
  92905. * Gets an unique (relatively to the current scene) Id
  92906. * @returns an unique number for the scene
  92907. */
  92908. getUniqueId(): number;
  92909. /**
  92910. * Add a mesh to the list of scene's meshes
  92911. * @param newMesh defines the mesh to add
  92912. * @param recursive if all child meshes should also be added to the scene
  92913. */
  92914. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92915. /**
  92916. * Remove a mesh for the list of scene's meshes
  92917. * @param toRemove defines the mesh to remove
  92918. * @param recursive if all child meshes should also be removed from the scene
  92919. * @returns the index where the mesh was in the mesh list
  92920. */
  92921. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92922. /**
  92923. * Add a transform node to the list of scene's transform nodes
  92924. * @param newTransformNode defines the transform node to add
  92925. */
  92926. addTransformNode(newTransformNode: TransformNode): void;
  92927. /**
  92928. * Remove a transform node for the list of scene's transform nodes
  92929. * @param toRemove defines the transform node to remove
  92930. * @returns the index where the transform node was in the transform node list
  92931. */
  92932. removeTransformNode(toRemove: TransformNode): number;
  92933. /**
  92934. * Remove a skeleton for the list of scene's skeletons
  92935. * @param toRemove defines the skeleton to remove
  92936. * @returns the index where the skeleton was in the skeleton list
  92937. */
  92938. removeSkeleton(toRemove: Skeleton): number;
  92939. /**
  92940. * Remove a morph target for the list of scene's morph targets
  92941. * @param toRemove defines the morph target to remove
  92942. * @returns the index where the morph target was in the morph target list
  92943. */
  92944. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92945. /**
  92946. * Remove a light for the list of scene's lights
  92947. * @param toRemove defines the light to remove
  92948. * @returns the index where the light was in the light list
  92949. */
  92950. removeLight(toRemove: Light): number;
  92951. /**
  92952. * Remove a camera for the list of scene's cameras
  92953. * @param toRemove defines the camera to remove
  92954. * @returns the index where the camera was in the camera list
  92955. */
  92956. removeCamera(toRemove: Camera): number;
  92957. /**
  92958. * Remove a particle system for the list of scene's particle systems
  92959. * @param toRemove defines the particle system to remove
  92960. * @returns the index where the particle system was in the particle system list
  92961. */
  92962. removeParticleSystem(toRemove: IParticleSystem): number;
  92963. /**
  92964. * Remove a animation for the list of scene's animations
  92965. * @param toRemove defines the animation to remove
  92966. * @returns the index where the animation was in the animation list
  92967. */
  92968. removeAnimation(toRemove: Animation): number;
  92969. /**
  92970. * Will stop the animation of the given target
  92971. * @param target - the target
  92972. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  92973. * @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)
  92974. */
  92975. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  92976. /**
  92977. * Removes the given animation group from this scene.
  92978. * @param toRemove The animation group to remove
  92979. * @returns The index of the removed animation group
  92980. */
  92981. removeAnimationGroup(toRemove: AnimationGroup): number;
  92982. /**
  92983. * Removes the given multi-material from this scene.
  92984. * @param toRemove The multi-material to remove
  92985. * @returns The index of the removed multi-material
  92986. */
  92987. removeMultiMaterial(toRemove: MultiMaterial): number;
  92988. /**
  92989. * Removes the given material from this scene.
  92990. * @param toRemove The material to remove
  92991. * @returns The index of the removed material
  92992. */
  92993. removeMaterial(toRemove: Material): number;
  92994. /**
  92995. * Removes the given action manager from this scene.
  92996. * @param toRemove The action manager to remove
  92997. * @returns The index of the removed action manager
  92998. */
  92999. removeActionManager(toRemove: AbstractActionManager): number;
  93000. /**
  93001. * Removes the given texture from this scene.
  93002. * @param toRemove The texture to remove
  93003. * @returns The index of the removed texture
  93004. */
  93005. removeTexture(toRemove: BaseTexture): number;
  93006. /**
  93007. * Adds the given light to this scene
  93008. * @param newLight The light to add
  93009. */
  93010. addLight(newLight: Light): void;
  93011. /**
  93012. * Sorts the list list based on light priorities
  93013. */
  93014. sortLightsByPriority(): void;
  93015. /**
  93016. * Adds the given camera to this scene
  93017. * @param newCamera The camera to add
  93018. */
  93019. addCamera(newCamera: Camera): void;
  93020. /**
  93021. * Adds the given skeleton to this scene
  93022. * @param newSkeleton The skeleton to add
  93023. */
  93024. addSkeleton(newSkeleton: Skeleton): void;
  93025. /**
  93026. * Adds the given particle system to this scene
  93027. * @param newParticleSystem The particle system to add
  93028. */
  93029. addParticleSystem(newParticleSystem: IParticleSystem): void;
  93030. /**
  93031. * Adds the given animation to this scene
  93032. * @param newAnimation The animation to add
  93033. */
  93034. addAnimation(newAnimation: Animation): void;
  93035. /**
  93036. * Adds the given animation group to this scene.
  93037. * @param newAnimationGroup The animation group to add
  93038. */
  93039. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  93040. /**
  93041. * Adds the given multi-material to this scene
  93042. * @param newMultiMaterial The multi-material to add
  93043. */
  93044. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  93045. /**
  93046. * Adds the given material to this scene
  93047. * @param newMaterial The material to add
  93048. */
  93049. addMaterial(newMaterial: Material): void;
  93050. /**
  93051. * Adds the given morph target to this scene
  93052. * @param newMorphTargetManager The morph target to add
  93053. */
  93054. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  93055. /**
  93056. * Adds the given geometry to this scene
  93057. * @param newGeometry The geometry to add
  93058. */
  93059. addGeometry(newGeometry: Geometry): void;
  93060. /**
  93061. * Adds the given action manager to this scene
  93062. * @param newActionManager The action manager to add
  93063. */
  93064. addActionManager(newActionManager: AbstractActionManager): void;
  93065. /**
  93066. * Adds the given texture to this scene.
  93067. * @param newTexture The texture to add
  93068. */
  93069. addTexture(newTexture: BaseTexture): void;
  93070. /**
  93071. * Switch active camera
  93072. * @param newCamera defines the new active camera
  93073. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  93074. */
  93075. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  93076. /**
  93077. * sets the active camera of the scene using its ID
  93078. * @param id defines the camera's ID
  93079. * @return the new active camera or null if none found.
  93080. */
  93081. setActiveCameraByID(id: string): Nullable<Camera>;
  93082. /**
  93083. * sets the active camera of the scene using its name
  93084. * @param name defines the camera's name
  93085. * @returns the new active camera or null if none found.
  93086. */
  93087. setActiveCameraByName(name: string): Nullable<Camera>;
  93088. /**
  93089. * get an animation group using its name
  93090. * @param name defines the material's name
  93091. * @return the animation group or null if none found.
  93092. */
  93093. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  93094. /**
  93095. * Get a material using its unique id
  93096. * @param uniqueId defines the material's unique id
  93097. * @return the material or null if none found.
  93098. */
  93099. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  93100. /**
  93101. * get a material using its id
  93102. * @param id defines the material's ID
  93103. * @return the material or null if none found.
  93104. */
  93105. getMaterialByID(id: string): Nullable<Material>;
  93106. /**
  93107. * Gets a material using its name
  93108. * @param name defines the material's name
  93109. * @return the material or null if none found.
  93110. */
  93111. getMaterialByName(name: string): Nullable<Material>;
  93112. /**
  93113. * Gets a camera using its id
  93114. * @param id defines the id to look for
  93115. * @returns the camera or null if not found
  93116. */
  93117. getCameraByID(id: string): Nullable<Camera>;
  93118. /**
  93119. * Gets a camera using its unique id
  93120. * @param uniqueId defines the unique id to look for
  93121. * @returns the camera or null if not found
  93122. */
  93123. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  93124. /**
  93125. * Gets a camera using its name
  93126. * @param name defines the camera's name
  93127. * @return the camera or null if none found.
  93128. */
  93129. getCameraByName(name: string): Nullable<Camera>;
  93130. /**
  93131. * Gets a bone using its id
  93132. * @param id defines the bone's id
  93133. * @return the bone or null if not found
  93134. */
  93135. getBoneByID(id: string): Nullable<Bone>;
  93136. /**
  93137. * Gets a bone using its id
  93138. * @param name defines the bone's name
  93139. * @return the bone or null if not found
  93140. */
  93141. getBoneByName(name: string): Nullable<Bone>;
  93142. /**
  93143. * Gets a light node using its name
  93144. * @param name defines the the light's name
  93145. * @return the light or null if none found.
  93146. */
  93147. getLightByName(name: string): Nullable<Light>;
  93148. /**
  93149. * Gets a light node using its id
  93150. * @param id defines the light's id
  93151. * @return the light or null if none found.
  93152. */
  93153. getLightByID(id: string): Nullable<Light>;
  93154. /**
  93155. * Gets a light node using its scene-generated unique ID
  93156. * @param uniqueId defines the light's unique id
  93157. * @return the light or null if none found.
  93158. */
  93159. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  93160. /**
  93161. * Gets a particle system by id
  93162. * @param id defines the particle system id
  93163. * @return the corresponding system or null if none found
  93164. */
  93165. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  93166. /**
  93167. * Gets a geometry using its ID
  93168. * @param id defines the geometry's id
  93169. * @return the geometry or null if none found.
  93170. */
  93171. getGeometryByID(id: string): Nullable<Geometry>;
  93172. private _getGeometryByUniqueID;
  93173. /**
  93174. * Add a new geometry to this scene
  93175. * @param geometry defines the geometry to be added to the scene.
  93176. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  93177. * @return a boolean defining if the geometry was added or not
  93178. */
  93179. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  93180. /**
  93181. * Removes an existing geometry
  93182. * @param geometry defines the geometry to be removed from the scene
  93183. * @return a boolean defining if the geometry was removed or not
  93184. */
  93185. removeGeometry(geometry: Geometry): boolean;
  93186. /**
  93187. * Gets the list of geometries attached to the scene
  93188. * @returns an array of Geometry
  93189. */
  93190. getGeometries(): Geometry[];
  93191. /**
  93192. * Gets the first added mesh found of a given ID
  93193. * @param id defines the id to search for
  93194. * @return the mesh found or null if not found at all
  93195. */
  93196. getMeshByID(id: string): Nullable<AbstractMesh>;
  93197. /**
  93198. * Gets a list of meshes using their id
  93199. * @param id defines the id to search for
  93200. * @returns a list of meshes
  93201. */
  93202. getMeshesByID(id: string): Array<AbstractMesh>;
  93203. /**
  93204. * Gets the first added transform node found of a given ID
  93205. * @param id defines the id to search for
  93206. * @return the found transform node or null if not found at all.
  93207. */
  93208. getTransformNodeByID(id: string): Nullable<TransformNode>;
  93209. /**
  93210. * Gets a transform node with its auto-generated unique id
  93211. * @param uniqueId efines the unique id to search for
  93212. * @return the found transform node or null if not found at all.
  93213. */
  93214. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  93215. /**
  93216. * Gets a list of transform nodes using their id
  93217. * @param id defines the id to search for
  93218. * @returns a list of transform nodes
  93219. */
  93220. getTransformNodesByID(id: string): Array<TransformNode>;
  93221. /**
  93222. * Gets a mesh with its auto-generated unique id
  93223. * @param uniqueId defines the unique id to search for
  93224. * @return the found mesh or null if not found at all.
  93225. */
  93226. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  93227. /**
  93228. * Gets a the last added mesh using a given id
  93229. * @param id defines the id to search for
  93230. * @return the found mesh or null if not found at all.
  93231. */
  93232. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  93233. /**
  93234. * Gets a the last added node (Mesh, Camera, Light) using a given id
  93235. * @param id defines the id to search for
  93236. * @return the found node or null if not found at all
  93237. */
  93238. getLastEntryByID(id: string): Nullable<Node>;
  93239. /**
  93240. * Gets a node (Mesh, Camera, Light) using a given id
  93241. * @param id defines the id to search for
  93242. * @return the found node or null if not found at all
  93243. */
  93244. getNodeByID(id: string): Nullable<Node>;
  93245. /**
  93246. * Gets a node (Mesh, Camera, Light) using a given name
  93247. * @param name defines the name to search for
  93248. * @return the found node or null if not found at all.
  93249. */
  93250. getNodeByName(name: string): Nullable<Node>;
  93251. /**
  93252. * Gets a mesh using a given name
  93253. * @param name defines the name to search for
  93254. * @return the found mesh or null if not found at all.
  93255. */
  93256. getMeshByName(name: string): Nullable<AbstractMesh>;
  93257. /**
  93258. * Gets a transform node using a given name
  93259. * @param name defines the name to search for
  93260. * @return the found transform node or null if not found at all.
  93261. */
  93262. getTransformNodeByName(name: string): Nullable<TransformNode>;
  93263. /**
  93264. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  93265. * @param id defines the id to search for
  93266. * @return the found skeleton or null if not found at all.
  93267. */
  93268. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  93269. /**
  93270. * Gets a skeleton using a given auto generated unique id
  93271. * @param uniqueId defines the unique id to search for
  93272. * @return the found skeleton or null if not found at all.
  93273. */
  93274. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  93275. /**
  93276. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  93277. * @param id defines the id to search for
  93278. * @return the found skeleton or null if not found at all.
  93279. */
  93280. getSkeletonById(id: string): Nullable<Skeleton>;
  93281. /**
  93282. * Gets a skeleton using a given name
  93283. * @param name defines the name to search for
  93284. * @return the found skeleton or null if not found at all.
  93285. */
  93286. getSkeletonByName(name: string): Nullable<Skeleton>;
  93287. /**
  93288. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  93289. * @param id defines the id to search for
  93290. * @return the found morph target manager or null if not found at all.
  93291. */
  93292. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  93293. /**
  93294. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  93295. * @param id defines the id to search for
  93296. * @return the found morph target or null if not found at all.
  93297. */
  93298. getMorphTargetById(id: string): Nullable<MorphTarget>;
  93299. /**
  93300. * Gets a boolean indicating if the given mesh is active
  93301. * @param mesh defines the mesh to look for
  93302. * @returns true if the mesh is in the active list
  93303. */
  93304. isActiveMesh(mesh: AbstractMesh): boolean;
  93305. /**
  93306. * Return a unique id as a string which can serve as an identifier for the scene
  93307. */
  93308. readonly uid: string;
  93309. /**
  93310. * Add an externaly attached data from its key.
  93311. * This method call will fail and return false, if such key already exists.
  93312. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  93313. * @param key the unique key that identifies the data
  93314. * @param data the data object to associate to the key for this Engine instance
  93315. * @return true if no such key were already present and the data was added successfully, false otherwise
  93316. */
  93317. addExternalData<T>(key: string, data: T): boolean;
  93318. /**
  93319. * Get an externaly attached data from its key
  93320. * @param key the unique key that identifies the data
  93321. * @return the associated data, if present (can be null), or undefined if not present
  93322. */
  93323. getExternalData<T>(key: string): Nullable<T>;
  93324. /**
  93325. * Get an externaly attached data from its key, create it using a factory if it's not already present
  93326. * @param key the unique key that identifies the data
  93327. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  93328. * @return the associated data, can be null if the factory returned null.
  93329. */
  93330. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  93331. /**
  93332. * Remove an externaly attached data from the Engine instance
  93333. * @param key the unique key that identifies the data
  93334. * @return true if the data was successfully removed, false if it doesn't exist
  93335. */
  93336. removeExternalData(key: string): boolean;
  93337. private _evaluateSubMesh;
  93338. /**
  93339. * Clear the processed materials smart array preventing retention point in material dispose.
  93340. */
  93341. freeProcessedMaterials(): void;
  93342. private _preventFreeActiveMeshesAndRenderingGroups;
  93343. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  93344. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  93345. * when disposing several meshes in a row or a hierarchy of meshes.
  93346. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  93347. */
  93348. blockfreeActiveMeshesAndRenderingGroups: boolean;
  93349. /**
  93350. * Clear the active meshes smart array preventing retention point in mesh dispose.
  93351. */
  93352. freeActiveMeshes(): void;
  93353. /**
  93354. * Clear the info related to rendering groups preventing retention points during dispose.
  93355. */
  93356. freeRenderingGroups(): void;
  93357. /** @hidden */
  93358. _isInIntermediateRendering(): boolean;
  93359. /**
  93360. * Lambda returning the list of potentially active meshes.
  93361. */
  93362. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  93363. /**
  93364. * Lambda returning the list of potentially active sub meshes.
  93365. */
  93366. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  93367. /**
  93368. * Lambda returning the list of potentially intersecting sub meshes.
  93369. */
  93370. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  93371. /**
  93372. * Lambda returning the list of potentially colliding sub meshes.
  93373. */
  93374. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  93375. private _activeMeshesFrozen;
  93376. /**
  93377. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  93378. * @returns the current scene
  93379. */
  93380. freezeActiveMeshes(): Scene;
  93381. /**
  93382. * Use this function to restart evaluating active meshes on every frame
  93383. * @returns the current scene
  93384. */
  93385. unfreezeActiveMeshes(): Scene;
  93386. private _evaluateActiveMeshes;
  93387. private _activeMesh;
  93388. /**
  93389. * Update the transform matrix to update from the current active camera
  93390. * @param force defines a boolean used to force the update even if cache is up to date
  93391. */
  93392. updateTransformMatrix(force?: boolean): void;
  93393. private _bindFrameBuffer;
  93394. /** @hidden */
  93395. _allowPostProcessClearColor: boolean;
  93396. /** @hidden */
  93397. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  93398. private _processSubCameras;
  93399. private _checkIntersections;
  93400. /** @hidden */
  93401. _advancePhysicsEngineStep(step: number): void;
  93402. /**
  93403. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  93404. */
  93405. getDeterministicFrameTime: () => number;
  93406. /** @hidden */
  93407. _animate(): void;
  93408. /** Execute all animations (for a frame) */
  93409. animate(): void;
  93410. /**
  93411. * Render the scene
  93412. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  93413. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  93414. */
  93415. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  93416. /**
  93417. * Freeze all materials
  93418. * A frozen material will not be updatable but should be faster to render
  93419. */
  93420. freezeMaterials(): void;
  93421. /**
  93422. * Unfreeze all materials
  93423. * A frozen material will not be updatable but should be faster to render
  93424. */
  93425. unfreezeMaterials(): void;
  93426. /**
  93427. * Releases all held ressources
  93428. */
  93429. dispose(): void;
  93430. /**
  93431. * Gets if the scene is already disposed
  93432. */
  93433. readonly isDisposed: boolean;
  93434. /**
  93435. * Call this function to reduce memory footprint of the scene.
  93436. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  93437. */
  93438. clearCachedVertexData(): void;
  93439. /**
  93440. * This function will remove the local cached buffer data from texture.
  93441. * It will save memory but will prevent the texture from being rebuilt
  93442. */
  93443. cleanCachedTextureBuffer(): void;
  93444. /**
  93445. * Get the world extend vectors with an optional filter
  93446. *
  93447. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  93448. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  93449. */
  93450. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  93451. min: Vector3;
  93452. max: Vector3;
  93453. };
  93454. /**
  93455. * Creates a ray that can be used to pick in the scene
  93456. * @param x defines the x coordinate of the origin (on-screen)
  93457. * @param y defines the y coordinate of the origin (on-screen)
  93458. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93459. * @param camera defines the camera to use for the picking
  93460. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93461. * @returns a Ray
  93462. */
  93463. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  93464. /**
  93465. * Creates a ray that can be used to pick in the scene
  93466. * @param x defines the x coordinate of the origin (on-screen)
  93467. * @param y defines the y coordinate of the origin (on-screen)
  93468. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93469. * @param result defines the ray where to store the picking ray
  93470. * @param camera defines the camera to use for the picking
  93471. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93472. * @returns the current scene
  93473. */
  93474. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  93475. /**
  93476. * Creates a ray that can be used to pick in the scene
  93477. * @param x defines the x coordinate of the origin (on-screen)
  93478. * @param y defines the y coordinate of the origin (on-screen)
  93479. * @param camera defines the camera to use for the picking
  93480. * @returns a Ray
  93481. */
  93482. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  93483. /**
  93484. * Creates a ray that can be used to pick in the scene
  93485. * @param x defines the x coordinate of the origin (on-screen)
  93486. * @param y defines the y coordinate of the origin (on-screen)
  93487. * @param result defines the ray where to store the picking ray
  93488. * @param camera defines the camera to use for the picking
  93489. * @returns the current scene
  93490. */
  93491. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  93492. /** Launch a ray to try to pick a mesh in the scene
  93493. * @param x position on screen
  93494. * @param y position on screen
  93495. * @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
  93496. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  93497. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93498. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93499. * @returns a PickingInfo
  93500. */
  93501. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  93502. /** Use the given ray to pick a mesh in the scene
  93503. * @param ray The ray to use to pick meshes
  93504. * @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
  93505. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  93506. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93507. * @returns a PickingInfo
  93508. */
  93509. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  93510. /**
  93511. * Launch a ray to try to pick a mesh in the scene
  93512. * @param x X position on screen
  93513. * @param y Y position on screen
  93514. * @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
  93515. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93516. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93517. * @returns an array of PickingInfo
  93518. */
  93519. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93520. /**
  93521. * Launch a ray to try to pick a mesh in the scene
  93522. * @param ray Ray to use
  93523. * @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
  93524. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93525. * @returns an array of PickingInfo
  93526. */
  93527. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93528. /**
  93529. * Force the value of meshUnderPointer
  93530. * @param mesh defines the mesh to use
  93531. */
  93532. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93533. /**
  93534. * Gets the mesh under the pointer
  93535. * @returns a Mesh or null if no mesh is under the pointer
  93536. */
  93537. getPointerOverMesh(): Nullable<AbstractMesh>;
  93538. /** @hidden */
  93539. _rebuildGeometries(): void;
  93540. /** @hidden */
  93541. _rebuildTextures(): void;
  93542. private _getByTags;
  93543. /**
  93544. * Get a list of meshes by tags
  93545. * @param tagsQuery defines the tags query to use
  93546. * @param forEach defines a predicate used to filter results
  93547. * @returns an array of Mesh
  93548. */
  93549. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  93550. /**
  93551. * Get a list of cameras by tags
  93552. * @param tagsQuery defines the tags query to use
  93553. * @param forEach defines a predicate used to filter results
  93554. * @returns an array of Camera
  93555. */
  93556. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  93557. /**
  93558. * Get a list of lights by tags
  93559. * @param tagsQuery defines the tags query to use
  93560. * @param forEach defines a predicate used to filter results
  93561. * @returns an array of Light
  93562. */
  93563. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  93564. /**
  93565. * Get a list of materials by tags
  93566. * @param tagsQuery defines the tags query to use
  93567. * @param forEach defines a predicate used to filter results
  93568. * @returns an array of Material
  93569. */
  93570. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  93571. /**
  93572. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93573. * This allowed control for front to back rendering or reversly depending of the special needs.
  93574. *
  93575. * @param renderingGroupId The rendering group id corresponding to its index
  93576. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93577. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93578. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93579. */
  93580. 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;
  93581. /**
  93582. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93583. *
  93584. * @param renderingGroupId The rendering group id corresponding to its index
  93585. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93586. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93587. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93588. */
  93589. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93590. /**
  93591. * Gets the current auto clear configuration for one rendering group of the rendering
  93592. * manager.
  93593. * @param index the rendering group index to get the information for
  93594. * @returns The auto clear setup for the requested rendering group
  93595. */
  93596. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93597. private _blockMaterialDirtyMechanism;
  93598. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  93599. blockMaterialDirtyMechanism: boolean;
  93600. /**
  93601. * Will flag all materials as dirty to trigger new shader compilation
  93602. * @param flag defines the flag used to specify which material part must be marked as dirty
  93603. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  93604. */
  93605. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93606. /** @hidden */
  93607. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  93608. /** @hidden */
  93609. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  93610. }
  93611. }
  93612. declare module BABYLON {
  93613. /**
  93614. * Set of assets to keep when moving a scene into an asset container.
  93615. */
  93616. export class KeepAssets extends AbstractScene {
  93617. }
  93618. /**
  93619. * Container with a set of assets that can be added or removed from a scene.
  93620. */
  93621. export class AssetContainer extends AbstractScene {
  93622. /**
  93623. * The scene the AssetContainer belongs to.
  93624. */
  93625. scene: Scene;
  93626. /**
  93627. * Instantiates an AssetContainer.
  93628. * @param scene The scene the AssetContainer belongs to.
  93629. */
  93630. constructor(scene: Scene);
  93631. /**
  93632. * Adds all the assets from the container to the scene.
  93633. */
  93634. addAllToScene(): void;
  93635. /**
  93636. * Removes all the assets in the container from the scene
  93637. */
  93638. removeAllFromScene(): void;
  93639. /**
  93640. * Disposes all the assets in the container
  93641. */
  93642. dispose(): void;
  93643. private _moveAssets;
  93644. /**
  93645. * Removes all the assets contained in the scene and adds them to the container.
  93646. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  93647. */
  93648. moveAllFromScene(keepAssets?: KeepAssets): void;
  93649. /**
  93650. * 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.
  93651. * @returns the root mesh
  93652. */
  93653. createRootMesh(): Mesh;
  93654. }
  93655. }
  93656. declare module BABYLON {
  93657. /**
  93658. * Defines how the parser contract is defined.
  93659. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  93660. */
  93661. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  93662. /**
  93663. * Defines how the individual parser contract is defined.
  93664. * These parser can parse an individual asset
  93665. */
  93666. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  93667. /**
  93668. * Base class of the scene acting as a container for the different elements composing a scene.
  93669. * This class is dynamically extended by the different components of the scene increasing
  93670. * flexibility and reducing coupling
  93671. */
  93672. export abstract class AbstractScene {
  93673. /**
  93674. * Stores the list of available parsers in the application.
  93675. */
  93676. private static _BabylonFileParsers;
  93677. /**
  93678. * Stores the list of available individual parsers in the application.
  93679. */
  93680. private static _IndividualBabylonFileParsers;
  93681. /**
  93682. * Adds a parser in the list of available ones
  93683. * @param name Defines the name of the parser
  93684. * @param parser Defines the parser to add
  93685. */
  93686. static AddParser(name: string, parser: BabylonFileParser): void;
  93687. /**
  93688. * Gets a general parser from the list of avaialble ones
  93689. * @param name Defines the name of the parser
  93690. * @returns the requested parser or null
  93691. */
  93692. static GetParser(name: string): Nullable<BabylonFileParser>;
  93693. /**
  93694. * Adds n individual parser in the list of available ones
  93695. * @param name Defines the name of the parser
  93696. * @param parser Defines the parser to add
  93697. */
  93698. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  93699. /**
  93700. * Gets an individual parser from the list of avaialble ones
  93701. * @param name Defines the name of the parser
  93702. * @returns the requested parser or null
  93703. */
  93704. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  93705. /**
  93706. * Parser json data and populate both a scene and its associated container object
  93707. * @param jsonData Defines the data to parse
  93708. * @param scene Defines the scene to parse the data for
  93709. * @param container Defines the container attached to the parsing sequence
  93710. * @param rootUrl Defines the root url of the data
  93711. */
  93712. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  93713. /**
  93714. * Gets the list of root nodes (ie. nodes with no parent)
  93715. */
  93716. rootNodes: Node[];
  93717. /** All of the cameras added to this scene
  93718. * @see http://doc.babylonjs.com/babylon101/cameras
  93719. */
  93720. cameras: Camera[];
  93721. /**
  93722. * All of the lights added to this scene
  93723. * @see http://doc.babylonjs.com/babylon101/lights
  93724. */
  93725. lights: Light[];
  93726. /**
  93727. * All of the (abstract) meshes added to this scene
  93728. */
  93729. meshes: AbstractMesh[];
  93730. /**
  93731. * The list of skeletons added to the scene
  93732. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93733. */
  93734. skeletons: Skeleton[];
  93735. /**
  93736. * All of the particle systems added to this scene
  93737. * @see http://doc.babylonjs.com/babylon101/particles
  93738. */
  93739. particleSystems: IParticleSystem[];
  93740. /**
  93741. * Gets a list of Animations associated with the scene
  93742. */
  93743. animations: Animation[];
  93744. /**
  93745. * All of the animation groups added to this scene
  93746. * @see http://doc.babylonjs.com/how_to/group
  93747. */
  93748. animationGroups: AnimationGroup[];
  93749. /**
  93750. * All of the multi-materials added to this scene
  93751. * @see http://doc.babylonjs.com/how_to/multi_materials
  93752. */
  93753. multiMaterials: MultiMaterial[];
  93754. /**
  93755. * All of the materials added to this scene
  93756. * In the context of a Scene, it is not supposed to be modified manually.
  93757. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93758. * Note also that the order of the Material wihin the array is not significant and might change.
  93759. * @see http://doc.babylonjs.com/babylon101/materials
  93760. */
  93761. materials: Material[];
  93762. /**
  93763. * The list of morph target managers added to the scene
  93764. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93765. */
  93766. morphTargetManagers: MorphTargetManager[];
  93767. /**
  93768. * The list of geometries used in the scene.
  93769. */
  93770. geometries: Geometry[];
  93771. /**
  93772. * All of the tranform nodes added to this scene
  93773. * In the context of a Scene, it is not supposed to be modified manually.
  93774. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93775. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93776. * @see http://doc.babylonjs.com/how_to/transformnode
  93777. */
  93778. transformNodes: TransformNode[];
  93779. /**
  93780. * ActionManagers available on the scene.
  93781. */
  93782. actionManagers: AbstractActionManager[];
  93783. /**
  93784. * Textures to keep.
  93785. */
  93786. textures: BaseTexture[];
  93787. /**
  93788. * Environment texture for the scene
  93789. */
  93790. environmentTexture: Nullable<BaseTexture>;
  93791. }
  93792. }
  93793. declare module BABYLON {
  93794. /**
  93795. * Defines a sound that can be played in the application.
  93796. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93798. */
  93799. export class Sound {
  93800. /**
  93801. * The name of the sound in the scene.
  93802. */
  93803. name: string;
  93804. /**
  93805. * Does the sound autoplay once loaded.
  93806. */
  93807. autoplay: boolean;
  93808. /**
  93809. * Does the sound loop after it finishes playing once.
  93810. */
  93811. loop: boolean;
  93812. /**
  93813. * Does the sound use a custom attenuation curve to simulate the falloff
  93814. * happening when the source gets further away from the camera.
  93815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93816. */
  93817. useCustomAttenuation: boolean;
  93818. /**
  93819. * The sound track id this sound belongs to.
  93820. */
  93821. soundTrackId: number;
  93822. /**
  93823. * Is this sound currently played.
  93824. */
  93825. isPlaying: boolean;
  93826. /**
  93827. * Is this sound currently paused.
  93828. */
  93829. isPaused: boolean;
  93830. /**
  93831. * Does this sound enables spatial sound.
  93832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93833. */
  93834. spatialSound: boolean;
  93835. /**
  93836. * Define the reference distance the sound should be heard perfectly.
  93837. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93838. */
  93839. refDistance: number;
  93840. /**
  93841. * Define the roll off factor of spatial sounds.
  93842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93843. */
  93844. rolloffFactor: number;
  93845. /**
  93846. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93848. */
  93849. maxDistance: number;
  93850. /**
  93851. * Define the distance attenuation model the sound will follow.
  93852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93853. */
  93854. distanceModel: string;
  93855. /**
  93856. * @hidden
  93857. * Back Compat
  93858. **/
  93859. onended: () => any;
  93860. /**
  93861. * Observable event when the current playing sound finishes.
  93862. */
  93863. onEndedObservable: Observable<Sound>;
  93864. private _panningModel;
  93865. private _playbackRate;
  93866. private _streaming;
  93867. private _startTime;
  93868. private _startOffset;
  93869. private _position;
  93870. /** @hidden */
  93871. _positionInEmitterSpace: boolean;
  93872. private _localDirection;
  93873. private _volume;
  93874. private _isReadyToPlay;
  93875. private _isDirectional;
  93876. private _readyToPlayCallback;
  93877. private _audioBuffer;
  93878. private _soundSource;
  93879. private _streamingSource;
  93880. private _soundPanner;
  93881. private _soundGain;
  93882. private _inputAudioNode;
  93883. private _outputAudioNode;
  93884. private _coneInnerAngle;
  93885. private _coneOuterAngle;
  93886. private _coneOuterGain;
  93887. private _scene;
  93888. private _connectedTransformNode;
  93889. private _customAttenuationFunction;
  93890. private _registerFunc;
  93891. private _isOutputConnected;
  93892. private _htmlAudioElement;
  93893. private _urlType;
  93894. /** @hidden */
  93895. static _SceneComponentInitialization: (scene: Scene) => void;
  93896. /**
  93897. * Create a sound and attach it to a scene
  93898. * @param name Name of your sound
  93899. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93900. * @param scene defines the scene the sound belongs to
  93901. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93902. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93903. */
  93904. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93905. /**
  93906. * Release the sound and its associated resources
  93907. */
  93908. dispose(): void;
  93909. /**
  93910. * Gets if the sounds is ready to be played or not.
  93911. * @returns true if ready, otherwise false
  93912. */
  93913. isReady(): boolean;
  93914. private _soundLoaded;
  93915. /**
  93916. * Sets the data of the sound from an audiobuffer
  93917. * @param audioBuffer The audioBuffer containing the data
  93918. */
  93919. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93920. /**
  93921. * Updates the current sounds options such as maxdistance, loop...
  93922. * @param options A JSON object containing values named as the object properties
  93923. */
  93924. updateOptions(options: any): void;
  93925. private _createSpatialParameters;
  93926. private _updateSpatialParameters;
  93927. /**
  93928. * Switch the panning model to HRTF:
  93929. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93931. */
  93932. switchPanningModelToHRTF(): void;
  93933. /**
  93934. * Switch the panning model to Equal Power:
  93935. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93937. */
  93938. switchPanningModelToEqualPower(): void;
  93939. private _switchPanningModel;
  93940. /**
  93941. * Connect this sound to a sound track audio node like gain...
  93942. * @param soundTrackAudioNode the sound track audio node to connect to
  93943. */
  93944. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93945. /**
  93946. * Transform this sound into a directional source
  93947. * @param coneInnerAngle Size of the inner cone in degree
  93948. * @param coneOuterAngle Size of the outer cone in degree
  93949. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93950. */
  93951. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93952. /**
  93953. * Gets or sets the inner angle for the directional cone.
  93954. */
  93955. /**
  93956. * Gets or sets the inner angle for the directional cone.
  93957. */
  93958. directionalConeInnerAngle: number;
  93959. /**
  93960. * Gets or sets the outer angle for the directional cone.
  93961. */
  93962. /**
  93963. * Gets or sets the outer angle for the directional cone.
  93964. */
  93965. directionalConeOuterAngle: number;
  93966. /**
  93967. * Sets the position of the emitter if spatial sound is enabled
  93968. * @param newPosition Defines the new posisiton
  93969. */
  93970. setPosition(newPosition: Vector3): void;
  93971. /**
  93972. * Sets the local direction of the emitter if spatial sound is enabled
  93973. * @param newLocalDirection Defines the new local direction
  93974. */
  93975. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93976. private _updateDirection;
  93977. /** @hidden */
  93978. updateDistanceFromListener(): void;
  93979. /**
  93980. * Sets a new custom attenuation function for the sound.
  93981. * @param callback Defines the function used for the attenuation
  93982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93983. */
  93984. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93985. /**
  93986. * Play the sound
  93987. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93988. * @param offset (optional) Start the sound setting it at a specific time
  93989. */
  93990. play(time?: number, offset?: number): void;
  93991. private _onended;
  93992. /**
  93993. * Stop the sound
  93994. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93995. */
  93996. stop(time?: number): void;
  93997. /**
  93998. * Put the sound in pause
  93999. */
  94000. pause(): void;
  94001. /**
  94002. * Sets a dedicated volume for this sounds
  94003. * @param newVolume Define the new volume of the sound
  94004. * @param time Define in how long the sound should be at this value
  94005. */
  94006. setVolume(newVolume: number, time?: number): void;
  94007. /**
  94008. * Set the sound play back rate
  94009. * @param newPlaybackRate Define the playback rate the sound should be played at
  94010. */
  94011. setPlaybackRate(newPlaybackRate: number): void;
  94012. /**
  94013. * Gets the volume of the sound.
  94014. * @returns the volume of the sound
  94015. */
  94016. getVolume(): number;
  94017. /**
  94018. * Attach the sound to a dedicated mesh
  94019. * @param transformNode The transform node to connect the sound with
  94020. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94021. */
  94022. attachToMesh(transformNode: TransformNode): void;
  94023. /**
  94024. * Detach the sound from the previously attached mesh
  94025. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94026. */
  94027. detachFromMesh(): void;
  94028. private _onRegisterAfterWorldMatrixUpdate;
  94029. /**
  94030. * Clone the current sound in the scene.
  94031. * @returns the new sound clone
  94032. */
  94033. clone(): Nullable<Sound>;
  94034. /**
  94035. * Gets the current underlying audio buffer containing the data
  94036. * @returns the audio buffer
  94037. */
  94038. getAudioBuffer(): Nullable<AudioBuffer>;
  94039. /**
  94040. * Serializes the Sound in a JSON representation
  94041. * @returns the JSON representation of the sound
  94042. */
  94043. serialize(): any;
  94044. /**
  94045. * Parse a JSON representation of a sound to innstantiate in a given scene
  94046. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  94047. * @param scene Define the scene the new parsed sound should be created in
  94048. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  94049. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  94050. * @returns the newly parsed sound
  94051. */
  94052. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  94053. }
  94054. }
  94055. declare module BABYLON {
  94056. /**
  94057. * This defines an action helpful to play a defined sound on a triggered action.
  94058. */
  94059. export class PlaySoundAction extends Action {
  94060. private _sound;
  94061. /**
  94062. * Instantiate the action
  94063. * @param triggerOptions defines the trigger options
  94064. * @param sound defines the sound to play
  94065. * @param condition defines the trigger related conditions
  94066. */
  94067. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94068. /** @hidden */
  94069. _prepare(): void;
  94070. /**
  94071. * Execute the action and play the sound.
  94072. */
  94073. execute(): void;
  94074. /**
  94075. * Serializes the actions and its related information.
  94076. * @param parent defines the object to serialize in
  94077. * @returns the serialized object
  94078. */
  94079. serialize(parent: any): any;
  94080. }
  94081. /**
  94082. * This defines an action helpful to stop a defined sound on a triggered action.
  94083. */
  94084. export class StopSoundAction extends Action {
  94085. private _sound;
  94086. /**
  94087. * Instantiate the action
  94088. * @param triggerOptions defines the trigger options
  94089. * @param sound defines the sound to stop
  94090. * @param condition defines the trigger related conditions
  94091. */
  94092. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94093. /** @hidden */
  94094. _prepare(): void;
  94095. /**
  94096. * Execute the action and stop the sound.
  94097. */
  94098. execute(): void;
  94099. /**
  94100. * Serializes the actions and its related information.
  94101. * @param parent defines the object to serialize in
  94102. * @returns the serialized object
  94103. */
  94104. serialize(parent: any): any;
  94105. }
  94106. }
  94107. declare module BABYLON {
  94108. /**
  94109. * This defines an action responsible to change the value of a property
  94110. * by interpolating between its current value and the newly set one once triggered.
  94111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94112. */
  94113. export class InterpolateValueAction extends Action {
  94114. /**
  94115. * Defines the path of the property where the value should be interpolated
  94116. */
  94117. propertyPath: string;
  94118. /**
  94119. * Defines the target value at the end of the interpolation.
  94120. */
  94121. value: any;
  94122. /**
  94123. * Defines the time it will take for the property to interpolate to the value.
  94124. */
  94125. duration: number;
  94126. /**
  94127. * Defines if the other scene animations should be stopped when the action has been triggered
  94128. */
  94129. stopOtherAnimations?: boolean;
  94130. /**
  94131. * Defines a callback raised once the interpolation animation has been done.
  94132. */
  94133. onInterpolationDone?: () => void;
  94134. /**
  94135. * Observable triggered once the interpolation animation has been done.
  94136. */
  94137. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  94138. private _target;
  94139. private _effectiveTarget;
  94140. private _property;
  94141. /**
  94142. * Instantiate the action
  94143. * @param triggerOptions defines the trigger options
  94144. * @param target defines the object containing the value to interpolate
  94145. * @param propertyPath defines the path to the property in the target object
  94146. * @param value defines the target value at the end of the interpolation
  94147. * @param duration deines the time it will take for the property to interpolate to the value.
  94148. * @param condition defines the trigger related conditions
  94149. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  94150. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  94151. */
  94152. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  94153. /** @hidden */
  94154. _prepare(): void;
  94155. /**
  94156. * Execute the action starts the value interpolation.
  94157. */
  94158. execute(): void;
  94159. /**
  94160. * Serializes the actions and its related information.
  94161. * @param parent defines the object to serialize in
  94162. * @returns the serialized object
  94163. */
  94164. serialize(parent: any): any;
  94165. }
  94166. }
  94167. declare module BABYLON {
  94168. /**
  94169. * Options allowed during the creation of a sound track.
  94170. */
  94171. export interface ISoundTrackOptions {
  94172. /**
  94173. * The volume the sound track should take during creation
  94174. */
  94175. volume?: number;
  94176. /**
  94177. * Define if the sound track is the main sound track of the scene
  94178. */
  94179. mainTrack?: boolean;
  94180. }
  94181. /**
  94182. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  94183. * It will be also used in a future release to apply effects on a specific track.
  94184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94185. */
  94186. export class SoundTrack {
  94187. /**
  94188. * The unique identifier of the sound track in the scene.
  94189. */
  94190. id: number;
  94191. /**
  94192. * The list of sounds included in the sound track.
  94193. */
  94194. soundCollection: Array<Sound>;
  94195. private _outputAudioNode;
  94196. private _scene;
  94197. private _isMainTrack;
  94198. private _connectedAnalyser;
  94199. private _options;
  94200. private _isInitialized;
  94201. /**
  94202. * Creates a new sound track.
  94203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94204. * @param scene Define the scene the sound track belongs to
  94205. * @param options
  94206. */
  94207. constructor(scene: Scene, options?: ISoundTrackOptions);
  94208. private _initializeSoundTrackAudioGraph;
  94209. /**
  94210. * Release the sound track and its associated resources
  94211. */
  94212. dispose(): void;
  94213. /**
  94214. * Adds a sound to this sound track
  94215. * @param sound define the cound to add
  94216. * @ignoreNaming
  94217. */
  94218. AddSound(sound: Sound): void;
  94219. /**
  94220. * Removes a sound to this sound track
  94221. * @param sound define the cound to remove
  94222. * @ignoreNaming
  94223. */
  94224. RemoveSound(sound: Sound): void;
  94225. /**
  94226. * Set a global volume for the full sound track.
  94227. * @param newVolume Define the new volume of the sound track
  94228. */
  94229. setVolume(newVolume: number): void;
  94230. /**
  94231. * Switch the panning model to HRTF:
  94232. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  94233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94234. */
  94235. switchPanningModelToHRTF(): void;
  94236. /**
  94237. * Switch the panning model to Equal Power:
  94238. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  94239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94240. */
  94241. switchPanningModelToEqualPower(): void;
  94242. /**
  94243. * Connect the sound track to an audio analyser allowing some amazing
  94244. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94245. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94246. * @param analyser The analyser to connect to the engine
  94247. */
  94248. connectToAnalyser(analyser: Analyser): void;
  94249. }
  94250. }
  94251. declare module BABYLON {
  94252. interface AbstractScene {
  94253. /**
  94254. * The list of sounds used in the scene.
  94255. */
  94256. sounds: Nullable<Array<Sound>>;
  94257. }
  94258. interface Scene {
  94259. /**
  94260. * @hidden
  94261. * Backing field
  94262. */
  94263. _mainSoundTrack: SoundTrack;
  94264. /**
  94265. * The main sound track played by the scene.
  94266. * It cotains your primary collection of sounds.
  94267. */
  94268. mainSoundTrack: SoundTrack;
  94269. /**
  94270. * The list of sound tracks added to the scene
  94271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94272. */
  94273. soundTracks: Nullable<Array<SoundTrack>>;
  94274. /**
  94275. * Gets a sound using a given name
  94276. * @param name defines the name to search for
  94277. * @return the found sound or null if not found at all.
  94278. */
  94279. getSoundByName(name: string): Nullable<Sound>;
  94280. /**
  94281. * Gets or sets if audio support is enabled
  94282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94283. */
  94284. audioEnabled: boolean;
  94285. /**
  94286. * Gets or sets if audio will be output to headphones
  94287. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94288. */
  94289. headphone: boolean;
  94290. }
  94291. /**
  94292. * Defines the sound scene component responsible to manage any sounds
  94293. * in a given scene.
  94294. */
  94295. export class AudioSceneComponent implements ISceneSerializableComponent {
  94296. /**
  94297. * The component name helpfull to identify the component in the list of scene components.
  94298. */
  94299. readonly name: string;
  94300. /**
  94301. * The scene the component belongs to.
  94302. */
  94303. scene: Scene;
  94304. private _audioEnabled;
  94305. /**
  94306. * Gets whether audio is enabled or not.
  94307. * Please use related enable/disable method to switch state.
  94308. */
  94309. readonly audioEnabled: boolean;
  94310. private _headphone;
  94311. /**
  94312. * Gets whether audio is outputing to headphone or not.
  94313. * Please use the according Switch methods to change output.
  94314. */
  94315. readonly headphone: boolean;
  94316. /**
  94317. * Creates a new instance of the component for the given scene
  94318. * @param scene Defines the scene to register the component in
  94319. */
  94320. constructor(scene: Scene);
  94321. /**
  94322. * Registers the component in a given scene
  94323. */
  94324. register(): void;
  94325. /**
  94326. * Rebuilds the elements related to this component in case of
  94327. * context lost for instance.
  94328. */
  94329. rebuild(): void;
  94330. /**
  94331. * Serializes the component data to the specified json object
  94332. * @param serializationObject The object to serialize to
  94333. */
  94334. serialize(serializationObject: any): void;
  94335. /**
  94336. * Adds all the element from the container to the scene
  94337. * @param container the container holding the elements
  94338. */
  94339. addFromContainer(container: AbstractScene): void;
  94340. /**
  94341. * Removes all the elements in the container from the scene
  94342. * @param container contains the elements to remove
  94343. * @param dispose if the removed element should be disposed (default: false)
  94344. */
  94345. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  94346. /**
  94347. * Disposes the component and the associated ressources.
  94348. */
  94349. dispose(): void;
  94350. /**
  94351. * Disables audio in the associated scene.
  94352. */
  94353. disableAudio(): void;
  94354. /**
  94355. * Enables audio in the associated scene.
  94356. */
  94357. enableAudio(): void;
  94358. /**
  94359. * Switch audio to headphone output.
  94360. */
  94361. switchAudioModeForHeadphones(): void;
  94362. /**
  94363. * Switch audio to normal speakers.
  94364. */
  94365. switchAudioModeForNormalSpeakers(): void;
  94366. private _afterRender;
  94367. }
  94368. }
  94369. declare module BABYLON {
  94370. /**
  94371. * Wraps one or more Sound objects and selects one with random weight for playback.
  94372. */
  94373. export class WeightedSound {
  94374. /** When true a Sound will be selected and played when the current playing Sound completes. */
  94375. loop: boolean;
  94376. private _coneInnerAngle;
  94377. private _coneOuterAngle;
  94378. private _volume;
  94379. /** A Sound is currently playing. */
  94380. isPlaying: boolean;
  94381. /** A Sound is currently paused. */
  94382. isPaused: boolean;
  94383. private _sounds;
  94384. private _weights;
  94385. private _currentIndex?;
  94386. /**
  94387. * Creates a new WeightedSound from the list of sounds given.
  94388. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  94389. * @param sounds Array of Sounds that will be selected from.
  94390. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  94391. */
  94392. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  94393. /**
  94394. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  94395. */
  94396. /**
  94397. * The size of cone in degress for a directional sound in which there will be no attenuation.
  94398. */
  94399. directionalConeInnerAngle: number;
  94400. /**
  94401. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94402. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94403. */
  94404. /**
  94405. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94406. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94407. */
  94408. directionalConeOuterAngle: number;
  94409. /**
  94410. * Playback volume.
  94411. */
  94412. /**
  94413. * Playback volume.
  94414. */
  94415. volume: number;
  94416. private _onended;
  94417. /**
  94418. * Suspend playback
  94419. */
  94420. pause(): void;
  94421. /**
  94422. * Stop playback
  94423. */
  94424. stop(): void;
  94425. /**
  94426. * Start playback.
  94427. * @param startOffset Position the clip head at a specific time in seconds.
  94428. */
  94429. play(startOffset?: number): void;
  94430. }
  94431. }
  94432. declare module BABYLON {
  94433. /**
  94434. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  94435. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94436. */
  94437. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  94438. /**
  94439. * Gets the name of the behavior.
  94440. */
  94441. readonly name: string;
  94442. /**
  94443. * The easing function used by animations
  94444. */
  94445. static EasingFunction: BackEase;
  94446. /**
  94447. * The easing mode used by animations
  94448. */
  94449. static EasingMode: number;
  94450. /**
  94451. * The duration of the animation, in milliseconds
  94452. */
  94453. transitionDuration: number;
  94454. /**
  94455. * Length of the distance animated by the transition when lower radius is reached
  94456. */
  94457. lowerRadiusTransitionRange: number;
  94458. /**
  94459. * Length of the distance animated by the transition when upper radius is reached
  94460. */
  94461. upperRadiusTransitionRange: number;
  94462. private _autoTransitionRange;
  94463. /**
  94464. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94465. */
  94466. /**
  94467. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94468. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  94469. */
  94470. autoTransitionRange: boolean;
  94471. private _attachedCamera;
  94472. private _onAfterCheckInputsObserver;
  94473. private _onMeshTargetChangedObserver;
  94474. /**
  94475. * Initializes the behavior.
  94476. */
  94477. init(): void;
  94478. /**
  94479. * Attaches the behavior to its arc rotate camera.
  94480. * @param camera Defines the camera to attach the behavior to
  94481. */
  94482. attach(camera: ArcRotateCamera): void;
  94483. /**
  94484. * Detaches the behavior from its current arc rotate camera.
  94485. */
  94486. detach(): void;
  94487. private _radiusIsAnimating;
  94488. private _radiusBounceTransition;
  94489. private _animatables;
  94490. private _cachedWheelPrecision;
  94491. /**
  94492. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  94493. * @param radiusLimit The limit to check against.
  94494. * @return Bool to indicate if at limit.
  94495. */
  94496. private _isRadiusAtLimit;
  94497. /**
  94498. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  94499. * @param radiusDelta The delta by which to animate to. Can be negative.
  94500. */
  94501. private _applyBoundRadiusAnimation;
  94502. /**
  94503. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  94504. */
  94505. protected _clearAnimationLocks(): void;
  94506. /**
  94507. * Stops and removes all animations that have been applied to the camera
  94508. */
  94509. stopAllAnimations(): void;
  94510. }
  94511. }
  94512. declare module BABYLON {
  94513. /**
  94514. * 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.
  94515. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94516. */
  94517. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  94518. /**
  94519. * Gets the name of the behavior.
  94520. */
  94521. readonly name: string;
  94522. private _mode;
  94523. private _radiusScale;
  94524. private _positionScale;
  94525. private _defaultElevation;
  94526. private _elevationReturnTime;
  94527. private _elevationReturnWaitTime;
  94528. private _zoomStopsAnimation;
  94529. private _framingTime;
  94530. /**
  94531. * The easing function used by animations
  94532. */
  94533. static EasingFunction: ExponentialEase;
  94534. /**
  94535. * The easing mode used by animations
  94536. */
  94537. static EasingMode: number;
  94538. /**
  94539. * Sets the current mode used by the behavior
  94540. */
  94541. /**
  94542. * Gets current mode used by the behavior.
  94543. */
  94544. mode: number;
  94545. /**
  94546. * Sets the scale applied to the radius (1 by default)
  94547. */
  94548. /**
  94549. * Gets the scale applied to the radius
  94550. */
  94551. radiusScale: number;
  94552. /**
  94553. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94554. */
  94555. /**
  94556. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94557. */
  94558. positionScale: number;
  94559. /**
  94560. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94561. * behaviour is triggered, in radians.
  94562. */
  94563. /**
  94564. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94565. * behaviour is triggered, in radians.
  94566. */
  94567. defaultElevation: number;
  94568. /**
  94569. * Sets the time (in milliseconds) taken to return to the default beta position.
  94570. * Negative value indicates camera should not return to default.
  94571. */
  94572. /**
  94573. * Gets the time (in milliseconds) taken to return to the default beta position.
  94574. * Negative value indicates camera should not return to default.
  94575. */
  94576. elevationReturnTime: number;
  94577. /**
  94578. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94579. */
  94580. /**
  94581. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94582. */
  94583. elevationReturnWaitTime: number;
  94584. /**
  94585. * Sets the flag that indicates if user zooming should stop animation.
  94586. */
  94587. /**
  94588. * Gets the flag that indicates if user zooming should stop animation.
  94589. */
  94590. zoomStopsAnimation: boolean;
  94591. /**
  94592. * Sets the transition time when framing the mesh, in milliseconds
  94593. */
  94594. /**
  94595. * Gets the transition time when framing the mesh, in milliseconds
  94596. */
  94597. framingTime: number;
  94598. /**
  94599. * Define if the behavior should automatically change the configured
  94600. * camera limits and sensibilities.
  94601. */
  94602. autoCorrectCameraLimitsAndSensibility: boolean;
  94603. private _onPrePointerObservableObserver;
  94604. private _onAfterCheckInputsObserver;
  94605. private _onMeshTargetChangedObserver;
  94606. private _attachedCamera;
  94607. private _isPointerDown;
  94608. private _lastInteractionTime;
  94609. /**
  94610. * Initializes the behavior.
  94611. */
  94612. init(): void;
  94613. /**
  94614. * Attaches the behavior to its arc rotate camera.
  94615. * @param camera Defines the camera to attach the behavior to
  94616. */
  94617. attach(camera: ArcRotateCamera): void;
  94618. /**
  94619. * Detaches the behavior from its current arc rotate camera.
  94620. */
  94621. detach(): void;
  94622. private _animatables;
  94623. private _betaIsAnimating;
  94624. private _betaTransition;
  94625. private _radiusTransition;
  94626. private _vectorTransition;
  94627. /**
  94628. * Targets the given mesh and updates zoom level accordingly.
  94629. * @param mesh The mesh to target.
  94630. * @param radius Optional. If a cached radius position already exists, overrides default.
  94631. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94632. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94633. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94634. */
  94635. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94636. /**
  94637. * Targets the given mesh with its children and updates zoom level accordingly.
  94638. * @param mesh The mesh to target.
  94639. * @param radius Optional. If a cached radius position already exists, overrides default.
  94640. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94641. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94642. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94643. */
  94644. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94645. /**
  94646. * Targets the given meshes with their children and updates zoom level accordingly.
  94647. * @param meshes The mesh to target.
  94648. * @param radius Optional. If a cached radius position already exists, overrides default.
  94649. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94650. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94651. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94652. */
  94653. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94654. /**
  94655. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  94656. * @param minimumWorld Determines the smaller position of the bounding box extend
  94657. * @param maximumWorld Determines the bigger position of the bounding box extend
  94658. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94659. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94660. */
  94661. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94662. /**
  94663. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  94664. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  94665. * frustum width.
  94666. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  94667. * to fully enclose the mesh in the viewing frustum.
  94668. */
  94669. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  94670. /**
  94671. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  94672. * is automatically returned to its default position (expected to be above ground plane).
  94673. */
  94674. private _maintainCameraAboveGround;
  94675. /**
  94676. * Returns the frustum slope based on the canvas ratio and camera FOV
  94677. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  94678. */
  94679. private _getFrustumSlope;
  94680. /**
  94681. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  94682. */
  94683. private _clearAnimationLocks;
  94684. /**
  94685. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94686. */
  94687. private _applyUserInteraction;
  94688. /**
  94689. * Stops and removes all animations that have been applied to the camera
  94690. */
  94691. stopAllAnimations(): void;
  94692. /**
  94693. * Gets a value indicating if the user is moving the camera
  94694. */
  94695. readonly isUserIsMoving: boolean;
  94696. /**
  94697. * The camera can move all the way towards the mesh.
  94698. */
  94699. static IgnoreBoundsSizeMode: number;
  94700. /**
  94701. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  94702. */
  94703. static FitFrustumSidesMode: number;
  94704. }
  94705. }
  94706. declare module BABYLON {
  94707. /**
  94708. * Base class for Camera Pointer Inputs.
  94709. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  94710. * for example usage.
  94711. */
  94712. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  94713. /**
  94714. * Defines the camera the input is attached to.
  94715. */
  94716. abstract camera: Camera;
  94717. /**
  94718. * Whether keyboard modifier keys are pressed at time of last mouse event.
  94719. */
  94720. protected _altKey: boolean;
  94721. protected _ctrlKey: boolean;
  94722. protected _metaKey: boolean;
  94723. protected _shiftKey: boolean;
  94724. /**
  94725. * Which mouse buttons were pressed at time of last mouse event.
  94726. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94727. */
  94728. protected _buttonsPressed: number;
  94729. /**
  94730. * Defines the buttons associated with the input to handle camera move.
  94731. */
  94732. buttons: number[];
  94733. /**
  94734. * Attach the input controls to a specific dom element to get the input from.
  94735. * @param element Defines the element the controls should be listened from
  94736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94737. */
  94738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94739. /**
  94740. * Detach the current controls from the specified dom element.
  94741. * @param element Defines the element to stop listening the inputs from
  94742. */
  94743. detachControl(element: Nullable<HTMLElement>): void;
  94744. /**
  94745. * Gets the class name of the current input.
  94746. * @returns the class name
  94747. */
  94748. getClassName(): string;
  94749. /**
  94750. * Get the friendly name associated with the input class.
  94751. * @returns the input friendly name
  94752. */
  94753. getSimpleName(): string;
  94754. /**
  94755. * Called on pointer POINTERDOUBLETAP event.
  94756. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94757. */
  94758. protected onDoubleTap(type: string): void;
  94759. /**
  94760. * Called on pointer POINTERMOVE event if only a single touch is active.
  94761. * Override this method to provide functionality.
  94762. */
  94763. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94764. /**
  94765. * Called on pointer POINTERMOVE event if multiple touches are active.
  94766. * Override this method to provide functionality.
  94767. */
  94768. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94769. /**
  94770. * Called on JS contextmenu event.
  94771. * Override this method to provide functionality.
  94772. */
  94773. protected onContextMenu(evt: PointerEvent): void;
  94774. /**
  94775. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94776. * press.
  94777. * Override this method to provide functionality.
  94778. */
  94779. protected onButtonDown(evt: PointerEvent): void;
  94780. /**
  94781. * Called each time a new POINTERUP event occurs. Ie, for each button
  94782. * release.
  94783. * Override this method to provide functionality.
  94784. */
  94785. protected onButtonUp(evt: PointerEvent): void;
  94786. /**
  94787. * Called when window becomes inactive.
  94788. * Override this method to provide functionality.
  94789. */
  94790. protected onLostFocus(): void;
  94791. private _pointerInput;
  94792. private _observer;
  94793. private _onLostFocus;
  94794. private pointA;
  94795. private pointB;
  94796. }
  94797. }
  94798. declare module BABYLON {
  94799. /**
  94800. * Manage the pointers inputs to control an arc rotate camera.
  94801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94802. */
  94803. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94804. /**
  94805. * Defines the camera the input is attached to.
  94806. */
  94807. camera: ArcRotateCamera;
  94808. /**
  94809. * Gets the class name of the current input.
  94810. * @returns the class name
  94811. */
  94812. getClassName(): string;
  94813. /**
  94814. * Defines the buttons associated with the input to handle camera move.
  94815. */
  94816. buttons: number[];
  94817. /**
  94818. * Defines the pointer angular sensibility along the X axis or how fast is
  94819. * the camera rotating.
  94820. */
  94821. angularSensibilityX: number;
  94822. /**
  94823. * Defines the pointer angular sensibility along the Y axis or how fast is
  94824. * the camera rotating.
  94825. */
  94826. angularSensibilityY: number;
  94827. /**
  94828. * Defines the pointer pinch precision or how fast is the camera zooming.
  94829. */
  94830. pinchPrecision: number;
  94831. /**
  94832. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94833. * from 0.
  94834. * It defines the percentage of current camera.radius to use as delta when
  94835. * pinch zoom is used.
  94836. */
  94837. pinchDeltaPercentage: number;
  94838. /**
  94839. * Defines the pointer panning sensibility or how fast is the camera moving.
  94840. */
  94841. panningSensibility: number;
  94842. /**
  94843. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94844. */
  94845. multiTouchPanning: boolean;
  94846. /**
  94847. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94848. * zoom (pinch) through multitouch.
  94849. */
  94850. multiTouchPanAndZoom: boolean;
  94851. /**
  94852. * Revers pinch action direction.
  94853. */
  94854. pinchInwards: boolean;
  94855. private _isPanClick;
  94856. private _twoFingerActivityCount;
  94857. private _isPinching;
  94858. /**
  94859. * Called on pointer POINTERMOVE event if only a single touch is active.
  94860. */
  94861. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94862. /**
  94863. * Called on pointer POINTERDOUBLETAP event.
  94864. */
  94865. protected onDoubleTap(type: string): void;
  94866. /**
  94867. * Called on pointer POINTERMOVE event if multiple touches are active.
  94868. */
  94869. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94870. /**
  94871. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94872. * press.
  94873. */
  94874. protected onButtonDown(evt: PointerEvent): void;
  94875. /**
  94876. * Called each time a new POINTERUP event occurs. Ie, for each button
  94877. * release.
  94878. */
  94879. protected onButtonUp(evt: PointerEvent): void;
  94880. /**
  94881. * Called when window becomes inactive.
  94882. */
  94883. protected onLostFocus(): void;
  94884. }
  94885. }
  94886. declare module BABYLON {
  94887. /**
  94888. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94890. */
  94891. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94892. /**
  94893. * Defines the camera the input is attached to.
  94894. */
  94895. camera: ArcRotateCamera;
  94896. /**
  94897. * Defines the list of key codes associated with the up action (increase alpha)
  94898. */
  94899. keysUp: number[];
  94900. /**
  94901. * Defines the list of key codes associated with the down action (decrease alpha)
  94902. */
  94903. keysDown: number[];
  94904. /**
  94905. * Defines the list of key codes associated with the left action (increase beta)
  94906. */
  94907. keysLeft: number[];
  94908. /**
  94909. * Defines the list of key codes associated with the right action (decrease beta)
  94910. */
  94911. keysRight: number[];
  94912. /**
  94913. * Defines the list of key codes associated with the reset action.
  94914. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94915. */
  94916. keysReset: number[];
  94917. /**
  94918. * Defines the panning sensibility of the inputs.
  94919. * (How fast is the camera paning)
  94920. */
  94921. panningSensibility: number;
  94922. /**
  94923. * Defines the zooming sensibility of the inputs.
  94924. * (How fast is the camera zooming)
  94925. */
  94926. zoomingSensibility: number;
  94927. /**
  94928. * Defines wether maintaining the alt key down switch the movement mode from
  94929. * orientation to zoom.
  94930. */
  94931. useAltToZoom: boolean;
  94932. /**
  94933. * Rotation speed of the camera
  94934. */
  94935. angularSpeed: number;
  94936. private _keys;
  94937. private _ctrlPressed;
  94938. private _altPressed;
  94939. private _onCanvasBlurObserver;
  94940. private _onKeyboardObserver;
  94941. private _engine;
  94942. private _scene;
  94943. /**
  94944. * Attach the input controls to a specific dom element to get the input from.
  94945. * @param element Defines the element the controls should be listened from
  94946. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94947. */
  94948. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94949. /**
  94950. * Detach the current controls from the specified dom element.
  94951. * @param element Defines the element to stop listening the inputs from
  94952. */
  94953. detachControl(element: Nullable<HTMLElement>): void;
  94954. /**
  94955. * Update the current camera state depending on the inputs that have been used this frame.
  94956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94957. */
  94958. checkInputs(): void;
  94959. /**
  94960. * Gets the class name of the current intput.
  94961. * @returns the class name
  94962. */
  94963. getClassName(): string;
  94964. /**
  94965. * Get the friendly name associated with the input class.
  94966. * @returns the input friendly name
  94967. */
  94968. getSimpleName(): string;
  94969. }
  94970. }
  94971. declare module BABYLON {
  94972. /**
  94973. * Manage the mouse wheel inputs to control an arc rotate camera.
  94974. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94975. */
  94976. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94977. /**
  94978. * Defines the camera the input is attached to.
  94979. */
  94980. camera: ArcRotateCamera;
  94981. /**
  94982. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94983. */
  94984. wheelPrecision: number;
  94985. /**
  94986. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94987. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94988. */
  94989. wheelDeltaPercentage: number;
  94990. private _wheel;
  94991. private _observer;
  94992. private computeDeltaFromMouseWheelLegacyEvent;
  94993. /**
  94994. * Attach the input controls to a specific dom element to get the input from.
  94995. * @param element Defines the element the controls should be listened from
  94996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94997. */
  94998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94999. /**
  95000. * Detach the current controls from the specified dom element.
  95001. * @param element Defines the element to stop listening the inputs from
  95002. */
  95003. detachControl(element: Nullable<HTMLElement>): void;
  95004. /**
  95005. * Gets the class name of the current intput.
  95006. * @returns the class name
  95007. */
  95008. getClassName(): string;
  95009. /**
  95010. * Get the friendly name associated with the input class.
  95011. * @returns the input friendly name
  95012. */
  95013. getSimpleName(): string;
  95014. }
  95015. }
  95016. declare module BABYLON {
  95017. /**
  95018. * Default Inputs manager for the ArcRotateCamera.
  95019. * It groups all the default supported inputs for ease of use.
  95020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95021. */
  95022. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  95023. /**
  95024. * Instantiates a new ArcRotateCameraInputsManager.
  95025. * @param camera Defines the camera the inputs belong to
  95026. */
  95027. constructor(camera: ArcRotateCamera);
  95028. /**
  95029. * Add mouse wheel input support to the input manager.
  95030. * @returns the current input manager
  95031. */
  95032. addMouseWheel(): ArcRotateCameraInputsManager;
  95033. /**
  95034. * Add pointers input support to the input manager.
  95035. * @returns the current input manager
  95036. */
  95037. addPointers(): ArcRotateCameraInputsManager;
  95038. /**
  95039. * Add keyboard input support to the input manager.
  95040. * @returns the current input manager
  95041. */
  95042. addKeyboard(): ArcRotateCameraInputsManager;
  95043. }
  95044. }
  95045. declare module BABYLON {
  95046. /**
  95047. * This represents an orbital type of camera.
  95048. *
  95049. * 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.
  95050. * 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.
  95051. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  95052. */
  95053. export class ArcRotateCamera extends TargetCamera {
  95054. /**
  95055. * Defines the rotation angle of the camera along the longitudinal axis.
  95056. */
  95057. alpha: number;
  95058. /**
  95059. * Defines the rotation angle of the camera along the latitudinal axis.
  95060. */
  95061. beta: number;
  95062. /**
  95063. * Defines the radius of the camera from it s target point.
  95064. */
  95065. radius: number;
  95066. protected _target: Vector3;
  95067. protected _targetHost: Nullable<AbstractMesh>;
  95068. /**
  95069. * Defines the target point of the camera.
  95070. * The camera looks towards it form the radius distance.
  95071. */
  95072. target: Vector3;
  95073. /**
  95074. * Define the current local position of the camera in the scene
  95075. */
  95076. position: Vector3;
  95077. protected _upVector: Vector3;
  95078. protected _upToYMatrix: Matrix;
  95079. protected _YToUpMatrix: Matrix;
  95080. /**
  95081. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  95082. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  95083. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  95084. */
  95085. upVector: Vector3;
  95086. /**
  95087. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  95088. */
  95089. setMatUp(): void;
  95090. /**
  95091. * Current inertia value on the longitudinal axis.
  95092. * The bigger this number the longer it will take for the camera to stop.
  95093. */
  95094. inertialAlphaOffset: number;
  95095. /**
  95096. * Current inertia value on the latitudinal axis.
  95097. * The bigger this number the longer it will take for the camera to stop.
  95098. */
  95099. inertialBetaOffset: number;
  95100. /**
  95101. * Current inertia value on the radius axis.
  95102. * The bigger this number the longer it will take for the camera to stop.
  95103. */
  95104. inertialRadiusOffset: number;
  95105. /**
  95106. * Minimum allowed angle on the longitudinal axis.
  95107. * This can help limiting how the Camera is able to move in the scene.
  95108. */
  95109. lowerAlphaLimit: Nullable<number>;
  95110. /**
  95111. * Maximum allowed angle on the longitudinal axis.
  95112. * This can help limiting how the Camera is able to move in the scene.
  95113. */
  95114. upperAlphaLimit: Nullable<number>;
  95115. /**
  95116. * Minimum allowed angle on the latitudinal axis.
  95117. * This can help limiting how the Camera is able to move in the scene.
  95118. */
  95119. lowerBetaLimit: number;
  95120. /**
  95121. * Maximum allowed angle on the latitudinal axis.
  95122. * This can help limiting how the Camera is able to move in the scene.
  95123. */
  95124. upperBetaLimit: number;
  95125. /**
  95126. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  95127. * This can help limiting how the Camera is able to move in the scene.
  95128. */
  95129. lowerRadiusLimit: Nullable<number>;
  95130. /**
  95131. * Maximum allowed distance of the camera to the target (The camera can not get further).
  95132. * This can help limiting how the Camera is able to move in the scene.
  95133. */
  95134. upperRadiusLimit: Nullable<number>;
  95135. /**
  95136. * Defines the current inertia value used during panning of the camera along the X axis.
  95137. */
  95138. inertialPanningX: number;
  95139. /**
  95140. * Defines the current inertia value used during panning of the camera along the Y axis.
  95141. */
  95142. inertialPanningY: number;
  95143. /**
  95144. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  95145. * Basically if your fingers moves away from more than this distance you will be considered
  95146. * in pinch mode.
  95147. */
  95148. pinchToPanMaxDistance: number;
  95149. /**
  95150. * Defines the maximum distance the camera can pan.
  95151. * This could help keeping the cammera always in your scene.
  95152. */
  95153. panningDistanceLimit: Nullable<number>;
  95154. /**
  95155. * Defines the target of the camera before paning.
  95156. */
  95157. panningOriginTarget: Vector3;
  95158. /**
  95159. * Defines the value of the inertia used during panning.
  95160. * 0 would mean stop inertia and one would mean no decelleration at all.
  95161. */
  95162. panningInertia: number;
  95163. /**
  95164. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  95165. */
  95166. angularSensibilityX: number;
  95167. /**
  95168. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  95169. */
  95170. angularSensibilityY: number;
  95171. /**
  95172. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  95173. */
  95174. pinchPrecision: number;
  95175. /**
  95176. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  95177. * It will be used instead of pinchDeltaPrecision if different from 0.
  95178. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95179. */
  95180. pinchDeltaPercentage: number;
  95181. /**
  95182. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  95183. */
  95184. panningSensibility: number;
  95185. /**
  95186. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  95187. */
  95188. keysUp: number[];
  95189. /**
  95190. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  95191. */
  95192. keysDown: number[];
  95193. /**
  95194. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  95195. */
  95196. keysLeft: number[];
  95197. /**
  95198. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  95199. */
  95200. keysRight: number[];
  95201. /**
  95202. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  95203. */
  95204. wheelPrecision: number;
  95205. /**
  95206. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  95207. * It will be used instead of pinchDeltaPrecision if different from 0.
  95208. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95209. */
  95210. wheelDeltaPercentage: number;
  95211. /**
  95212. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  95213. */
  95214. zoomOnFactor: number;
  95215. /**
  95216. * Defines a screen offset for the camera position.
  95217. */
  95218. targetScreenOffset: Vector2;
  95219. /**
  95220. * Allows the camera to be completely reversed.
  95221. * If false the camera can not arrive upside down.
  95222. */
  95223. allowUpsideDown: boolean;
  95224. /**
  95225. * Define if double tap/click is used to restore the previously saved state of the camera.
  95226. */
  95227. useInputToRestoreState: boolean;
  95228. /** @hidden */
  95229. _viewMatrix: Matrix;
  95230. /** @hidden */
  95231. _useCtrlForPanning: boolean;
  95232. /** @hidden */
  95233. _panningMouseButton: number;
  95234. /**
  95235. * Defines the input associated to the camera.
  95236. */
  95237. inputs: ArcRotateCameraInputsManager;
  95238. /** @hidden */
  95239. _reset: () => void;
  95240. /**
  95241. * Defines the allowed panning axis.
  95242. */
  95243. panningAxis: Vector3;
  95244. protected _localDirection: Vector3;
  95245. protected _transformedDirection: Vector3;
  95246. private _bouncingBehavior;
  95247. /**
  95248. * Gets the bouncing behavior of the camera if it has been enabled.
  95249. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95250. */
  95251. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  95252. /**
  95253. * Defines if the bouncing behavior of the camera is enabled on the camera.
  95254. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95255. */
  95256. useBouncingBehavior: boolean;
  95257. private _framingBehavior;
  95258. /**
  95259. * Gets the framing behavior of the camera if it has been enabled.
  95260. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95261. */
  95262. readonly framingBehavior: Nullable<FramingBehavior>;
  95263. /**
  95264. * Defines if the framing behavior of the camera is enabled on the camera.
  95265. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95266. */
  95267. useFramingBehavior: boolean;
  95268. private _autoRotationBehavior;
  95269. /**
  95270. * Gets the auto rotation behavior of the camera if it has been enabled.
  95271. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95272. */
  95273. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  95274. /**
  95275. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  95276. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95277. */
  95278. useAutoRotationBehavior: boolean;
  95279. /**
  95280. * Observable triggered when the mesh target has been changed on the camera.
  95281. */
  95282. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  95283. /**
  95284. * Event raised when the camera is colliding with a mesh.
  95285. */
  95286. onCollide: (collidedMesh: AbstractMesh) => void;
  95287. /**
  95288. * Defines whether the camera should check collision with the objects oh the scene.
  95289. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  95290. */
  95291. checkCollisions: boolean;
  95292. /**
  95293. * Defines the collision radius of the camera.
  95294. * This simulates a sphere around the camera.
  95295. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95296. */
  95297. collisionRadius: Vector3;
  95298. protected _collider: Collider;
  95299. protected _previousPosition: Vector3;
  95300. protected _collisionVelocity: Vector3;
  95301. protected _newPosition: Vector3;
  95302. protected _previousAlpha: number;
  95303. protected _previousBeta: number;
  95304. protected _previousRadius: number;
  95305. protected _collisionTriggered: boolean;
  95306. protected _targetBoundingCenter: Nullable<Vector3>;
  95307. private _computationVector;
  95308. /**
  95309. * Instantiates a new ArcRotateCamera in a given scene
  95310. * @param name Defines the name of the camera
  95311. * @param alpha Defines the camera rotation along the logitudinal axis
  95312. * @param beta Defines the camera rotation along the latitudinal axis
  95313. * @param radius Defines the camera distance from its target
  95314. * @param target Defines the camera target
  95315. * @param scene Defines the scene the camera belongs to
  95316. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95317. */
  95318. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95319. /** @hidden */
  95320. _initCache(): void;
  95321. /** @hidden */
  95322. _updateCache(ignoreParentClass?: boolean): void;
  95323. protected _getTargetPosition(): Vector3;
  95324. private _storedAlpha;
  95325. private _storedBeta;
  95326. private _storedRadius;
  95327. private _storedTarget;
  95328. /**
  95329. * Stores the current state of the camera (alpha, beta, radius and target)
  95330. * @returns the camera itself
  95331. */
  95332. storeState(): Camera;
  95333. /**
  95334. * @hidden
  95335. * Restored camera state. You must call storeState() first
  95336. */
  95337. _restoreStateValues(): boolean;
  95338. /** @hidden */
  95339. _isSynchronizedViewMatrix(): boolean;
  95340. /**
  95341. * Attached controls to the current camera.
  95342. * @param element Defines the element the controls should be listened from
  95343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95344. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  95345. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  95346. */
  95347. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  95348. /**
  95349. * Detach the current controls from the camera.
  95350. * The camera will stop reacting to inputs.
  95351. * @param element Defines the element to stop listening the inputs from
  95352. */
  95353. detachControl(element: HTMLElement): void;
  95354. /** @hidden */
  95355. _checkInputs(): void;
  95356. protected _checkLimits(): void;
  95357. /**
  95358. * Rebuilds angles (alpha, beta) and radius from the give position and target
  95359. */
  95360. rebuildAnglesAndRadius(): void;
  95361. /**
  95362. * Use a position to define the current camera related information like aplha, beta and radius
  95363. * @param position Defines the position to set the camera at
  95364. */
  95365. setPosition(position: Vector3): void;
  95366. /**
  95367. * Defines the target the camera should look at.
  95368. * This will automatically adapt alpha beta and radius to fit within the new target.
  95369. * @param target Defines the new target as a Vector or a mesh
  95370. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  95371. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  95372. */
  95373. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  95374. /** @hidden */
  95375. _getViewMatrix(): Matrix;
  95376. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  95377. /**
  95378. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  95379. * @param meshes Defines the mesh to zoom on
  95380. * @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)
  95381. */
  95382. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  95383. /**
  95384. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  95385. * The target will be changed but the radius
  95386. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  95387. * @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)
  95388. */
  95389. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  95390. min: Vector3;
  95391. max: Vector3;
  95392. distance: number;
  95393. }, doNotUpdateMaxZ?: boolean): void;
  95394. /**
  95395. * @override
  95396. * Override Camera.createRigCamera
  95397. */
  95398. createRigCamera(name: string, cameraIndex: number): Camera;
  95399. /**
  95400. * @hidden
  95401. * @override
  95402. * Override Camera._updateRigCameras
  95403. */
  95404. _updateRigCameras(): void;
  95405. /**
  95406. * Destroy the camera and release the current resources hold by it.
  95407. */
  95408. dispose(): void;
  95409. /**
  95410. * Gets the current object class name.
  95411. * @return the class name
  95412. */
  95413. getClassName(): string;
  95414. }
  95415. }
  95416. declare module BABYLON {
  95417. /**
  95418. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  95419. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95420. */
  95421. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  95422. /**
  95423. * Gets the name of the behavior.
  95424. */
  95425. readonly name: string;
  95426. private _zoomStopsAnimation;
  95427. private _idleRotationSpeed;
  95428. private _idleRotationWaitTime;
  95429. private _idleRotationSpinupTime;
  95430. /**
  95431. * Sets the flag that indicates if user zooming should stop animation.
  95432. */
  95433. /**
  95434. * Gets the flag that indicates if user zooming should stop animation.
  95435. */
  95436. zoomStopsAnimation: boolean;
  95437. /**
  95438. * Sets the default speed at which the camera rotates around the model.
  95439. */
  95440. /**
  95441. * Gets the default speed at which the camera rotates around the model.
  95442. */
  95443. idleRotationSpeed: number;
  95444. /**
  95445. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  95446. */
  95447. /**
  95448. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  95449. */
  95450. idleRotationWaitTime: number;
  95451. /**
  95452. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95453. */
  95454. /**
  95455. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95456. */
  95457. idleRotationSpinupTime: number;
  95458. /**
  95459. * Gets a value indicating if the camera is currently rotating because of this behavior
  95460. */
  95461. readonly rotationInProgress: boolean;
  95462. private _onPrePointerObservableObserver;
  95463. private _onAfterCheckInputsObserver;
  95464. private _attachedCamera;
  95465. private _isPointerDown;
  95466. private _lastFrameTime;
  95467. private _lastInteractionTime;
  95468. private _cameraRotationSpeed;
  95469. /**
  95470. * Initializes the behavior.
  95471. */
  95472. init(): void;
  95473. /**
  95474. * Attaches the behavior to its arc rotate camera.
  95475. * @param camera Defines the camera to attach the behavior to
  95476. */
  95477. attach(camera: ArcRotateCamera): void;
  95478. /**
  95479. * Detaches the behavior from its current arc rotate camera.
  95480. */
  95481. detach(): void;
  95482. /**
  95483. * Returns true if user is scrolling.
  95484. * @return true if user is scrolling.
  95485. */
  95486. private _userIsZooming;
  95487. private _lastFrameRadius;
  95488. private _shouldAnimationStopForInteraction;
  95489. /**
  95490. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  95491. */
  95492. private _applyUserInteraction;
  95493. private _userIsMoving;
  95494. }
  95495. }
  95496. declare module BABYLON {
  95497. /**
  95498. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  95499. */
  95500. export class AttachToBoxBehavior implements Behavior<Mesh> {
  95501. private ui;
  95502. /**
  95503. * The name of the behavior
  95504. */
  95505. name: string;
  95506. /**
  95507. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  95508. */
  95509. distanceAwayFromFace: number;
  95510. /**
  95511. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  95512. */
  95513. distanceAwayFromBottomOfFace: number;
  95514. private _faceVectors;
  95515. private _target;
  95516. private _scene;
  95517. private _onRenderObserver;
  95518. private _tmpMatrix;
  95519. private _tmpVector;
  95520. /**
  95521. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  95522. * @param ui The transform node that should be attched to the mesh
  95523. */
  95524. constructor(ui: TransformNode);
  95525. /**
  95526. * Initializes the behavior
  95527. */
  95528. init(): void;
  95529. private _closestFace;
  95530. private _zeroVector;
  95531. private _lookAtTmpMatrix;
  95532. private _lookAtToRef;
  95533. /**
  95534. * Attaches the AttachToBoxBehavior to the passed in mesh
  95535. * @param target The mesh that the specified node will be attached to
  95536. */
  95537. attach(target: Mesh): void;
  95538. /**
  95539. * Detaches the behavior from the mesh
  95540. */
  95541. detach(): void;
  95542. }
  95543. }
  95544. declare module BABYLON {
  95545. /**
  95546. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  95547. */
  95548. export class FadeInOutBehavior implements Behavior<Mesh> {
  95549. /**
  95550. * Time in milliseconds to delay before fading in (Default: 0)
  95551. */
  95552. delay: number;
  95553. /**
  95554. * Time in milliseconds for the mesh to fade in (Default: 300)
  95555. */
  95556. fadeInTime: number;
  95557. private _millisecondsPerFrame;
  95558. private _hovered;
  95559. private _hoverValue;
  95560. private _ownerNode;
  95561. /**
  95562. * Instatiates the FadeInOutBehavior
  95563. */
  95564. constructor();
  95565. /**
  95566. * The name of the behavior
  95567. */
  95568. readonly name: string;
  95569. /**
  95570. * Initializes the behavior
  95571. */
  95572. init(): void;
  95573. /**
  95574. * Attaches the fade behavior on the passed in mesh
  95575. * @param ownerNode The mesh that will be faded in/out once attached
  95576. */
  95577. attach(ownerNode: Mesh): void;
  95578. /**
  95579. * Detaches the behavior from the mesh
  95580. */
  95581. detach(): void;
  95582. /**
  95583. * Triggers the mesh to begin fading in or out
  95584. * @param value if the object should fade in or out (true to fade in)
  95585. */
  95586. fadeIn(value: boolean): void;
  95587. private _update;
  95588. private _setAllVisibility;
  95589. }
  95590. }
  95591. declare module BABYLON {
  95592. /**
  95593. * Class containing a set of static utilities functions for managing Pivots
  95594. * @hidden
  95595. */
  95596. export class PivotTools {
  95597. private static _PivotCached;
  95598. private static _OldPivotPoint;
  95599. private static _PivotTranslation;
  95600. private static _PivotTmpVector;
  95601. /** @hidden */
  95602. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  95603. /** @hidden */
  95604. static _RestorePivotPoint(mesh: AbstractMesh): void;
  95605. }
  95606. }
  95607. declare module BABYLON {
  95608. /**
  95609. * Class containing static functions to help procedurally build meshes
  95610. */
  95611. export class PlaneBuilder {
  95612. /**
  95613. * Creates a plane mesh
  95614. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  95615. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  95616. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  95617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95618. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95620. * @param name defines the name of the mesh
  95621. * @param options defines the options used to create the mesh
  95622. * @param scene defines the hosting scene
  95623. * @returns the plane mesh
  95624. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  95625. */
  95626. static CreatePlane(name: string, options: {
  95627. size?: number;
  95628. width?: number;
  95629. height?: number;
  95630. sideOrientation?: number;
  95631. frontUVs?: Vector4;
  95632. backUVs?: Vector4;
  95633. updatable?: boolean;
  95634. sourcePlane?: Plane;
  95635. }, scene?: Nullable<Scene>): Mesh;
  95636. }
  95637. }
  95638. declare module BABYLON {
  95639. /**
  95640. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  95641. */
  95642. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  95643. private static _AnyMouseID;
  95644. private _attachedNode;
  95645. private _dragPlane;
  95646. private _scene;
  95647. private _pointerObserver;
  95648. private _beforeRenderObserver;
  95649. private static _planeScene;
  95650. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  95651. /**
  95652. * 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)
  95653. */
  95654. maxDragAngle: number;
  95655. /**
  95656. * @hidden
  95657. */
  95658. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  95659. /**
  95660. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95661. */
  95662. currentDraggingPointerID: number;
  95663. /**
  95664. * The last position where the pointer hit the drag plane in world space
  95665. */
  95666. lastDragPosition: Vector3;
  95667. /**
  95668. * If the behavior is currently in a dragging state
  95669. */
  95670. dragging: boolean;
  95671. /**
  95672. * 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)
  95673. */
  95674. dragDeltaRatio: number;
  95675. /**
  95676. * If the drag plane orientation should be updated during the dragging (Default: true)
  95677. */
  95678. updateDragPlane: boolean;
  95679. private _debugMode;
  95680. private _moving;
  95681. /**
  95682. * Fires each time the attached mesh is dragged with the pointer
  95683. * * delta between last drag position and current drag position in world space
  95684. * * dragDistance along the drag axis
  95685. * * dragPlaneNormal normal of the current drag plane used during the drag
  95686. * * dragPlanePoint in world space where the drag intersects the drag plane
  95687. */
  95688. onDragObservable: Observable<{
  95689. delta: Vector3;
  95690. dragPlanePoint: Vector3;
  95691. dragPlaneNormal: Vector3;
  95692. dragDistance: number;
  95693. pointerId: number;
  95694. }>;
  95695. /**
  95696. * Fires each time a drag begins (eg. mouse down on mesh)
  95697. */
  95698. onDragStartObservable: Observable<{
  95699. dragPlanePoint: Vector3;
  95700. pointerId: number;
  95701. }>;
  95702. /**
  95703. * Fires each time a drag ends (eg. mouse release after drag)
  95704. */
  95705. onDragEndObservable: Observable<{
  95706. dragPlanePoint: Vector3;
  95707. pointerId: number;
  95708. }>;
  95709. /**
  95710. * If the attached mesh should be moved when dragged
  95711. */
  95712. moveAttached: boolean;
  95713. /**
  95714. * If the drag behavior will react to drag events (Default: true)
  95715. */
  95716. enabled: boolean;
  95717. /**
  95718. * If camera controls should be detached during the drag
  95719. */
  95720. detachCameraControls: boolean;
  95721. /**
  95722. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  95723. */
  95724. useObjectOrienationForDragging: boolean;
  95725. private _options;
  95726. /**
  95727. * Creates a pointer drag behavior that can be attached to a mesh
  95728. * @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)
  95729. */
  95730. constructor(options?: {
  95731. dragAxis?: Vector3;
  95732. dragPlaneNormal?: Vector3;
  95733. });
  95734. /**
  95735. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95736. */
  95737. validateDrag: (targetPosition: Vector3) => boolean;
  95738. /**
  95739. * The name of the behavior
  95740. */
  95741. readonly name: string;
  95742. /**
  95743. * Initializes the behavior
  95744. */
  95745. init(): void;
  95746. private _tmpVector;
  95747. private _alternatePickedPoint;
  95748. private _worldDragAxis;
  95749. private _targetPosition;
  95750. private _attachedElement;
  95751. /**
  95752. * Attaches the drag behavior the passed in mesh
  95753. * @param ownerNode The mesh that will be dragged around once attached
  95754. */
  95755. attach(ownerNode: AbstractMesh): void;
  95756. /**
  95757. * Force relase the drag action by code.
  95758. */
  95759. releaseDrag(): void;
  95760. private _startDragRay;
  95761. private _lastPointerRay;
  95762. /**
  95763. * Simulates the start of a pointer drag event on the behavior
  95764. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95765. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95766. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95767. */
  95768. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95769. private _startDrag;
  95770. private _dragDelta;
  95771. private _moveDrag;
  95772. private _pickWithRayOnDragPlane;
  95773. private _pointA;
  95774. private _pointB;
  95775. private _pointC;
  95776. private _lineA;
  95777. private _lineB;
  95778. private _localAxis;
  95779. private _lookAt;
  95780. private _updateDragPlanePosition;
  95781. /**
  95782. * Detaches the behavior from the mesh
  95783. */
  95784. detach(): void;
  95785. }
  95786. }
  95787. declare module BABYLON {
  95788. /**
  95789. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95790. */
  95791. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95792. private _dragBehaviorA;
  95793. private _dragBehaviorB;
  95794. private _startDistance;
  95795. private _initialScale;
  95796. private _targetScale;
  95797. private _ownerNode;
  95798. private _sceneRenderObserver;
  95799. /**
  95800. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95801. */
  95802. constructor();
  95803. /**
  95804. * The name of the behavior
  95805. */
  95806. readonly name: string;
  95807. /**
  95808. * Initializes the behavior
  95809. */
  95810. init(): void;
  95811. private _getCurrentDistance;
  95812. /**
  95813. * Attaches the scale behavior the passed in mesh
  95814. * @param ownerNode The mesh that will be scaled around once attached
  95815. */
  95816. attach(ownerNode: Mesh): void;
  95817. /**
  95818. * Detaches the behavior from the mesh
  95819. */
  95820. detach(): void;
  95821. }
  95822. }
  95823. declare module BABYLON {
  95824. /**
  95825. * 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
  95826. */
  95827. export class SixDofDragBehavior implements Behavior<Mesh> {
  95828. private static _virtualScene;
  95829. private _ownerNode;
  95830. private _sceneRenderObserver;
  95831. private _scene;
  95832. private _targetPosition;
  95833. private _virtualOriginMesh;
  95834. private _virtualDragMesh;
  95835. private _pointerObserver;
  95836. private _moving;
  95837. private _startingOrientation;
  95838. /**
  95839. * 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)
  95840. */
  95841. private zDragFactor;
  95842. /**
  95843. * If the object should rotate to face the drag origin
  95844. */
  95845. rotateDraggedObject: boolean;
  95846. /**
  95847. * If the behavior is currently in a dragging state
  95848. */
  95849. dragging: boolean;
  95850. /**
  95851. * 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)
  95852. */
  95853. dragDeltaRatio: number;
  95854. /**
  95855. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95856. */
  95857. currentDraggingPointerID: number;
  95858. /**
  95859. * If camera controls should be detached during the drag
  95860. */
  95861. detachCameraControls: boolean;
  95862. /**
  95863. * Fires each time a drag starts
  95864. */
  95865. onDragStartObservable: Observable<{}>;
  95866. /**
  95867. * Fires each time a drag ends (eg. mouse release after drag)
  95868. */
  95869. onDragEndObservable: Observable<{}>;
  95870. /**
  95871. * 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
  95872. */
  95873. constructor();
  95874. /**
  95875. * The name of the behavior
  95876. */
  95877. readonly name: string;
  95878. /**
  95879. * Initializes the behavior
  95880. */
  95881. init(): void;
  95882. /**
  95883. * Attaches the scale behavior the passed in mesh
  95884. * @param ownerNode The mesh that will be scaled around once attached
  95885. */
  95886. attach(ownerNode: Mesh): void;
  95887. /**
  95888. * Detaches the behavior from the mesh
  95889. */
  95890. detach(): void;
  95891. }
  95892. }
  95893. declare module BABYLON {
  95894. /**
  95895. * Class used to apply inverse kinematics to bones
  95896. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95897. */
  95898. export class BoneIKController {
  95899. private static _tmpVecs;
  95900. private static _tmpQuat;
  95901. private static _tmpMats;
  95902. /**
  95903. * Gets or sets the target mesh
  95904. */
  95905. targetMesh: AbstractMesh;
  95906. /** Gets or sets the mesh used as pole */
  95907. poleTargetMesh: AbstractMesh;
  95908. /**
  95909. * Gets or sets the bone used as pole
  95910. */
  95911. poleTargetBone: Nullable<Bone>;
  95912. /**
  95913. * Gets or sets the target position
  95914. */
  95915. targetPosition: Vector3;
  95916. /**
  95917. * Gets or sets the pole target position
  95918. */
  95919. poleTargetPosition: Vector3;
  95920. /**
  95921. * Gets or sets the pole target local offset
  95922. */
  95923. poleTargetLocalOffset: Vector3;
  95924. /**
  95925. * Gets or sets the pole angle
  95926. */
  95927. poleAngle: number;
  95928. /**
  95929. * Gets or sets the mesh associated with the controller
  95930. */
  95931. mesh: AbstractMesh;
  95932. /**
  95933. * 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)
  95934. */
  95935. slerpAmount: number;
  95936. private _bone1Quat;
  95937. private _bone1Mat;
  95938. private _bone2Ang;
  95939. private _bone1;
  95940. private _bone2;
  95941. private _bone1Length;
  95942. private _bone2Length;
  95943. private _maxAngle;
  95944. private _maxReach;
  95945. private _rightHandedSystem;
  95946. private _bendAxis;
  95947. private _slerping;
  95948. private _adjustRoll;
  95949. /**
  95950. * Gets or sets maximum allowed angle
  95951. */
  95952. maxAngle: number;
  95953. /**
  95954. * Creates a new BoneIKController
  95955. * @param mesh defines the mesh to control
  95956. * @param bone defines the bone to control
  95957. * @param options defines options to set up the controller
  95958. */
  95959. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95960. targetMesh?: AbstractMesh;
  95961. poleTargetMesh?: AbstractMesh;
  95962. poleTargetBone?: Bone;
  95963. poleTargetLocalOffset?: Vector3;
  95964. poleAngle?: number;
  95965. bendAxis?: Vector3;
  95966. maxAngle?: number;
  95967. slerpAmount?: number;
  95968. });
  95969. private _setMaxAngle;
  95970. /**
  95971. * Force the controller to update the bones
  95972. */
  95973. update(): void;
  95974. }
  95975. }
  95976. declare module BABYLON {
  95977. /**
  95978. * Class used to make a bone look toward a point in space
  95979. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95980. */
  95981. export class BoneLookController {
  95982. private static _tmpVecs;
  95983. private static _tmpQuat;
  95984. private static _tmpMats;
  95985. /**
  95986. * The target Vector3 that the bone will look at
  95987. */
  95988. target: Vector3;
  95989. /**
  95990. * The mesh that the bone is attached to
  95991. */
  95992. mesh: AbstractMesh;
  95993. /**
  95994. * The bone that will be looking to the target
  95995. */
  95996. bone: Bone;
  95997. /**
  95998. * The up axis of the coordinate system that is used when the bone is rotated
  95999. */
  96000. upAxis: Vector3;
  96001. /**
  96002. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  96003. */
  96004. upAxisSpace: Space;
  96005. /**
  96006. * Used to make an adjustment to the yaw of the bone
  96007. */
  96008. adjustYaw: number;
  96009. /**
  96010. * Used to make an adjustment to the pitch of the bone
  96011. */
  96012. adjustPitch: number;
  96013. /**
  96014. * Used to make an adjustment to the roll of the bone
  96015. */
  96016. adjustRoll: number;
  96017. /**
  96018. * 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)
  96019. */
  96020. slerpAmount: number;
  96021. private _minYaw;
  96022. private _maxYaw;
  96023. private _minPitch;
  96024. private _maxPitch;
  96025. private _minYawSin;
  96026. private _minYawCos;
  96027. private _maxYawSin;
  96028. private _maxYawCos;
  96029. private _midYawConstraint;
  96030. private _minPitchTan;
  96031. private _maxPitchTan;
  96032. private _boneQuat;
  96033. private _slerping;
  96034. private _transformYawPitch;
  96035. private _transformYawPitchInv;
  96036. private _firstFrameSkipped;
  96037. private _yawRange;
  96038. private _fowardAxis;
  96039. /**
  96040. * Gets or sets the minimum yaw angle that the bone can look to
  96041. */
  96042. minYaw: number;
  96043. /**
  96044. * Gets or sets the maximum yaw angle that the bone can look to
  96045. */
  96046. maxYaw: number;
  96047. /**
  96048. * Gets or sets the minimum pitch angle that the bone can look to
  96049. */
  96050. minPitch: number;
  96051. /**
  96052. * Gets or sets the maximum pitch angle that the bone can look to
  96053. */
  96054. maxPitch: number;
  96055. /**
  96056. * Create a BoneLookController
  96057. * @param mesh the mesh that the bone belongs to
  96058. * @param bone the bone that will be looking to the target
  96059. * @param target the target Vector3 to look at
  96060. * @param options optional settings:
  96061. * * maxYaw: the maximum angle the bone will yaw to
  96062. * * minYaw: the minimum angle the bone will yaw to
  96063. * * maxPitch: the maximum angle the bone will pitch to
  96064. * * minPitch: the minimum angle the bone will yaw to
  96065. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  96066. * * upAxis: the up axis of the coordinate system
  96067. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  96068. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  96069. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  96070. * * adjustYaw: used to make an adjustment to the yaw of the bone
  96071. * * adjustPitch: used to make an adjustment to the pitch of the bone
  96072. * * adjustRoll: used to make an adjustment to the roll of the bone
  96073. **/
  96074. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  96075. maxYaw?: number;
  96076. minYaw?: number;
  96077. maxPitch?: number;
  96078. minPitch?: number;
  96079. slerpAmount?: number;
  96080. upAxis?: Vector3;
  96081. upAxisSpace?: Space;
  96082. yawAxis?: Vector3;
  96083. pitchAxis?: Vector3;
  96084. adjustYaw?: number;
  96085. adjustPitch?: number;
  96086. adjustRoll?: number;
  96087. });
  96088. /**
  96089. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  96090. */
  96091. update(): void;
  96092. private _getAngleDiff;
  96093. private _getAngleBetween;
  96094. private _isAngleBetween;
  96095. }
  96096. }
  96097. declare module BABYLON {
  96098. /**
  96099. * Manage the gamepad inputs to control an arc rotate camera.
  96100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96101. */
  96102. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  96103. /**
  96104. * Defines the camera the input is attached to.
  96105. */
  96106. camera: ArcRotateCamera;
  96107. /**
  96108. * Defines the gamepad the input is gathering event from.
  96109. */
  96110. gamepad: Nullable<Gamepad>;
  96111. /**
  96112. * Defines the gamepad rotation sensiblity.
  96113. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96114. */
  96115. gamepadRotationSensibility: number;
  96116. /**
  96117. * Defines the gamepad move sensiblity.
  96118. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96119. */
  96120. gamepadMoveSensibility: number;
  96121. private _onGamepadConnectedObserver;
  96122. private _onGamepadDisconnectedObserver;
  96123. /**
  96124. * Attach the input controls to a specific dom element to get the input from.
  96125. * @param element Defines the element the controls should be listened from
  96126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96127. */
  96128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96129. /**
  96130. * Detach the current controls from the specified dom element.
  96131. * @param element Defines the element to stop listening the inputs from
  96132. */
  96133. detachControl(element: Nullable<HTMLElement>): void;
  96134. /**
  96135. * Update the current camera state depending on the inputs that have been used this frame.
  96136. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96137. */
  96138. checkInputs(): void;
  96139. /**
  96140. * Gets the class name of the current intput.
  96141. * @returns the class name
  96142. */
  96143. getClassName(): string;
  96144. /**
  96145. * Get the friendly name associated with the input class.
  96146. * @returns the input friendly name
  96147. */
  96148. getSimpleName(): string;
  96149. }
  96150. }
  96151. declare module BABYLON {
  96152. interface ArcRotateCameraInputsManager {
  96153. /**
  96154. * Add orientation input support to the input manager.
  96155. * @returns the current input manager
  96156. */
  96157. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  96158. }
  96159. /**
  96160. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  96161. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96162. */
  96163. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  96164. /**
  96165. * Defines the camera the input is attached to.
  96166. */
  96167. camera: ArcRotateCamera;
  96168. /**
  96169. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  96170. */
  96171. alphaCorrection: number;
  96172. /**
  96173. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  96174. */
  96175. gammaCorrection: number;
  96176. private _alpha;
  96177. private _gamma;
  96178. private _dirty;
  96179. private _deviceOrientationHandler;
  96180. /**
  96181. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  96182. */
  96183. constructor();
  96184. /**
  96185. * Attach the input controls to a specific dom element to get the input from.
  96186. * @param element Defines the element the controls should be listened from
  96187. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96188. */
  96189. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96190. /** @hidden */
  96191. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  96192. /**
  96193. * Update the current camera state depending on the inputs that have been used this frame.
  96194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96195. */
  96196. checkInputs(): void;
  96197. /**
  96198. * Detach the current controls from the specified dom element.
  96199. * @param element Defines the element to stop listening the inputs from
  96200. */
  96201. detachControl(element: Nullable<HTMLElement>): void;
  96202. /**
  96203. * Gets the class name of the current intput.
  96204. * @returns the class name
  96205. */
  96206. getClassName(): string;
  96207. /**
  96208. * Get the friendly name associated with the input class.
  96209. * @returns the input friendly name
  96210. */
  96211. getSimpleName(): string;
  96212. }
  96213. }
  96214. declare module BABYLON {
  96215. /**
  96216. * Listen to mouse events to control the camera.
  96217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96218. */
  96219. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  96220. /**
  96221. * Defines the camera the input is attached to.
  96222. */
  96223. camera: FlyCamera;
  96224. /**
  96225. * Defines if touch is enabled. (Default is true.)
  96226. */
  96227. touchEnabled: boolean;
  96228. /**
  96229. * Defines the buttons associated with the input to handle camera rotation.
  96230. */
  96231. buttons: number[];
  96232. /**
  96233. * Assign buttons for Yaw control.
  96234. */
  96235. buttonsYaw: number[];
  96236. /**
  96237. * Assign buttons for Pitch control.
  96238. */
  96239. buttonsPitch: number[];
  96240. /**
  96241. * Assign buttons for Roll control.
  96242. */
  96243. buttonsRoll: number[];
  96244. /**
  96245. * Detect if any button is being pressed while mouse is moved.
  96246. * -1 = Mouse locked.
  96247. * 0 = Left button.
  96248. * 1 = Middle Button.
  96249. * 2 = Right Button.
  96250. */
  96251. activeButton: number;
  96252. /**
  96253. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  96254. * Higher values reduce its sensitivity.
  96255. */
  96256. angularSensibility: number;
  96257. private _mousemoveCallback;
  96258. private _observer;
  96259. private _rollObserver;
  96260. private previousPosition;
  96261. private noPreventDefault;
  96262. private element;
  96263. /**
  96264. * Listen to mouse events to control the camera.
  96265. * @param touchEnabled Define if touch is enabled. (Default is true.)
  96266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96267. */
  96268. constructor(touchEnabled?: boolean);
  96269. /**
  96270. * Attach the mouse control to the HTML DOM element.
  96271. * @param element Defines the element that listens to the input events.
  96272. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  96273. */
  96274. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96275. /**
  96276. * Detach the current controls from the specified dom element.
  96277. * @param element Defines the element to stop listening the inputs from
  96278. */
  96279. detachControl(element: Nullable<HTMLElement>): void;
  96280. /**
  96281. * Gets the class name of the current input.
  96282. * @returns the class name.
  96283. */
  96284. getClassName(): string;
  96285. /**
  96286. * Get the friendly name associated with the input class.
  96287. * @returns the input's friendly name.
  96288. */
  96289. getSimpleName(): string;
  96290. private _pointerInput;
  96291. private _onMouseMove;
  96292. /**
  96293. * Rotate camera by mouse offset.
  96294. */
  96295. private rotateCamera;
  96296. }
  96297. }
  96298. declare module BABYLON {
  96299. /**
  96300. * Default Inputs manager for the FlyCamera.
  96301. * It groups all the default supported inputs for ease of use.
  96302. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96303. */
  96304. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  96305. /**
  96306. * Instantiates a new FlyCameraInputsManager.
  96307. * @param camera Defines the camera the inputs belong to.
  96308. */
  96309. constructor(camera: FlyCamera);
  96310. /**
  96311. * Add keyboard input support to the input manager.
  96312. * @returns the new FlyCameraKeyboardMoveInput().
  96313. */
  96314. addKeyboard(): FlyCameraInputsManager;
  96315. /**
  96316. * Add mouse input support to the input manager.
  96317. * @param touchEnabled Enable touch screen support.
  96318. * @returns the new FlyCameraMouseInput().
  96319. */
  96320. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  96321. }
  96322. }
  96323. declare module BABYLON {
  96324. /**
  96325. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96326. * such as in a 3D Space Shooter or a Flight Simulator.
  96327. */
  96328. export class FlyCamera extends TargetCamera {
  96329. /**
  96330. * Define the collision ellipsoid of the camera.
  96331. * This is helpful for simulating a camera body, like a player's body.
  96332. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96333. */
  96334. ellipsoid: Vector3;
  96335. /**
  96336. * Define an offset for the position of the ellipsoid around the camera.
  96337. * This can be helpful if the camera is attached away from the player's body center,
  96338. * such as at its head.
  96339. */
  96340. ellipsoidOffset: Vector3;
  96341. /**
  96342. * Enable or disable collisions of the camera with the rest of the scene objects.
  96343. */
  96344. checkCollisions: boolean;
  96345. /**
  96346. * Enable or disable gravity on the camera.
  96347. */
  96348. applyGravity: boolean;
  96349. /**
  96350. * Define the current direction the camera is moving to.
  96351. */
  96352. cameraDirection: Vector3;
  96353. /**
  96354. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  96355. * This overrides and empties cameraRotation.
  96356. */
  96357. rotationQuaternion: Quaternion;
  96358. /**
  96359. * Track Roll to maintain the wanted Rolling when looking around.
  96360. */
  96361. _trackRoll: number;
  96362. /**
  96363. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  96364. */
  96365. rollCorrect: number;
  96366. /**
  96367. * Mimic a banked turn, Rolling the camera when Yawing.
  96368. * It's recommended to use rollCorrect = 10 for faster banking correction.
  96369. */
  96370. bankedTurn: boolean;
  96371. /**
  96372. * Limit in radians for how much Roll banking will add. (Default: 90°)
  96373. */
  96374. bankedTurnLimit: number;
  96375. /**
  96376. * Value of 0 disables the banked Roll.
  96377. * Value of 1 is equal to the Yaw angle in radians.
  96378. */
  96379. bankedTurnMultiplier: number;
  96380. /**
  96381. * The inputs manager loads all the input sources, such as keyboard and mouse.
  96382. */
  96383. inputs: FlyCameraInputsManager;
  96384. /**
  96385. * Gets the input sensibility for mouse input.
  96386. * Higher values reduce sensitivity.
  96387. */
  96388. /**
  96389. * Sets the input sensibility for a mouse input.
  96390. * Higher values reduce sensitivity.
  96391. */
  96392. angularSensibility: number;
  96393. /**
  96394. * Get the keys for camera movement forward.
  96395. */
  96396. /**
  96397. * Set the keys for camera movement forward.
  96398. */
  96399. keysForward: number[];
  96400. /**
  96401. * Get the keys for camera movement backward.
  96402. */
  96403. keysBackward: number[];
  96404. /**
  96405. * Get the keys for camera movement up.
  96406. */
  96407. /**
  96408. * Set the keys for camera movement up.
  96409. */
  96410. keysUp: number[];
  96411. /**
  96412. * Get the keys for camera movement down.
  96413. */
  96414. /**
  96415. * Set the keys for camera movement down.
  96416. */
  96417. keysDown: number[];
  96418. /**
  96419. * Get the keys for camera movement left.
  96420. */
  96421. /**
  96422. * Set the keys for camera movement left.
  96423. */
  96424. keysLeft: number[];
  96425. /**
  96426. * Set the keys for camera movement right.
  96427. */
  96428. /**
  96429. * Set the keys for camera movement right.
  96430. */
  96431. keysRight: number[];
  96432. /**
  96433. * Event raised when the camera collides with a mesh in the scene.
  96434. */
  96435. onCollide: (collidedMesh: AbstractMesh) => void;
  96436. private _collider;
  96437. private _needMoveForGravity;
  96438. private _oldPosition;
  96439. private _diffPosition;
  96440. private _newPosition;
  96441. /** @hidden */
  96442. _localDirection: Vector3;
  96443. /** @hidden */
  96444. _transformedDirection: Vector3;
  96445. /**
  96446. * Instantiates a FlyCamera.
  96447. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96448. * such as in a 3D Space Shooter or a Flight Simulator.
  96449. * @param name Define the name of the camera in the scene.
  96450. * @param position Define the starting position of the camera in the scene.
  96451. * @param scene Define the scene the camera belongs to.
  96452. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  96453. */
  96454. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96455. /**
  96456. * Attach a control to the HTML DOM element.
  96457. * @param element Defines the element that listens to the input events.
  96458. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  96459. */
  96460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96461. /**
  96462. * Detach a control from the HTML DOM element.
  96463. * The camera will stop reacting to that input.
  96464. * @param element Defines the element that listens to the input events.
  96465. */
  96466. detachControl(element: HTMLElement): void;
  96467. private _collisionMask;
  96468. /**
  96469. * Get the mask that the camera ignores in collision events.
  96470. */
  96471. /**
  96472. * Set the mask that the camera ignores in collision events.
  96473. */
  96474. collisionMask: number;
  96475. /** @hidden */
  96476. _collideWithWorld(displacement: Vector3): void;
  96477. /** @hidden */
  96478. private _onCollisionPositionChange;
  96479. /** @hidden */
  96480. _checkInputs(): void;
  96481. /** @hidden */
  96482. _decideIfNeedsToMove(): boolean;
  96483. /** @hidden */
  96484. _updatePosition(): void;
  96485. /**
  96486. * Restore the Roll to its target value at the rate specified.
  96487. * @param rate - Higher means slower restoring.
  96488. * @hidden
  96489. */
  96490. restoreRoll(rate: number): void;
  96491. /**
  96492. * Destroy the camera and release the current resources held by it.
  96493. */
  96494. dispose(): void;
  96495. /**
  96496. * Get the current object class name.
  96497. * @returns the class name.
  96498. */
  96499. getClassName(): string;
  96500. }
  96501. }
  96502. declare module BABYLON {
  96503. /**
  96504. * Listen to keyboard events to control the camera.
  96505. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96506. */
  96507. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  96508. /**
  96509. * Defines the camera the input is attached to.
  96510. */
  96511. camera: FlyCamera;
  96512. /**
  96513. * The list of keyboard keys used to control the forward move of the camera.
  96514. */
  96515. keysForward: number[];
  96516. /**
  96517. * The list of keyboard keys used to control the backward move of the camera.
  96518. */
  96519. keysBackward: number[];
  96520. /**
  96521. * The list of keyboard keys used to control the forward move of the camera.
  96522. */
  96523. keysUp: number[];
  96524. /**
  96525. * The list of keyboard keys used to control the backward move of the camera.
  96526. */
  96527. keysDown: number[];
  96528. /**
  96529. * The list of keyboard keys used to control the right strafe move of the camera.
  96530. */
  96531. keysRight: number[];
  96532. /**
  96533. * The list of keyboard keys used to control the left strafe move of the camera.
  96534. */
  96535. keysLeft: number[];
  96536. private _keys;
  96537. private _onCanvasBlurObserver;
  96538. private _onKeyboardObserver;
  96539. private _engine;
  96540. private _scene;
  96541. /**
  96542. * Attach the input controls to a specific dom element to get the input from.
  96543. * @param element Defines the element the controls should be listened from
  96544. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96545. */
  96546. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96547. /**
  96548. * Detach the current controls from the specified dom element.
  96549. * @param element Defines the element to stop listening the inputs from
  96550. */
  96551. detachControl(element: Nullable<HTMLElement>): void;
  96552. /**
  96553. * Gets the class name of the current intput.
  96554. * @returns the class name
  96555. */
  96556. getClassName(): string;
  96557. /** @hidden */
  96558. _onLostFocus(e: FocusEvent): void;
  96559. /**
  96560. * Get the friendly name associated with the input class.
  96561. * @returns the input friendly name
  96562. */
  96563. getSimpleName(): string;
  96564. /**
  96565. * Update the current camera state depending on the inputs that have been used this frame.
  96566. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96567. */
  96568. checkInputs(): void;
  96569. }
  96570. }
  96571. declare module BABYLON {
  96572. /**
  96573. * Manage the mouse wheel inputs to control a follow camera.
  96574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96575. */
  96576. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  96577. /**
  96578. * Defines the camera the input is attached to.
  96579. */
  96580. camera: FollowCamera;
  96581. /**
  96582. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  96583. */
  96584. axisControlRadius: boolean;
  96585. /**
  96586. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  96587. */
  96588. axisControlHeight: boolean;
  96589. /**
  96590. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  96591. */
  96592. axisControlRotation: boolean;
  96593. /**
  96594. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  96595. * relation to mouseWheel events.
  96596. */
  96597. wheelPrecision: number;
  96598. /**
  96599. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  96600. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  96601. */
  96602. wheelDeltaPercentage: number;
  96603. private _wheel;
  96604. private _observer;
  96605. /**
  96606. * Attach the input controls to a specific dom element to get the input from.
  96607. * @param element Defines the element the controls should be listened from
  96608. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96609. */
  96610. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96611. /**
  96612. * Detach the current controls from the specified dom element.
  96613. * @param element Defines the element to stop listening the inputs from
  96614. */
  96615. detachControl(element: Nullable<HTMLElement>): void;
  96616. /**
  96617. * Gets the class name of the current intput.
  96618. * @returns the class name
  96619. */
  96620. getClassName(): string;
  96621. /**
  96622. * Get the friendly name associated with the input class.
  96623. * @returns the input friendly name
  96624. */
  96625. getSimpleName(): string;
  96626. }
  96627. }
  96628. declare module BABYLON {
  96629. /**
  96630. * Manage the pointers inputs to control an follow camera.
  96631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96632. */
  96633. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  96634. /**
  96635. * Defines the camera the input is attached to.
  96636. */
  96637. camera: FollowCamera;
  96638. /**
  96639. * Gets the class name of the current input.
  96640. * @returns the class name
  96641. */
  96642. getClassName(): string;
  96643. /**
  96644. * Defines the pointer angular sensibility along the X axis or how fast is
  96645. * the camera rotating.
  96646. * A negative number will reverse the axis direction.
  96647. */
  96648. angularSensibilityX: number;
  96649. /**
  96650. * Defines the pointer angular sensibility along the Y axis or how fast is
  96651. * the camera rotating.
  96652. * A negative number will reverse the axis direction.
  96653. */
  96654. angularSensibilityY: number;
  96655. /**
  96656. * Defines the pointer pinch precision or how fast is the camera zooming.
  96657. * A negative number will reverse the axis direction.
  96658. */
  96659. pinchPrecision: number;
  96660. /**
  96661. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  96662. * from 0.
  96663. * It defines the percentage of current camera.radius to use as delta when
  96664. * pinch zoom is used.
  96665. */
  96666. pinchDeltaPercentage: number;
  96667. /**
  96668. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  96669. */
  96670. axisXControlRadius: boolean;
  96671. /**
  96672. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  96673. */
  96674. axisXControlHeight: boolean;
  96675. /**
  96676. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  96677. */
  96678. axisXControlRotation: boolean;
  96679. /**
  96680. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  96681. */
  96682. axisYControlRadius: boolean;
  96683. /**
  96684. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  96685. */
  96686. axisYControlHeight: boolean;
  96687. /**
  96688. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  96689. */
  96690. axisYControlRotation: boolean;
  96691. /**
  96692. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  96693. */
  96694. axisPinchControlRadius: boolean;
  96695. /**
  96696. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  96697. */
  96698. axisPinchControlHeight: boolean;
  96699. /**
  96700. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  96701. */
  96702. axisPinchControlRotation: boolean;
  96703. /**
  96704. * Log error messages if basic misconfiguration has occurred.
  96705. */
  96706. warningEnable: boolean;
  96707. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96708. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96709. private _warningCounter;
  96710. private _warning;
  96711. }
  96712. }
  96713. declare module BABYLON {
  96714. /**
  96715. * Default Inputs manager for the FollowCamera.
  96716. * It groups all the default supported inputs for ease of use.
  96717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96718. */
  96719. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  96720. /**
  96721. * Instantiates a new FollowCameraInputsManager.
  96722. * @param camera Defines the camera the inputs belong to
  96723. */
  96724. constructor(camera: FollowCamera);
  96725. /**
  96726. * Add keyboard input support to the input manager.
  96727. * @returns the current input manager
  96728. */
  96729. addKeyboard(): FollowCameraInputsManager;
  96730. /**
  96731. * Add mouse wheel input support to the input manager.
  96732. * @returns the current input manager
  96733. */
  96734. addMouseWheel(): FollowCameraInputsManager;
  96735. /**
  96736. * Add pointers input support to the input manager.
  96737. * @returns the current input manager
  96738. */
  96739. addPointers(): FollowCameraInputsManager;
  96740. /**
  96741. * Add orientation input support to the input manager.
  96742. * @returns the current input manager
  96743. */
  96744. addVRDeviceOrientation(): FollowCameraInputsManager;
  96745. }
  96746. }
  96747. declare module BABYLON {
  96748. /**
  96749. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96750. * an arc rotate version arcFollowCamera are available.
  96751. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96752. */
  96753. export class FollowCamera extends TargetCamera {
  96754. /**
  96755. * Distance the follow camera should follow an object at
  96756. */
  96757. radius: number;
  96758. /**
  96759. * Minimum allowed distance of the camera to the axis of rotation
  96760. * (The camera can not get closer).
  96761. * This can help limiting how the Camera is able to move in the scene.
  96762. */
  96763. lowerRadiusLimit: Nullable<number>;
  96764. /**
  96765. * Maximum allowed distance of the camera to the axis of rotation
  96766. * (The camera can not get further).
  96767. * This can help limiting how the Camera is able to move in the scene.
  96768. */
  96769. upperRadiusLimit: Nullable<number>;
  96770. /**
  96771. * Define a rotation offset between the camera and the object it follows
  96772. */
  96773. rotationOffset: number;
  96774. /**
  96775. * Minimum allowed angle to camera position relative to target object.
  96776. * This can help limiting how the Camera is able to move in the scene.
  96777. */
  96778. lowerRotationOffsetLimit: Nullable<number>;
  96779. /**
  96780. * Maximum allowed angle to camera position relative to target object.
  96781. * This can help limiting how the Camera is able to move in the scene.
  96782. */
  96783. upperRotationOffsetLimit: Nullable<number>;
  96784. /**
  96785. * Define a height offset between the camera and the object it follows.
  96786. * It can help following an object from the top (like a car chaing a plane)
  96787. */
  96788. heightOffset: number;
  96789. /**
  96790. * Minimum allowed height of camera position relative to target object.
  96791. * This can help limiting how the Camera is able to move in the scene.
  96792. */
  96793. lowerHeightOffsetLimit: Nullable<number>;
  96794. /**
  96795. * Maximum allowed height of camera position relative to target object.
  96796. * This can help limiting how the Camera is able to move in the scene.
  96797. */
  96798. upperHeightOffsetLimit: Nullable<number>;
  96799. /**
  96800. * Define how fast the camera can accelerate to follow it s target.
  96801. */
  96802. cameraAcceleration: number;
  96803. /**
  96804. * Define the speed limit of the camera following an object.
  96805. */
  96806. maxCameraSpeed: number;
  96807. /**
  96808. * Define the target of the camera.
  96809. */
  96810. lockedTarget: Nullable<AbstractMesh>;
  96811. /**
  96812. * Defines the input associated with the camera.
  96813. */
  96814. inputs: FollowCameraInputsManager;
  96815. /**
  96816. * Instantiates the follow camera.
  96817. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96818. * @param name Define the name of the camera in the scene
  96819. * @param position Define the position of the camera
  96820. * @param scene Define the scene the camera belong to
  96821. * @param lockedTarget Define the target of the camera
  96822. */
  96823. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96824. private _follow;
  96825. /**
  96826. * Attached controls to the current camera.
  96827. * @param element Defines the element the controls should be listened from
  96828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96829. */
  96830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96831. /**
  96832. * Detach the current controls from the camera.
  96833. * The camera will stop reacting to inputs.
  96834. * @param element Defines the element to stop listening the inputs from
  96835. */
  96836. detachControl(element: HTMLElement): void;
  96837. /** @hidden */
  96838. _checkInputs(): void;
  96839. private _checkLimits;
  96840. /**
  96841. * Gets the camera class name.
  96842. * @returns the class name
  96843. */
  96844. getClassName(): string;
  96845. }
  96846. /**
  96847. * Arc Rotate version of the follow camera.
  96848. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96849. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96850. */
  96851. export class ArcFollowCamera extends TargetCamera {
  96852. /** The longitudinal angle of the camera */
  96853. alpha: number;
  96854. /** The latitudinal angle of the camera */
  96855. beta: number;
  96856. /** The radius of the camera from its target */
  96857. radius: number;
  96858. /** Define the camera target (the messh it should follow) */
  96859. target: Nullable<AbstractMesh>;
  96860. private _cartesianCoordinates;
  96861. /**
  96862. * Instantiates a new ArcFollowCamera
  96863. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96864. * @param name Define the name of the camera
  96865. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96866. * @param beta Define the rotation angle of the camera around the elevation axis
  96867. * @param radius Define the radius of the camera from its target point
  96868. * @param target Define the target of the camera
  96869. * @param scene Define the scene the camera belongs to
  96870. */
  96871. constructor(name: string,
  96872. /** The longitudinal angle of the camera */
  96873. alpha: number,
  96874. /** The latitudinal angle of the camera */
  96875. beta: number,
  96876. /** The radius of the camera from its target */
  96877. radius: number,
  96878. /** Define the camera target (the messh it should follow) */
  96879. target: Nullable<AbstractMesh>, scene: Scene);
  96880. private _follow;
  96881. /** @hidden */
  96882. _checkInputs(): void;
  96883. /**
  96884. * Returns the class name of the object.
  96885. * It is mostly used internally for serialization purposes.
  96886. */
  96887. getClassName(): string;
  96888. }
  96889. }
  96890. declare module BABYLON {
  96891. /**
  96892. * Manage the keyboard inputs to control the movement of a follow camera.
  96893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96894. */
  96895. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96896. /**
  96897. * Defines the camera the input is attached to.
  96898. */
  96899. camera: FollowCamera;
  96900. /**
  96901. * Defines the list of key codes associated with the up action (increase heightOffset)
  96902. */
  96903. keysHeightOffsetIncr: number[];
  96904. /**
  96905. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96906. */
  96907. keysHeightOffsetDecr: number[];
  96908. /**
  96909. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96910. */
  96911. keysHeightOffsetModifierAlt: boolean;
  96912. /**
  96913. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96914. */
  96915. keysHeightOffsetModifierCtrl: boolean;
  96916. /**
  96917. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96918. */
  96919. keysHeightOffsetModifierShift: boolean;
  96920. /**
  96921. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96922. */
  96923. keysRotationOffsetIncr: number[];
  96924. /**
  96925. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96926. */
  96927. keysRotationOffsetDecr: number[];
  96928. /**
  96929. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96930. */
  96931. keysRotationOffsetModifierAlt: boolean;
  96932. /**
  96933. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96934. */
  96935. keysRotationOffsetModifierCtrl: boolean;
  96936. /**
  96937. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96938. */
  96939. keysRotationOffsetModifierShift: boolean;
  96940. /**
  96941. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96942. */
  96943. keysRadiusIncr: number[];
  96944. /**
  96945. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96946. */
  96947. keysRadiusDecr: number[];
  96948. /**
  96949. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96950. */
  96951. keysRadiusModifierAlt: boolean;
  96952. /**
  96953. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96954. */
  96955. keysRadiusModifierCtrl: boolean;
  96956. /**
  96957. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96958. */
  96959. keysRadiusModifierShift: boolean;
  96960. /**
  96961. * Defines the rate of change of heightOffset.
  96962. */
  96963. heightSensibility: number;
  96964. /**
  96965. * Defines the rate of change of rotationOffset.
  96966. */
  96967. rotationSensibility: number;
  96968. /**
  96969. * Defines the rate of change of radius.
  96970. */
  96971. radiusSensibility: number;
  96972. private _keys;
  96973. private _ctrlPressed;
  96974. private _altPressed;
  96975. private _shiftPressed;
  96976. private _onCanvasBlurObserver;
  96977. private _onKeyboardObserver;
  96978. private _engine;
  96979. private _scene;
  96980. /**
  96981. * Attach the input controls to a specific dom element to get the input from.
  96982. * @param element Defines the element the controls should be listened from
  96983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96984. */
  96985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96986. /**
  96987. * Detach the current controls from the specified dom element.
  96988. * @param element Defines the element to stop listening the inputs from
  96989. */
  96990. detachControl(element: Nullable<HTMLElement>): void;
  96991. /**
  96992. * Update the current camera state depending on the inputs that have been used this frame.
  96993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96994. */
  96995. checkInputs(): void;
  96996. /**
  96997. * Gets the class name of the current input.
  96998. * @returns the class name
  96999. */
  97000. getClassName(): string;
  97001. /**
  97002. * Get the friendly name associated with the input class.
  97003. * @returns the input friendly name
  97004. */
  97005. getSimpleName(): string;
  97006. /**
  97007. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97008. * allow modification of the heightOffset value.
  97009. */
  97010. private _modifierHeightOffset;
  97011. /**
  97012. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97013. * allow modification of the rotationOffset value.
  97014. */
  97015. private _modifierRotationOffset;
  97016. /**
  97017. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97018. * allow modification of the radius value.
  97019. */
  97020. private _modifierRadius;
  97021. }
  97022. }
  97023. declare module BABYLON {
  97024. interface FreeCameraInputsManager {
  97025. /**
  97026. * @hidden
  97027. */
  97028. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  97029. /**
  97030. * Add orientation input support to the input manager.
  97031. * @returns the current input manager
  97032. */
  97033. addDeviceOrientation(): FreeCameraInputsManager;
  97034. }
  97035. /**
  97036. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  97037. * Screen rotation is taken into account.
  97038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97039. */
  97040. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  97041. private _camera;
  97042. private _screenOrientationAngle;
  97043. private _constantTranform;
  97044. private _screenQuaternion;
  97045. private _alpha;
  97046. private _beta;
  97047. private _gamma;
  97048. /**
  97049. * @hidden
  97050. */
  97051. _onDeviceOrientationChangedObservable: Observable<void>;
  97052. /**
  97053. * Instantiates a new input
  97054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97055. */
  97056. constructor();
  97057. /**
  97058. * Define the camera controlled by the input.
  97059. */
  97060. camera: FreeCamera;
  97061. /**
  97062. * Attach the input controls to a specific dom element to get the input from.
  97063. * @param element Defines the element the controls should be listened from
  97064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97065. */
  97066. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97067. private _orientationChanged;
  97068. private _deviceOrientation;
  97069. /**
  97070. * Detach the current controls from the specified dom element.
  97071. * @param element Defines the element to stop listening the inputs from
  97072. */
  97073. detachControl(element: Nullable<HTMLElement>): void;
  97074. /**
  97075. * Update the current camera state depending on the inputs that have been used this frame.
  97076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97077. */
  97078. checkInputs(): void;
  97079. /**
  97080. * Gets the class name of the current intput.
  97081. * @returns the class name
  97082. */
  97083. getClassName(): string;
  97084. /**
  97085. * Get the friendly name associated with the input class.
  97086. * @returns the input friendly name
  97087. */
  97088. getSimpleName(): string;
  97089. }
  97090. }
  97091. declare module BABYLON {
  97092. /**
  97093. * Manage the gamepad inputs to control a free camera.
  97094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97095. */
  97096. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  97097. /**
  97098. * Define the camera the input is attached to.
  97099. */
  97100. camera: FreeCamera;
  97101. /**
  97102. * Define the Gamepad controlling the input
  97103. */
  97104. gamepad: Nullable<Gamepad>;
  97105. /**
  97106. * Defines the gamepad rotation sensiblity.
  97107. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97108. */
  97109. gamepadAngularSensibility: number;
  97110. /**
  97111. * Defines the gamepad move sensiblity.
  97112. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97113. */
  97114. gamepadMoveSensibility: number;
  97115. private _onGamepadConnectedObserver;
  97116. private _onGamepadDisconnectedObserver;
  97117. private _cameraTransform;
  97118. private _deltaTransform;
  97119. private _vector3;
  97120. private _vector2;
  97121. /**
  97122. * Attach the input controls to a specific dom element to get the input from.
  97123. * @param element Defines the element the controls should be listened from
  97124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97125. */
  97126. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97127. /**
  97128. * Detach the current controls from the specified dom element.
  97129. * @param element Defines the element to stop listening the inputs from
  97130. */
  97131. detachControl(element: Nullable<HTMLElement>): void;
  97132. /**
  97133. * Update the current camera state depending on the inputs that have been used this frame.
  97134. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97135. */
  97136. checkInputs(): void;
  97137. /**
  97138. * Gets the class name of the current intput.
  97139. * @returns the class name
  97140. */
  97141. getClassName(): string;
  97142. /**
  97143. * Get the friendly name associated with the input class.
  97144. * @returns the input friendly name
  97145. */
  97146. getSimpleName(): string;
  97147. }
  97148. }
  97149. declare module BABYLON {
  97150. /**
  97151. * Defines the potential axis of a Joystick
  97152. */
  97153. export enum JoystickAxis {
  97154. /** X axis */
  97155. X = 0,
  97156. /** Y axis */
  97157. Y = 1,
  97158. /** Z axis */
  97159. Z = 2
  97160. }
  97161. /**
  97162. * Class used to define virtual joystick (used in touch mode)
  97163. */
  97164. export class VirtualJoystick {
  97165. /**
  97166. * Gets or sets a boolean indicating that left and right values must be inverted
  97167. */
  97168. reverseLeftRight: boolean;
  97169. /**
  97170. * Gets or sets a boolean indicating that up and down values must be inverted
  97171. */
  97172. reverseUpDown: boolean;
  97173. /**
  97174. * Gets the offset value for the position (ie. the change of the position value)
  97175. */
  97176. deltaPosition: Vector3;
  97177. /**
  97178. * Gets a boolean indicating if the virtual joystick was pressed
  97179. */
  97180. pressed: boolean;
  97181. /**
  97182. * Canvas the virtual joystick will render onto, default z-index of this is 5
  97183. */
  97184. static Canvas: Nullable<HTMLCanvasElement>;
  97185. private static _globalJoystickIndex;
  97186. private static vjCanvasContext;
  97187. private static vjCanvasWidth;
  97188. private static vjCanvasHeight;
  97189. private static halfWidth;
  97190. private _action;
  97191. private _axisTargetedByLeftAndRight;
  97192. private _axisTargetedByUpAndDown;
  97193. private _joystickSensibility;
  97194. private _inversedSensibility;
  97195. private _joystickPointerID;
  97196. private _joystickColor;
  97197. private _joystickPointerPos;
  97198. private _joystickPreviousPointerPos;
  97199. private _joystickPointerStartPos;
  97200. private _deltaJoystickVector;
  97201. private _leftJoystick;
  97202. private _touches;
  97203. private _onPointerDownHandlerRef;
  97204. private _onPointerMoveHandlerRef;
  97205. private _onPointerUpHandlerRef;
  97206. private _onResize;
  97207. /**
  97208. * Creates a new virtual joystick
  97209. * @param leftJoystick defines that the joystick is for left hand (false by default)
  97210. */
  97211. constructor(leftJoystick?: boolean);
  97212. /**
  97213. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  97214. * @param newJoystickSensibility defines the new sensibility
  97215. */
  97216. setJoystickSensibility(newJoystickSensibility: number): void;
  97217. private _onPointerDown;
  97218. private _onPointerMove;
  97219. private _onPointerUp;
  97220. /**
  97221. * Change the color of the virtual joystick
  97222. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  97223. */
  97224. setJoystickColor(newColor: string): void;
  97225. /**
  97226. * Defines a callback to call when the joystick is touched
  97227. * @param action defines the callback
  97228. */
  97229. setActionOnTouch(action: () => any): void;
  97230. /**
  97231. * Defines which axis you'd like to control for left & right
  97232. * @param axis defines the axis to use
  97233. */
  97234. setAxisForLeftRight(axis: JoystickAxis): void;
  97235. /**
  97236. * Defines which axis you'd like to control for up & down
  97237. * @param axis defines the axis to use
  97238. */
  97239. setAxisForUpDown(axis: JoystickAxis): void;
  97240. private _drawVirtualJoystick;
  97241. /**
  97242. * Release internal HTML canvas
  97243. */
  97244. releaseCanvas(): void;
  97245. }
  97246. }
  97247. declare module BABYLON {
  97248. interface FreeCameraInputsManager {
  97249. /**
  97250. * Add virtual joystick input support to the input manager.
  97251. * @returns the current input manager
  97252. */
  97253. addVirtualJoystick(): FreeCameraInputsManager;
  97254. }
  97255. /**
  97256. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  97257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97258. */
  97259. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  97260. /**
  97261. * Defines the camera the input is attached to.
  97262. */
  97263. camera: FreeCamera;
  97264. private _leftjoystick;
  97265. private _rightjoystick;
  97266. /**
  97267. * Gets the left stick of the virtual joystick.
  97268. * @returns The virtual Joystick
  97269. */
  97270. getLeftJoystick(): VirtualJoystick;
  97271. /**
  97272. * Gets the right stick of the virtual joystick.
  97273. * @returns The virtual Joystick
  97274. */
  97275. getRightJoystick(): VirtualJoystick;
  97276. /**
  97277. * Update the current camera state depending on the inputs that have been used this frame.
  97278. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97279. */
  97280. checkInputs(): void;
  97281. /**
  97282. * Attach the input controls to a specific dom element to get the input from.
  97283. * @param element Defines the element the controls should be listened from
  97284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97285. */
  97286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97287. /**
  97288. * Detach the current controls from the specified dom element.
  97289. * @param element Defines the element to stop listening the inputs from
  97290. */
  97291. detachControl(element: Nullable<HTMLElement>): void;
  97292. /**
  97293. * Gets the class name of the current intput.
  97294. * @returns the class name
  97295. */
  97296. getClassName(): string;
  97297. /**
  97298. * Get the friendly name associated with the input class.
  97299. * @returns the input friendly name
  97300. */
  97301. getSimpleName(): string;
  97302. }
  97303. }
  97304. declare module BABYLON {
  97305. /**
  97306. * This represents a FPS type of camera controlled by touch.
  97307. * This is like a universal camera minus the Gamepad controls.
  97308. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97309. */
  97310. export class TouchCamera extends FreeCamera {
  97311. /**
  97312. * Defines the touch sensibility for rotation.
  97313. * The higher the faster.
  97314. */
  97315. touchAngularSensibility: number;
  97316. /**
  97317. * Defines the touch sensibility for move.
  97318. * The higher the faster.
  97319. */
  97320. touchMoveSensibility: number;
  97321. /**
  97322. * Instantiates a new touch camera.
  97323. * This represents a FPS type of camera controlled by touch.
  97324. * This is like a universal camera minus the Gamepad controls.
  97325. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97326. * @param name Define the name of the camera in the scene
  97327. * @param position Define the start position of the camera in the scene
  97328. * @param scene Define the scene the camera belongs to
  97329. */
  97330. constructor(name: string, position: Vector3, scene: Scene);
  97331. /**
  97332. * Gets the current object class name.
  97333. * @return the class name
  97334. */
  97335. getClassName(): string;
  97336. /** @hidden */
  97337. _setupInputs(): void;
  97338. }
  97339. }
  97340. declare module BABYLON {
  97341. /**
  97342. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  97343. * being tilted forward or back and left or right.
  97344. */
  97345. export class DeviceOrientationCamera extends FreeCamera {
  97346. private _initialQuaternion;
  97347. private _quaternionCache;
  97348. private _tmpDragQuaternion;
  97349. /**
  97350. * Creates a new device orientation camera
  97351. * @param name The name of the camera
  97352. * @param position The start position camera
  97353. * @param scene The scene the camera belongs to
  97354. */
  97355. constructor(name: string, position: Vector3, scene: Scene);
  97356. /**
  97357. * @hidden
  97358. * Disabled pointer input on first orientation sensor update (Default: true)
  97359. */
  97360. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  97361. private _dragFactor;
  97362. /**
  97363. * Enabled turning on the y axis when the orientation sensor is active
  97364. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  97365. */
  97366. enableHorizontalDragging(dragFactor?: number): void;
  97367. /**
  97368. * Gets the current instance class name ("DeviceOrientationCamera").
  97369. * This helps avoiding instanceof at run time.
  97370. * @returns the class name
  97371. */
  97372. getClassName(): string;
  97373. /**
  97374. * @hidden
  97375. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  97376. */
  97377. _checkInputs(): void;
  97378. /**
  97379. * Reset the camera to its default orientation on the specified axis only.
  97380. * @param axis The axis to reset
  97381. */
  97382. resetToCurrentRotation(axis?: Axis): void;
  97383. }
  97384. }
  97385. declare module BABYLON {
  97386. /**
  97387. * 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,
  97388. * which still works and will still be found in many Playgrounds.
  97389. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97390. */
  97391. export class UniversalCamera extends TouchCamera {
  97392. /**
  97393. * Defines the gamepad rotation sensiblity.
  97394. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97395. */
  97396. gamepadAngularSensibility: number;
  97397. /**
  97398. * Defines the gamepad move sensiblity.
  97399. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97400. */
  97401. gamepadMoveSensibility: number;
  97402. /**
  97403. * 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,
  97404. * which still works and will still be found in many Playgrounds.
  97405. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97406. * @param name Define the name of the camera in the scene
  97407. * @param position Define the start position of the camera in the scene
  97408. * @param scene Define the scene the camera belongs to
  97409. */
  97410. constructor(name: string, position: Vector3, scene: Scene);
  97411. /**
  97412. * Gets the current object class name.
  97413. * @return the class name
  97414. */
  97415. getClassName(): string;
  97416. }
  97417. }
  97418. declare module BABYLON {
  97419. /**
  97420. * This represents a FPS type of camera. This is only here for back compat purpose.
  97421. * Please use the UniversalCamera instead as both are identical.
  97422. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97423. */
  97424. export class GamepadCamera extends UniversalCamera {
  97425. /**
  97426. * Instantiates a new Gamepad Camera
  97427. * This represents a FPS type of camera. This is only here for back compat purpose.
  97428. * Please use the UniversalCamera instead as both are identical.
  97429. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97430. * @param name Define the name of the camera in the scene
  97431. * @param position Define the start position of the camera in the scene
  97432. * @param scene Define the scene the camera belongs to
  97433. */
  97434. constructor(name: string, position: Vector3, scene: Scene);
  97435. /**
  97436. * Gets the current object class name.
  97437. * @return the class name
  97438. */
  97439. getClassName(): string;
  97440. }
  97441. }
  97442. declare module BABYLON {
  97443. /** @hidden */
  97444. export var passPixelShader: {
  97445. name: string;
  97446. shader: string;
  97447. };
  97448. }
  97449. declare module BABYLON {
  97450. /** @hidden */
  97451. export var passCubePixelShader: {
  97452. name: string;
  97453. shader: string;
  97454. };
  97455. }
  97456. declare module BABYLON {
  97457. /**
  97458. * PassPostProcess which produces an output the same as it's input
  97459. */
  97460. export class PassPostProcess extends PostProcess {
  97461. /**
  97462. * Creates the PassPostProcess
  97463. * @param name The name of the effect.
  97464. * @param options The required width/height ratio to downsize to before computing the render pass.
  97465. * @param camera The camera to apply the render pass to.
  97466. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97467. * @param engine The engine which the post process will be applied. (default: current engine)
  97468. * @param reusable If the post process can be reused on the same frame. (default: false)
  97469. * @param textureType The type of texture to be used when performing the post processing.
  97470. * @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)
  97471. */
  97472. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97473. }
  97474. /**
  97475. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  97476. */
  97477. export class PassCubePostProcess extends PostProcess {
  97478. private _face;
  97479. /**
  97480. * Gets or sets the cube face to display.
  97481. * * 0 is +X
  97482. * * 1 is -X
  97483. * * 2 is +Y
  97484. * * 3 is -Y
  97485. * * 4 is +Z
  97486. * * 5 is -Z
  97487. */
  97488. face: number;
  97489. /**
  97490. * Creates the PassCubePostProcess
  97491. * @param name The name of the effect.
  97492. * @param options The required width/height ratio to downsize to before computing the render pass.
  97493. * @param camera The camera to apply the render pass to.
  97494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97495. * @param engine The engine which the post process will be applied. (default: current engine)
  97496. * @param reusable If the post process can be reused on the same frame. (default: false)
  97497. * @param textureType The type of texture to be used when performing the post processing.
  97498. * @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)
  97499. */
  97500. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97501. }
  97502. }
  97503. declare module BABYLON {
  97504. /** @hidden */
  97505. export var anaglyphPixelShader: {
  97506. name: string;
  97507. shader: string;
  97508. };
  97509. }
  97510. declare module BABYLON {
  97511. /**
  97512. * Postprocess used to generate anaglyphic rendering
  97513. */
  97514. export class AnaglyphPostProcess extends PostProcess {
  97515. private _passedProcess;
  97516. /**
  97517. * Creates a new AnaglyphPostProcess
  97518. * @param name defines postprocess name
  97519. * @param options defines creation options or target ratio scale
  97520. * @param rigCameras defines cameras using this postprocess
  97521. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  97522. * @param engine defines hosting engine
  97523. * @param reusable defines if the postprocess will be reused multiple times per frame
  97524. */
  97525. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  97526. }
  97527. }
  97528. declare module BABYLON {
  97529. /**
  97530. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  97531. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97532. */
  97533. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  97534. /**
  97535. * Creates a new AnaglyphArcRotateCamera
  97536. * @param name defines camera name
  97537. * @param alpha defines alpha angle (in radians)
  97538. * @param beta defines beta angle (in radians)
  97539. * @param radius defines radius
  97540. * @param target defines camera target
  97541. * @param interaxialDistance defines distance between each color axis
  97542. * @param scene defines the hosting scene
  97543. */
  97544. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  97545. /**
  97546. * Gets camera class name
  97547. * @returns AnaglyphArcRotateCamera
  97548. */
  97549. getClassName(): string;
  97550. }
  97551. }
  97552. declare module BABYLON {
  97553. /**
  97554. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  97555. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97556. */
  97557. export class AnaglyphFreeCamera extends FreeCamera {
  97558. /**
  97559. * Creates a new AnaglyphFreeCamera
  97560. * @param name defines camera name
  97561. * @param position defines initial position
  97562. * @param interaxialDistance defines distance between each color axis
  97563. * @param scene defines the hosting scene
  97564. */
  97565. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97566. /**
  97567. * Gets camera class name
  97568. * @returns AnaglyphFreeCamera
  97569. */
  97570. getClassName(): string;
  97571. }
  97572. }
  97573. declare module BABYLON {
  97574. /**
  97575. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  97576. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97577. */
  97578. export class AnaglyphGamepadCamera extends GamepadCamera {
  97579. /**
  97580. * Creates a new AnaglyphGamepadCamera
  97581. * @param name defines camera name
  97582. * @param position defines initial position
  97583. * @param interaxialDistance defines distance between each color axis
  97584. * @param scene defines the hosting scene
  97585. */
  97586. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97587. /**
  97588. * Gets camera class name
  97589. * @returns AnaglyphGamepadCamera
  97590. */
  97591. getClassName(): string;
  97592. }
  97593. }
  97594. declare module BABYLON {
  97595. /**
  97596. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  97597. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97598. */
  97599. export class AnaglyphUniversalCamera extends UniversalCamera {
  97600. /**
  97601. * Creates a new AnaglyphUniversalCamera
  97602. * @param name defines camera name
  97603. * @param position defines initial position
  97604. * @param interaxialDistance defines distance between each color axis
  97605. * @param scene defines the hosting scene
  97606. */
  97607. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97608. /**
  97609. * Gets camera class name
  97610. * @returns AnaglyphUniversalCamera
  97611. */
  97612. getClassName(): string;
  97613. }
  97614. }
  97615. declare module BABYLON {
  97616. /** @hidden */
  97617. export var stereoscopicInterlacePixelShader: {
  97618. name: string;
  97619. shader: string;
  97620. };
  97621. }
  97622. declare module BABYLON {
  97623. /**
  97624. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  97625. */
  97626. export class StereoscopicInterlacePostProcess extends PostProcess {
  97627. private _stepSize;
  97628. private _passedProcess;
  97629. /**
  97630. * Initializes a StereoscopicInterlacePostProcess
  97631. * @param name The name of the effect.
  97632. * @param rigCameras The rig cameras to be appled to the post process
  97633. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  97634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97635. * @param engine The engine which the post process will be applied. (default: current engine)
  97636. * @param reusable If the post process can be reused on the same frame. (default: false)
  97637. */
  97638. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  97639. }
  97640. }
  97641. declare module BABYLON {
  97642. /**
  97643. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  97644. * @see http://doc.babylonjs.com/features/cameras
  97645. */
  97646. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  97647. /**
  97648. * Creates a new StereoscopicArcRotateCamera
  97649. * @param name defines camera name
  97650. * @param alpha defines alpha angle (in radians)
  97651. * @param beta defines beta angle (in radians)
  97652. * @param radius defines radius
  97653. * @param target defines camera target
  97654. * @param interaxialDistance defines distance between each color axis
  97655. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97656. * @param scene defines the hosting scene
  97657. */
  97658. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97659. /**
  97660. * Gets camera class name
  97661. * @returns StereoscopicArcRotateCamera
  97662. */
  97663. getClassName(): string;
  97664. }
  97665. }
  97666. declare module BABYLON {
  97667. /**
  97668. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  97669. * @see http://doc.babylonjs.com/features/cameras
  97670. */
  97671. export class StereoscopicFreeCamera extends FreeCamera {
  97672. /**
  97673. * Creates a new StereoscopicFreeCamera
  97674. * @param name defines camera name
  97675. * @param position defines initial position
  97676. * @param interaxialDistance defines distance between each color axis
  97677. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97678. * @param scene defines the hosting scene
  97679. */
  97680. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97681. /**
  97682. * Gets camera class name
  97683. * @returns StereoscopicFreeCamera
  97684. */
  97685. getClassName(): string;
  97686. }
  97687. }
  97688. declare module BABYLON {
  97689. /**
  97690. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  97691. * @see http://doc.babylonjs.com/features/cameras
  97692. */
  97693. export class StereoscopicGamepadCamera extends GamepadCamera {
  97694. /**
  97695. * Creates a new StereoscopicGamepadCamera
  97696. * @param name defines camera name
  97697. * @param position defines initial position
  97698. * @param interaxialDistance defines distance between each color axis
  97699. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97700. * @param scene defines the hosting scene
  97701. */
  97702. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97703. /**
  97704. * Gets camera class name
  97705. * @returns StereoscopicGamepadCamera
  97706. */
  97707. getClassName(): string;
  97708. }
  97709. }
  97710. declare module BABYLON {
  97711. /**
  97712. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  97713. * @see http://doc.babylonjs.com/features/cameras
  97714. */
  97715. export class StereoscopicUniversalCamera extends UniversalCamera {
  97716. /**
  97717. * Creates a new StereoscopicUniversalCamera
  97718. * @param name defines camera name
  97719. * @param position defines initial position
  97720. * @param interaxialDistance defines distance between each color axis
  97721. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97722. * @param scene defines the hosting scene
  97723. */
  97724. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97725. /**
  97726. * Gets camera class name
  97727. * @returns StereoscopicUniversalCamera
  97728. */
  97729. getClassName(): string;
  97730. }
  97731. }
  97732. declare module BABYLON {
  97733. /**
  97734. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97735. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97736. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97737. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97738. */
  97739. export class VirtualJoysticksCamera extends FreeCamera {
  97740. /**
  97741. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  97742. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97743. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97744. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97745. * @param name Define the name of the camera in the scene
  97746. * @param position Define the start position of the camera in the scene
  97747. * @param scene Define the scene the camera belongs to
  97748. */
  97749. constructor(name: string, position: Vector3, scene: Scene);
  97750. /**
  97751. * Gets the current object class name.
  97752. * @return the class name
  97753. */
  97754. getClassName(): string;
  97755. }
  97756. }
  97757. declare module BABYLON {
  97758. /**
  97759. * This represents all the required metrics to create a VR camera.
  97760. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  97761. */
  97762. export class VRCameraMetrics {
  97763. /**
  97764. * Define the horizontal resolution off the screen.
  97765. */
  97766. hResolution: number;
  97767. /**
  97768. * Define the vertical resolution off the screen.
  97769. */
  97770. vResolution: number;
  97771. /**
  97772. * Define the horizontal screen size.
  97773. */
  97774. hScreenSize: number;
  97775. /**
  97776. * Define the vertical screen size.
  97777. */
  97778. vScreenSize: number;
  97779. /**
  97780. * Define the vertical screen center position.
  97781. */
  97782. vScreenCenter: number;
  97783. /**
  97784. * Define the distance of the eyes to the screen.
  97785. */
  97786. eyeToScreenDistance: number;
  97787. /**
  97788. * Define the distance between both lenses
  97789. */
  97790. lensSeparationDistance: number;
  97791. /**
  97792. * Define the distance between both viewer's eyes.
  97793. */
  97794. interpupillaryDistance: number;
  97795. /**
  97796. * Define the distortion factor of the VR postprocess.
  97797. * Please, touch with care.
  97798. */
  97799. distortionK: number[];
  97800. /**
  97801. * Define the chromatic aberration correction factors for the VR post process.
  97802. */
  97803. chromaAbCorrection: number[];
  97804. /**
  97805. * Define the scale factor of the post process.
  97806. * The smaller the better but the slower.
  97807. */
  97808. postProcessScaleFactor: number;
  97809. /**
  97810. * Define an offset for the lens center.
  97811. */
  97812. lensCenterOffset: number;
  97813. /**
  97814. * Define if the current vr camera should compensate the distortion of the lense or not.
  97815. */
  97816. compensateDistortion: boolean;
  97817. /**
  97818. * Defines if multiview should be enabled when rendering (Default: false)
  97819. */
  97820. multiviewEnabled: boolean;
  97821. /**
  97822. * Gets the rendering aspect ratio based on the provided resolutions.
  97823. */
  97824. readonly aspectRatio: number;
  97825. /**
  97826. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  97827. */
  97828. readonly aspectRatioFov: number;
  97829. /**
  97830. * @hidden
  97831. */
  97832. readonly leftHMatrix: Matrix;
  97833. /**
  97834. * @hidden
  97835. */
  97836. readonly rightHMatrix: Matrix;
  97837. /**
  97838. * @hidden
  97839. */
  97840. readonly leftPreViewMatrix: Matrix;
  97841. /**
  97842. * @hidden
  97843. */
  97844. readonly rightPreViewMatrix: Matrix;
  97845. /**
  97846. * Get the default VRMetrics based on the most generic setup.
  97847. * @returns the default vr metrics
  97848. */
  97849. static GetDefault(): VRCameraMetrics;
  97850. }
  97851. }
  97852. declare module BABYLON {
  97853. /** @hidden */
  97854. export var vrDistortionCorrectionPixelShader: {
  97855. name: string;
  97856. shader: string;
  97857. };
  97858. }
  97859. declare module BABYLON {
  97860. /**
  97861. * VRDistortionCorrectionPostProcess used for mobile VR
  97862. */
  97863. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97864. private _isRightEye;
  97865. private _distortionFactors;
  97866. private _postProcessScaleFactor;
  97867. private _lensCenterOffset;
  97868. private _scaleIn;
  97869. private _scaleFactor;
  97870. private _lensCenter;
  97871. /**
  97872. * Initializes the VRDistortionCorrectionPostProcess
  97873. * @param name The name of the effect.
  97874. * @param camera The camera to apply the render pass to.
  97875. * @param isRightEye If this is for the right eye distortion
  97876. * @param vrMetrics All the required metrics for the VR camera
  97877. */
  97878. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97879. }
  97880. }
  97881. declare module BABYLON {
  97882. /**
  97883. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97884. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97885. */
  97886. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97887. /**
  97888. * Creates a new VRDeviceOrientationArcRotateCamera
  97889. * @param name defines camera name
  97890. * @param alpha defines the camera rotation along the logitudinal axis
  97891. * @param beta defines the camera rotation along the latitudinal axis
  97892. * @param radius defines the camera distance from its target
  97893. * @param target defines the camera target
  97894. * @param scene defines the scene the camera belongs to
  97895. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97896. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97897. */
  97898. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97899. /**
  97900. * Gets camera class name
  97901. * @returns VRDeviceOrientationArcRotateCamera
  97902. */
  97903. getClassName(): string;
  97904. }
  97905. }
  97906. declare module BABYLON {
  97907. /**
  97908. * Camera used to simulate VR rendering (based on FreeCamera)
  97909. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97910. */
  97911. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97912. /**
  97913. * Creates a new VRDeviceOrientationFreeCamera
  97914. * @param name defines camera name
  97915. * @param position defines the start position of the camera
  97916. * @param scene defines the scene the camera belongs to
  97917. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97918. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97919. */
  97920. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97921. /**
  97922. * Gets camera class name
  97923. * @returns VRDeviceOrientationFreeCamera
  97924. */
  97925. getClassName(): string;
  97926. }
  97927. }
  97928. declare module BABYLON {
  97929. /**
  97930. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97931. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97932. */
  97933. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97934. /**
  97935. * Creates a new VRDeviceOrientationGamepadCamera
  97936. * @param name defines camera name
  97937. * @param position defines the start position of the camera
  97938. * @param scene defines the scene the camera belongs to
  97939. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97940. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97941. */
  97942. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97943. /**
  97944. * Gets camera class name
  97945. * @returns VRDeviceOrientationGamepadCamera
  97946. */
  97947. getClassName(): string;
  97948. }
  97949. }
  97950. declare module BABYLON {
  97951. /**
  97952. * Defines supported buttons for XBox360 compatible gamepads
  97953. */
  97954. export enum Xbox360Button {
  97955. /** A */
  97956. A = 0,
  97957. /** B */
  97958. B = 1,
  97959. /** X */
  97960. X = 2,
  97961. /** Y */
  97962. Y = 3,
  97963. /** Start */
  97964. Start = 4,
  97965. /** Back */
  97966. Back = 5,
  97967. /** Left button */
  97968. LB = 6,
  97969. /** Right button */
  97970. RB = 7,
  97971. /** Left stick */
  97972. LeftStick = 8,
  97973. /** Right stick */
  97974. RightStick = 9
  97975. }
  97976. /** Defines values for XBox360 DPad */
  97977. export enum Xbox360Dpad {
  97978. /** Up */
  97979. Up = 0,
  97980. /** Down */
  97981. Down = 1,
  97982. /** Left */
  97983. Left = 2,
  97984. /** Right */
  97985. Right = 3
  97986. }
  97987. /**
  97988. * Defines a XBox360 gamepad
  97989. */
  97990. export class Xbox360Pad extends Gamepad {
  97991. private _leftTrigger;
  97992. private _rightTrigger;
  97993. private _onlefttriggerchanged;
  97994. private _onrighttriggerchanged;
  97995. private _onbuttondown;
  97996. private _onbuttonup;
  97997. private _ondpaddown;
  97998. private _ondpadup;
  97999. /** Observable raised when a button is pressed */
  98000. onButtonDownObservable: Observable<Xbox360Button>;
  98001. /** Observable raised when a button is released */
  98002. onButtonUpObservable: Observable<Xbox360Button>;
  98003. /** Observable raised when a pad is pressed */
  98004. onPadDownObservable: Observable<Xbox360Dpad>;
  98005. /** Observable raised when a pad is released */
  98006. onPadUpObservable: Observable<Xbox360Dpad>;
  98007. private _buttonA;
  98008. private _buttonB;
  98009. private _buttonX;
  98010. private _buttonY;
  98011. private _buttonBack;
  98012. private _buttonStart;
  98013. private _buttonLB;
  98014. private _buttonRB;
  98015. private _buttonLeftStick;
  98016. private _buttonRightStick;
  98017. private _dPadUp;
  98018. private _dPadDown;
  98019. private _dPadLeft;
  98020. private _dPadRight;
  98021. private _isXboxOnePad;
  98022. /**
  98023. * Creates a new XBox360 gamepad object
  98024. * @param id defines the id of this gamepad
  98025. * @param index defines its index
  98026. * @param gamepad defines the internal HTML gamepad object
  98027. * @param xboxOne defines if it is a XBox One gamepad
  98028. */
  98029. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  98030. /**
  98031. * Defines the callback to call when left trigger is pressed
  98032. * @param callback defines the callback to use
  98033. */
  98034. onlefttriggerchanged(callback: (value: number) => void): void;
  98035. /**
  98036. * Defines the callback to call when right trigger is pressed
  98037. * @param callback defines the callback to use
  98038. */
  98039. onrighttriggerchanged(callback: (value: number) => void): void;
  98040. /**
  98041. * Gets the left trigger value
  98042. */
  98043. /**
  98044. * Sets the left trigger value
  98045. */
  98046. leftTrigger: number;
  98047. /**
  98048. * Gets the right trigger value
  98049. */
  98050. /**
  98051. * Sets the right trigger value
  98052. */
  98053. rightTrigger: number;
  98054. /**
  98055. * Defines the callback to call when a button is pressed
  98056. * @param callback defines the callback to use
  98057. */
  98058. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  98059. /**
  98060. * Defines the callback to call when a button is released
  98061. * @param callback defines the callback to use
  98062. */
  98063. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  98064. /**
  98065. * Defines the callback to call when a pad is pressed
  98066. * @param callback defines the callback to use
  98067. */
  98068. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  98069. /**
  98070. * Defines the callback to call when a pad is released
  98071. * @param callback defines the callback to use
  98072. */
  98073. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  98074. private _setButtonValue;
  98075. private _setDPadValue;
  98076. /**
  98077. * Gets the value of the `A` button
  98078. */
  98079. /**
  98080. * Sets the value of the `A` button
  98081. */
  98082. buttonA: number;
  98083. /**
  98084. * Gets the value of the `B` button
  98085. */
  98086. /**
  98087. * Sets the value of the `B` button
  98088. */
  98089. buttonB: number;
  98090. /**
  98091. * Gets the value of the `X` button
  98092. */
  98093. /**
  98094. * Sets the value of the `X` button
  98095. */
  98096. buttonX: number;
  98097. /**
  98098. * Gets the value of the `Y` button
  98099. */
  98100. /**
  98101. * Sets the value of the `Y` button
  98102. */
  98103. buttonY: number;
  98104. /**
  98105. * Gets the value of the `Start` button
  98106. */
  98107. /**
  98108. * Sets the value of the `Start` button
  98109. */
  98110. buttonStart: number;
  98111. /**
  98112. * Gets the value of the `Back` button
  98113. */
  98114. /**
  98115. * Sets the value of the `Back` button
  98116. */
  98117. buttonBack: number;
  98118. /**
  98119. * Gets the value of the `Left` button
  98120. */
  98121. /**
  98122. * Sets the value of the `Left` button
  98123. */
  98124. buttonLB: number;
  98125. /**
  98126. * Gets the value of the `Right` button
  98127. */
  98128. /**
  98129. * Sets the value of the `Right` button
  98130. */
  98131. buttonRB: number;
  98132. /**
  98133. * Gets the value of the Left joystick
  98134. */
  98135. /**
  98136. * Sets the value of the Left joystick
  98137. */
  98138. buttonLeftStick: number;
  98139. /**
  98140. * Gets the value of the Right joystick
  98141. */
  98142. /**
  98143. * Sets the value of the Right joystick
  98144. */
  98145. buttonRightStick: number;
  98146. /**
  98147. * Gets the value of D-pad up
  98148. */
  98149. /**
  98150. * Sets the value of D-pad up
  98151. */
  98152. dPadUp: number;
  98153. /**
  98154. * Gets the value of D-pad down
  98155. */
  98156. /**
  98157. * Sets the value of D-pad down
  98158. */
  98159. dPadDown: number;
  98160. /**
  98161. * Gets the value of D-pad left
  98162. */
  98163. /**
  98164. * Sets the value of D-pad left
  98165. */
  98166. dPadLeft: number;
  98167. /**
  98168. * Gets the value of D-pad right
  98169. */
  98170. /**
  98171. * Sets the value of D-pad right
  98172. */
  98173. dPadRight: number;
  98174. /**
  98175. * Force the gamepad to synchronize with device values
  98176. */
  98177. update(): void;
  98178. /**
  98179. * Disposes the gamepad
  98180. */
  98181. dispose(): void;
  98182. }
  98183. }
  98184. declare module BABYLON {
  98185. /**
  98186. * Base class of materials working in push mode in babylon JS
  98187. * @hidden
  98188. */
  98189. export class PushMaterial extends Material {
  98190. protected _activeEffect: Effect;
  98191. protected _normalMatrix: Matrix;
  98192. /**
  98193. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98194. * This means that the material can keep using a previous shader while a new one is being compiled.
  98195. * This is mostly used when shader parallel compilation is supported (true by default)
  98196. */
  98197. allowShaderHotSwapping: boolean;
  98198. constructor(name: string, scene: Scene);
  98199. getEffect(): Effect;
  98200. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98201. /**
  98202. * Binds the given world matrix to the active effect
  98203. *
  98204. * @param world the matrix to bind
  98205. */
  98206. bindOnlyWorldMatrix(world: Matrix): void;
  98207. /**
  98208. * Binds the given normal matrix to the active effect
  98209. *
  98210. * @param normalMatrix the matrix to bind
  98211. */
  98212. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98213. bind(world: Matrix, mesh?: Mesh): void;
  98214. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98215. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98216. }
  98217. }
  98218. declare module BABYLON {
  98219. /**
  98220. * This groups all the flags used to control the materials channel.
  98221. */
  98222. export class MaterialFlags {
  98223. private static _DiffuseTextureEnabled;
  98224. /**
  98225. * Are diffuse textures enabled in the application.
  98226. */
  98227. static DiffuseTextureEnabled: boolean;
  98228. private static _AmbientTextureEnabled;
  98229. /**
  98230. * Are ambient textures enabled in the application.
  98231. */
  98232. static AmbientTextureEnabled: boolean;
  98233. private static _OpacityTextureEnabled;
  98234. /**
  98235. * Are opacity textures enabled in the application.
  98236. */
  98237. static OpacityTextureEnabled: boolean;
  98238. private static _ReflectionTextureEnabled;
  98239. /**
  98240. * Are reflection textures enabled in the application.
  98241. */
  98242. static ReflectionTextureEnabled: boolean;
  98243. private static _EmissiveTextureEnabled;
  98244. /**
  98245. * Are emissive textures enabled in the application.
  98246. */
  98247. static EmissiveTextureEnabled: boolean;
  98248. private static _SpecularTextureEnabled;
  98249. /**
  98250. * Are specular textures enabled in the application.
  98251. */
  98252. static SpecularTextureEnabled: boolean;
  98253. private static _BumpTextureEnabled;
  98254. /**
  98255. * Are bump textures enabled in the application.
  98256. */
  98257. static BumpTextureEnabled: boolean;
  98258. private static _LightmapTextureEnabled;
  98259. /**
  98260. * Are lightmap textures enabled in the application.
  98261. */
  98262. static LightmapTextureEnabled: boolean;
  98263. private static _RefractionTextureEnabled;
  98264. /**
  98265. * Are refraction textures enabled in the application.
  98266. */
  98267. static RefractionTextureEnabled: boolean;
  98268. private static _ColorGradingTextureEnabled;
  98269. /**
  98270. * Are color grading textures enabled in the application.
  98271. */
  98272. static ColorGradingTextureEnabled: boolean;
  98273. private static _FresnelEnabled;
  98274. /**
  98275. * Are fresnels enabled in the application.
  98276. */
  98277. static FresnelEnabled: boolean;
  98278. private static _ClearCoatTextureEnabled;
  98279. /**
  98280. * Are clear coat textures enabled in the application.
  98281. */
  98282. static ClearCoatTextureEnabled: boolean;
  98283. private static _ClearCoatBumpTextureEnabled;
  98284. /**
  98285. * Are clear coat bump textures enabled in the application.
  98286. */
  98287. static ClearCoatBumpTextureEnabled: boolean;
  98288. private static _ClearCoatTintTextureEnabled;
  98289. /**
  98290. * Are clear coat tint textures enabled in the application.
  98291. */
  98292. static ClearCoatTintTextureEnabled: boolean;
  98293. private static _SheenTextureEnabled;
  98294. /**
  98295. * Are sheen textures enabled in the application.
  98296. */
  98297. static SheenTextureEnabled: boolean;
  98298. private static _AnisotropicTextureEnabled;
  98299. /**
  98300. * Are anisotropic textures enabled in the application.
  98301. */
  98302. static AnisotropicTextureEnabled: boolean;
  98303. private static _ThicknessTextureEnabled;
  98304. /**
  98305. * Are thickness textures enabled in the application.
  98306. */
  98307. static ThicknessTextureEnabled: boolean;
  98308. }
  98309. }
  98310. declare module BABYLON {
  98311. /** @hidden */
  98312. export var defaultFragmentDeclaration: {
  98313. name: string;
  98314. shader: string;
  98315. };
  98316. }
  98317. declare module BABYLON {
  98318. /** @hidden */
  98319. export var defaultUboDeclaration: {
  98320. name: string;
  98321. shader: string;
  98322. };
  98323. }
  98324. declare module BABYLON {
  98325. /** @hidden */
  98326. export var lightFragmentDeclaration: {
  98327. name: string;
  98328. shader: string;
  98329. };
  98330. }
  98331. declare module BABYLON {
  98332. /** @hidden */
  98333. export var lightUboDeclaration: {
  98334. name: string;
  98335. shader: string;
  98336. };
  98337. }
  98338. declare module BABYLON {
  98339. /** @hidden */
  98340. export var lightsFragmentFunctions: {
  98341. name: string;
  98342. shader: string;
  98343. };
  98344. }
  98345. declare module BABYLON {
  98346. /** @hidden */
  98347. export var shadowsFragmentFunctions: {
  98348. name: string;
  98349. shader: string;
  98350. };
  98351. }
  98352. declare module BABYLON {
  98353. /** @hidden */
  98354. export var fresnelFunction: {
  98355. name: string;
  98356. shader: string;
  98357. };
  98358. }
  98359. declare module BABYLON {
  98360. /** @hidden */
  98361. export var reflectionFunction: {
  98362. name: string;
  98363. shader: string;
  98364. };
  98365. }
  98366. declare module BABYLON {
  98367. /** @hidden */
  98368. export var bumpFragmentFunctions: {
  98369. name: string;
  98370. shader: string;
  98371. };
  98372. }
  98373. declare module BABYLON {
  98374. /** @hidden */
  98375. export var logDepthDeclaration: {
  98376. name: string;
  98377. shader: string;
  98378. };
  98379. }
  98380. declare module BABYLON {
  98381. /** @hidden */
  98382. export var bumpFragment: {
  98383. name: string;
  98384. shader: string;
  98385. };
  98386. }
  98387. declare module BABYLON {
  98388. /** @hidden */
  98389. export var depthPrePass: {
  98390. name: string;
  98391. shader: string;
  98392. };
  98393. }
  98394. declare module BABYLON {
  98395. /** @hidden */
  98396. export var lightFragment: {
  98397. name: string;
  98398. shader: string;
  98399. };
  98400. }
  98401. declare module BABYLON {
  98402. /** @hidden */
  98403. export var logDepthFragment: {
  98404. name: string;
  98405. shader: string;
  98406. };
  98407. }
  98408. declare module BABYLON {
  98409. /** @hidden */
  98410. export var defaultPixelShader: {
  98411. name: string;
  98412. shader: string;
  98413. };
  98414. }
  98415. declare module BABYLON {
  98416. /** @hidden */
  98417. export var defaultVertexDeclaration: {
  98418. name: string;
  98419. shader: string;
  98420. };
  98421. }
  98422. declare module BABYLON {
  98423. /** @hidden */
  98424. export var bumpVertexDeclaration: {
  98425. name: string;
  98426. shader: string;
  98427. };
  98428. }
  98429. declare module BABYLON {
  98430. /** @hidden */
  98431. export var bumpVertex: {
  98432. name: string;
  98433. shader: string;
  98434. };
  98435. }
  98436. declare module BABYLON {
  98437. /** @hidden */
  98438. export var fogVertex: {
  98439. name: string;
  98440. shader: string;
  98441. };
  98442. }
  98443. declare module BABYLON {
  98444. /** @hidden */
  98445. export var shadowsVertex: {
  98446. name: string;
  98447. shader: string;
  98448. };
  98449. }
  98450. declare module BABYLON {
  98451. /** @hidden */
  98452. export var pointCloudVertex: {
  98453. name: string;
  98454. shader: string;
  98455. };
  98456. }
  98457. declare module BABYLON {
  98458. /** @hidden */
  98459. export var logDepthVertex: {
  98460. name: string;
  98461. shader: string;
  98462. };
  98463. }
  98464. declare module BABYLON {
  98465. /** @hidden */
  98466. export var defaultVertexShader: {
  98467. name: string;
  98468. shader: string;
  98469. };
  98470. }
  98471. declare module BABYLON {
  98472. /** @hidden */
  98473. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98474. MAINUV1: boolean;
  98475. MAINUV2: boolean;
  98476. DIFFUSE: boolean;
  98477. DIFFUSEDIRECTUV: number;
  98478. AMBIENT: boolean;
  98479. AMBIENTDIRECTUV: number;
  98480. OPACITY: boolean;
  98481. OPACITYDIRECTUV: number;
  98482. OPACITYRGB: boolean;
  98483. REFLECTION: boolean;
  98484. EMISSIVE: boolean;
  98485. EMISSIVEDIRECTUV: number;
  98486. SPECULAR: boolean;
  98487. SPECULARDIRECTUV: number;
  98488. BUMP: boolean;
  98489. BUMPDIRECTUV: number;
  98490. PARALLAX: boolean;
  98491. PARALLAXOCCLUSION: boolean;
  98492. SPECULAROVERALPHA: boolean;
  98493. CLIPPLANE: boolean;
  98494. CLIPPLANE2: boolean;
  98495. CLIPPLANE3: boolean;
  98496. CLIPPLANE4: boolean;
  98497. ALPHATEST: boolean;
  98498. DEPTHPREPASS: boolean;
  98499. ALPHAFROMDIFFUSE: boolean;
  98500. POINTSIZE: boolean;
  98501. FOG: boolean;
  98502. SPECULARTERM: boolean;
  98503. DIFFUSEFRESNEL: boolean;
  98504. OPACITYFRESNEL: boolean;
  98505. REFLECTIONFRESNEL: boolean;
  98506. REFRACTIONFRESNEL: boolean;
  98507. EMISSIVEFRESNEL: boolean;
  98508. FRESNEL: boolean;
  98509. NORMAL: boolean;
  98510. UV1: boolean;
  98511. UV2: boolean;
  98512. VERTEXCOLOR: boolean;
  98513. VERTEXALPHA: boolean;
  98514. NUM_BONE_INFLUENCERS: number;
  98515. BonesPerMesh: number;
  98516. BONETEXTURE: boolean;
  98517. INSTANCES: boolean;
  98518. GLOSSINESS: boolean;
  98519. ROUGHNESS: boolean;
  98520. EMISSIVEASILLUMINATION: boolean;
  98521. LINKEMISSIVEWITHDIFFUSE: boolean;
  98522. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98523. LIGHTMAP: boolean;
  98524. LIGHTMAPDIRECTUV: number;
  98525. OBJECTSPACE_NORMALMAP: boolean;
  98526. USELIGHTMAPASSHADOWMAP: boolean;
  98527. REFLECTIONMAP_3D: boolean;
  98528. REFLECTIONMAP_SPHERICAL: boolean;
  98529. REFLECTIONMAP_PLANAR: boolean;
  98530. REFLECTIONMAP_CUBIC: boolean;
  98531. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98532. REFLECTIONMAP_PROJECTION: boolean;
  98533. REFLECTIONMAP_SKYBOX: boolean;
  98534. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98535. REFLECTIONMAP_EXPLICIT: boolean;
  98536. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98537. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98538. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98539. INVERTCUBICMAP: boolean;
  98540. LOGARITHMICDEPTH: boolean;
  98541. REFRACTION: boolean;
  98542. REFRACTIONMAP_3D: boolean;
  98543. REFLECTIONOVERALPHA: boolean;
  98544. TWOSIDEDLIGHTING: boolean;
  98545. SHADOWFLOAT: boolean;
  98546. MORPHTARGETS: boolean;
  98547. MORPHTARGETS_NORMAL: boolean;
  98548. MORPHTARGETS_TANGENT: boolean;
  98549. NUM_MORPH_INFLUENCERS: number;
  98550. NONUNIFORMSCALING: boolean;
  98551. PREMULTIPLYALPHA: boolean;
  98552. IMAGEPROCESSING: boolean;
  98553. VIGNETTE: boolean;
  98554. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98555. VIGNETTEBLENDMODEOPAQUE: boolean;
  98556. TONEMAPPING: boolean;
  98557. TONEMAPPING_ACES: boolean;
  98558. CONTRAST: boolean;
  98559. COLORCURVES: boolean;
  98560. COLORGRADING: boolean;
  98561. COLORGRADING3D: boolean;
  98562. SAMPLER3DGREENDEPTH: boolean;
  98563. SAMPLER3DBGRMAP: boolean;
  98564. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98565. MULTIVIEW: boolean;
  98566. /**
  98567. * If the reflection texture on this material is in linear color space
  98568. * @hidden
  98569. */
  98570. IS_REFLECTION_LINEAR: boolean;
  98571. /**
  98572. * If the refraction texture on this material is in linear color space
  98573. * @hidden
  98574. */
  98575. IS_REFRACTION_LINEAR: boolean;
  98576. EXPOSURE: boolean;
  98577. constructor();
  98578. setReflectionMode(modeToEnable: string): void;
  98579. }
  98580. /**
  98581. * This is the default material used in Babylon. It is the best trade off between quality
  98582. * and performances.
  98583. * @see http://doc.babylonjs.com/babylon101/materials
  98584. */
  98585. export class StandardMaterial extends PushMaterial {
  98586. private _diffuseTexture;
  98587. /**
  98588. * The basic texture of the material as viewed under a light.
  98589. */
  98590. diffuseTexture: Nullable<BaseTexture>;
  98591. private _ambientTexture;
  98592. /**
  98593. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98594. */
  98595. ambientTexture: Nullable<BaseTexture>;
  98596. private _opacityTexture;
  98597. /**
  98598. * Define the transparency of the material from a texture.
  98599. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98600. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98601. */
  98602. opacityTexture: Nullable<BaseTexture>;
  98603. private _reflectionTexture;
  98604. /**
  98605. * Define the texture used to display the reflection.
  98606. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98607. */
  98608. reflectionTexture: Nullable<BaseTexture>;
  98609. private _emissiveTexture;
  98610. /**
  98611. * Define texture of the material as if self lit.
  98612. * This will be mixed in the final result even in the absence of light.
  98613. */
  98614. emissiveTexture: Nullable<BaseTexture>;
  98615. private _specularTexture;
  98616. /**
  98617. * Define how the color and intensity of the highlight given by the light in the material.
  98618. */
  98619. specularTexture: Nullable<BaseTexture>;
  98620. private _bumpTexture;
  98621. /**
  98622. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98623. * 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.
  98624. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98625. */
  98626. bumpTexture: Nullable<BaseTexture>;
  98627. private _lightmapTexture;
  98628. /**
  98629. * Complex lighting can be computationally expensive to compute at runtime.
  98630. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98631. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98632. */
  98633. lightmapTexture: Nullable<BaseTexture>;
  98634. private _refractionTexture;
  98635. /**
  98636. * Define the texture used to display the refraction.
  98637. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98638. */
  98639. refractionTexture: Nullable<BaseTexture>;
  98640. /**
  98641. * The color of the material lit by the environmental background lighting.
  98642. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98643. */
  98644. ambientColor: Color3;
  98645. /**
  98646. * The basic color of the material as viewed under a light.
  98647. */
  98648. diffuseColor: Color3;
  98649. /**
  98650. * Define how the color and intensity of the highlight given by the light in the material.
  98651. */
  98652. specularColor: Color3;
  98653. /**
  98654. * Define the color of the material as if self lit.
  98655. * This will be mixed in the final result even in the absence of light.
  98656. */
  98657. emissiveColor: Color3;
  98658. /**
  98659. * Defines how sharp are the highlights in the material.
  98660. * The bigger the value the sharper giving a more glossy feeling to the result.
  98661. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98662. */
  98663. specularPower: number;
  98664. private _useAlphaFromDiffuseTexture;
  98665. /**
  98666. * Does the transparency come from the diffuse texture alpha channel.
  98667. */
  98668. useAlphaFromDiffuseTexture: boolean;
  98669. private _useEmissiveAsIllumination;
  98670. /**
  98671. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98672. */
  98673. useEmissiveAsIllumination: boolean;
  98674. private _linkEmissiveWithDiffuse;
  98675. /**
  98676. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98677. * the emissive level when the final color is close to one.
  98678. */
  98679. linkEmissiveWithDiffuse: boolean;
  98680. private _useSpecularOverAlpha;
  98681. /**
  98682. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98683. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98684. */
  98685. useSpecularOverAlpha: boolean;
  98686. private _useReflectionOverAlpha;
  98687. /**
  98688. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98689. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98690. */
  98691. useReflectionOverAlpha: boolean;
  98692. private _disableLighting;
  98693. /**
  98694. * Does lights from the scene impacts this material.
  98695. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98696. */
  98697. disableLighting: boolean;
  98698. private _useObjectSpaceNormalMap;
  98699. /**
  98700. * Allows using an object space normal map (instead of tangent space).
  98701. */
  98702. useObjectSpaceNormalMap: boolean;
  98703. private _useParallax;
  98704. /**
  98705. * Is parallax enabled or not.
  98706. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98707. */
  98708. useParallax: boolean;
  98709. private _useParallaxOcclusion;
  98710. /**
  98711. * Is parallax occlusion enabled or not.
  98712. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98713. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98714. */
  98715. useParallaxOcclusion: boolean;
  98716. /**
  98717. * 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.
  98718. */
  98719. parallaxScaleBias: number;
  98720. private _roughness;
  98721. /**
  98722. * Helps to define how blurry the reflections should appears in the material.
  98723. */
  98724. roughness: number;
  98725. /**
  98726. * In case of refraction, define the value of the indice of refraction.
  98727. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98728. */
  98729. indexOfRefraction: number;
  98730. /**
  98731. * Invert the refraction texture alongside the y axis.
  98732. * It can be useful with procedural textures or probe for instance.
  98733. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98734. */
  98735. invertRefractionY: boolean;
  98736. /**
  98737. * Defines the alpha limits in alpha test mode.
  98738. */
  98739. alphaCutOff: number;
  98740. private _useLightmapAsShadowmap;
  98741. /**
  98742. * In case of light mapping, define whether the map contains light or shadow informations.
  98743. */
  98744. useLightmapAsShadowmap: boolean;
  98745. private _diffuseFresnelParameters;
  98746. /**
  98747. * Define the diffuse fresnel parameters of the material.
  98748. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98749. */
  98750. diffuseFresnelParameters: FresnelParameters;
  98751. private _opacityFresnelParameters;
  98752. /**
  98753. * Define the opacity fresnel parameters of the material.
  98754. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98755. */
  98756. opacityFresnelParameters: FresnelParameters;
  98757. private _reflectionFresnelParameters;
  98758. /**
  98759. * Define the reflection fresnel parameters of the material.
  98760. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98761. */
  98762. reflectionFresnelParameters: FresnelParameters;
  98763. private _refractionFresnelParameters;
  98764. /**
  98765. * Define the refraction fresnel parameters of the material.
  98766. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98767. */
  98768. refractionFresnelParameters: FresnelParameters;
  98769. private _emissiveFresnelParameters;
  98770. /**
  98771. * Define the emissive fresnel parameters of the material.
  98772. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98773. */
  98774. emissiveFresnelParameters: FresnelParameters;
  98775. private _useReflectionFresnelFromSpecular;
  98776. /**
  98777. * If true automatically deducts the fresnels values from the material specularity.
  98778. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98779. */
  98780. useReflectionFresnelFromSpecular: boolean;
  98781. private _useGlossinessFromSpecularMapAlpha;
  98782. /**
  98783. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98784. */
  98785. useGlossinessFromSpecularMapAlpha: boolean;
  98786. private _maxSimultaneousLights;
  98787. /**
  98788. * Defines the maximum number of lights that can be used in the material
  98789. */
  98790. maxSimultaneousLights: number;
  98791. private _invertNormalMapX;
  98792. /**
  98793. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98794. */
  98795. invertNormalMapX: boolean;
  98796. private _invertNormalMapY;
  98797. /**
  98798. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98799. */
  98800. invertNormalMapY: boolean;
  98801. private _twoSidedLighting;
  98802. /**
  98803. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98804. */
  98805. twoSidedLighting: boolean;
  98806. /**
  98807. * Default configuration related to image processing available in the standard Material.
  98808. */
  98809. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98810. /**
  98811. * Gets the image processing configuration used either in this material.
  98812. */
  98813. /**
  98814. * Sets the Default image processing configuration used either in the this material.
  98815. *
  98816. * If sets to null, the scene one is in use.
  98817. */
  98818. imageProcessingConfiguration: ImageProcessingConfiguration;
  98819. /**
  98820. * Keep track of the image processing observer to allow dispose and replace.
  98821. */
  98822. private _imageProcessingObserver;
  98823. /**
  98824. * Attaches a new image processing configuration to the Standard Material.
  98825. * @param configuration
  98826. */
  98827. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98828. /**
  98829. * Gets wether the color curves effect is enabled.
  98830. */
  98831. /**
  98832. * Sets wether the color curves effect is enabled.
  98833. */
  98834. cameraColorCurvesEnabled: boolean;
  98835. /**
  98836. * Gets wether the color grading effect is enabled.
  98837. */
  98838. /**
  98839. * Gets wether the color grading effect is enabled.
  98840. */
  98841. cameraColorGradingEnabled: boolean;
  98842. /**
  98843. * Gets wether tonemapping is enabled or not.
  98844. */
  98845. /**
  98846. * Sets wether tonemapping is enabled or not
  98847. */
  98848. cameraToneMappingEnabled: boolean;
  98849. /**
  98850. * The camera exposure used on this material.
  98851. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98852. * This corresponds to a photographic exposure.
  98853. */
  98854. /**
  98855. * The camera exposure used on this material.
  98856. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98857. * This corresponds to a photographic exposure.
  98858. */
  98859. cameraExposure: number;
  98860. /**
  98861. * Gets The camera contrast used on this material.
  98862. */
  98863. /**
  98864. * Sets The camera contrast used on this material.
  98865. */
  98866. cameraContrast: number;
  98867. /**
  98868. * Gets the Color Grading 2D Lookup Texture.
  98869. */
  98870. /**
  98871. * Sets the Color Grading 2D Lookup Texture.
  98872. */
  98873. cameraColorGradingTexture: Nullable<BaseTexture>;
  98874. /**
  98875. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98876. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98877. * 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;
  98878. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98879. */
  98880. /**
  98881. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98882. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98883. * 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;
  98884. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98885. */
  98886. cameraColorCurves: Nullable<ColorCurves>;
  98887. /**
  98888. * Custom callback helping to override the default shader used in the material.
  98889. */
  98890. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98891. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98892. protected _worldViewProjectionMatrix: Matrix;
  98893. protected _globalAmbientColor: Color3;
  98894. protected _useLogarithmicDepth: boolean;
  98895. /**
  98896. * Instantiates a new standard material.
  98897. * This is the default material used in Babylon. It is the best trade off between quality
  98898. * and performances.
  98899. * @see http://doc.babylonjs.com/babylon101/materials
  98900. * @param name Define the name of the material in the scene
  98901. * @param scene Define the scene the material belong to
  98902. */
  98903. constructor(name: string, scene: Scene);
  98904. /**
  98905. * Gets a boolean indicating that current material needs to register RTT
  98906. */
  98907. readonly hasRenderTargetTextures: boolean;
  98908. /**
  98909. * Gets the current class name of the material e.g. "StandardMaterial"
  98910. * Mainly use in serialization.
  98911. * @returns the class name
  98912. */
  98913. getClassName(): string;
  98914. /**
  98915. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98916. * You can try switching to logarithmic depth.
  98917. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98918. */
  98919. useLogarithmicDepth: boolean;
  98920. /**
  98921. * Specifies if the material will require alpha blending
  98922. * @returns a boolean specifying if alpha blending is needed
  98923. */
  98924. needAlphaBlending(): boolean;
  98925. /**
  98926. * Specifies if this material should be rendered in alpha test mode
  98927. * @returns a boolean specifying if an alpha test is needed.
  98928. */
  98929. needAlphaTesting(): boolean;
  98930. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98931. /**
  98932. * Get the texture used for alpha test purpose.
  98933. * @returns the diffuse texture in case of the standard material.
  98934. */
  98935. getAlphaTestTexture(): Nullable<BaseTexture>;
  98936. /**
  98937. * Get if the submesh is ready to be used and all its information available.
  98938. * Child classes can use it to update shaders
  98939. * @param mesh defines the mesh to check
  98940. * @param subMesh defines which submesh to check
  98941. * @param useInstances specifies that instances should be used
  98942. * @returns a boolean indicating that the submesh is ready or not
  98943. */
  98944. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98945. /**
  98946. * Builds the material UBO layouts.
  98947. * Used internally during the effect preparation.
  98948. */
  98949. buildUniformLayout(): void;
  98950. /**
  98951. * Unbinds the material from the mesh
  98952. */
  98953. unbind(): void;
  98954. /**
  98955. * Binds the submesh to this material by preparing the effect and shader to draw
  98956. * @param world defines the world transformation matrix
  98957. * @param mesh defines the mesh containing the submesh
  98958. * @param subMesh defines the submesh to bind the material to
  98959. */
  98960. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98961. /**
  98962. * Get the list of animatables in the material.
  98963. * @returns the list of animatables object used in the material
  98964. */
  98965. getAnimatables(): IAnimatable[];
  98966. /**
  98967. * Gets the active textures from the material
  98968. * @returns an array of textures
  98969. */
  98970. getActiveTextures(): BaseTexture[];
  98971. /**
  98972. * Specifies if the material uses a texture
  98973. * @param texture defines the texture to check against the material
  98974. * @returns a boolean specifying if the material uses the texture
  98975. */
  98976. hasTexture(texture: BaseTexture): boolean;
  98977. /**
  98978. * Disposes the material
  98979. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98980. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98981. */
  98982. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98983. /**
  98984. * Makes a duplicate of the material, and gives it a new name
  98985. * @param name defines the new name for the duplicated material
  98986. * @returns the cloned material
  98987. */
  98988. clone(name: string): StandardMaterial;
  98989. /**
  98990. * Serializes this material in a JSON representation
  98991. * @returns the serialized material object
  98992. */
  98993. serialize(): any;
  98994. /**
  98995. * Creates a standard material from parsed material data
  98996. * @param source defines the JSON representation of the material
  98997. * @param scene defines the hosting scene
  98998. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98999. * @returns a new standard material
  99000. */
  99001. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  99002. /**
  99003. * Are diffuse textures enabled in the application.
  99004. */
  99005. static DiffuseTextureEnabled: boolean;
  99006. /**
  99007. * Are ambient textures enabled in the application.
  99008. */
  99009. static AmbientTextureEnabled: boolean;
  99010. /**
  99011. * Are opacity textures enabled in the application.
  99012. */
  99013. static OpacityTextureEnabled: boolean;
  99014. /**
  99015. * Are reflection textures enabled in the application.
  99016. */
  99017. static ReflectionTextureEnabled: boolean;
  99018. /**
  99019. * Are emissive textures enabled in the application.
  99020. */
  99021. static EmissiveTextureEnabled: boolean;
  99022. /**
  99023. * Are specular textures enabled in the application.
  99024. */
  99025. static SpecularTextureEnabled: boolean;
  99026. /**
  99027. * Are bump textures enabled in the application.
  99028. */
  99029. static BumpTextureEnabled: boolean;
  99030. /**
  99031. * Are lightmap textures enabled in the application.
  99032. */
  99033. static LightmapTextureEnabled: boolean;
  99034. /**
  99035. * Are refraction textures enabled in the application.
  99036. */
  99037. static RefractionTextureEnabled: boolean;
  99038. /**
  99039. * Are color grading textures enabled in the application.
  99040. */
  99041. static ColorGradingTextureEnabled: boolean;
  99042. /**
  99043. * Are fresnels enabled in the application.
  99044. */
  99045. static FresnelEnabled: boolean;
  99046. }
  99047. }
  99048. declare module BABYLON {
  99049. /**
  99050. * A class extending Texture allowing drawing on a texture
  99051. * @see http://doc.babylonjs.com/how_to/dynamictexture
  99052. */
  99053. export class DynamicTexture extends Texture {
  99054. private _generateMipMaps;
  99055. private _canvas;
  99056. private _context;
  99057. private _engine;
  99058. /**
  99059. * Creates a DynamicTexture
  99060. * @param name defines the name of the texture
  99061. * @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
  99062. * @param scene defines the scene where you want the texture
  99063. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  99064. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  99065. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  99066. */
  99067. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  99068. /**
  99069. * Get the current class name of the texture useful for serialization or dynamic coding.
  99070. * @returns "DynamicTexture"
  99071. */
  99072. getClassName(): string;
  99073. /**
  99074. * Gets the current state of canRescale
  99075. */
  99076. readonly canRescale: boolean;
  99077. private _recreate;
  99078. /**
  99079. * Scales the texture
  99080. * @param ratio the scale factor to apply to both width and height
  99081. */
  99082. scale(ratio: number): void;
  99083. /**
  99084. * Resizes the texture
  99085. * @param width the new width
  99086. * @param height the new height
  99087. */
  99088. scaleTo(width: number, height: number): void;
  99089. /**
  99090. * Gets the context of the canvas used by the texture
  99091. * @returns the canvas context of the dynamic texture
  99092. */
  99093. getContext(): CanvasRenderingContext2D;
  99094. /**
  99095. * Clears the texture
  99096. */
  99097. clear(): void;
  99098. /**
  99099. * Updates the texture
  99100. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99101. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  99102. */
  99103. update(invertY?: boolean, premulAlpha?: boolean): void;
  99104. /**
  99105. * Draws text onto the texture
  99106. * @param text defines the text to be drawn
  99107. * @param x defines the placement of the text from the left
  99108. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  99109. * @param font defines the font to be used with font-style, font-size, font-name
  99110. * @param color defines the color used for the text
  99111. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  99112. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99113. * @param update defines whether texture is immediately update (default is true)
  99114. */
  99115. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  99116. /**
  99117. * Clones the texture
  99118. * @returns the clone of the texture.
  99119. */
  99120. clone(): DynamicTexture;
  99121. /**
  99122. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  99123. * @returns a serialized dynamic texture object
  99124. */
  99125. serialize(): any;
  99126. /** @hidden */
  99127. _rebuild(): void;
  99128. }
  99129. }
  99130. declare module BABYLON {
  99131. /** @hidden */
  99132. export var imageProcessingPixelShader: {
  99133. name: string;
  99134. shader: string;
  99135. };
  99136. }
  99137. declare module BABYLON {
  99138. /**
  99139. * ImageProcessingPostProcess
  99140. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99141. */
  99142. export class ImageProcessingPostProcess extends PostProcess {
  99143. /**
  99144. * Default configuration related to image processing available in the PBR Material.
  99145. */
  99146. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99147. /**
  99148. * Gets the image processing configuration used either in this material.
  99149. */
  99150. /**
  99151. * Sets the Default image processing configuration used either in the this material.
  99152. *
  99153. * If sets to null, the scene one is in use.
  99154. */
  99155. imageProcessingConfiguration: ImageProcessingConfiguration;
  99156. /**
  99157. * Keep track of the image processing observer to allow dispose and replace.
  99158. */
  99159. private _imageProcessingObserver;
  99160. /**
  99161. * Attaches a new image processing configuration to the PBR Material.
  99162. * @param configuration
  99163. */
  99164. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99165. /**
  99166. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99167. */
  99168. /**
  99169. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99170. */
  99171. colorCurves: Nullable<ColorCurves>;
  99172. /**
  99173. * Gets wether the color curves effect is enabled.
  99174. */
  99175. /**
  99176. * Sets wether the color curves effect is enabled.
  99177. */
  99178. colorCurvesEnabled: boolean;
  99179. /**
  99180. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99181. */
  99182. /**
  99183. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99184. */
  99185. colorGradingTexture: Nullable<BaseTexture>;
  99186. /**
  99187. * Gets wether the color grading effect is enabled.
  99188. */
  99189. /**
  99190. * Gets wether the color grading effect is enabled.
  99191. */
  99192. colorGradingEnabled: boolean;
  99193. /**
  99194. * Gets exposure used in the effect.
  99195. */
  99196. /**
  99197. * Sets exposure used in the effect.
  99198. */
  99199. exposure: number;
  99200. /**
  99201. * Gets wether tonemapping is enabled or not.
  99202. */
  99203. /**
  99204. * Sets wether tonemapping is enabled or not
  99205. */
  99206. toneMappingEnabled: boolean;
  99207. /**
  99208. * Gets the type of tone mapping effect.
  99209. */
  99210. /**
  99211. * Sets the type of tone mapping effect.
  99212. */
  99213. toneMappingType: number;
  99214. /**
  99215. * Gets contrast used in the effect.
  99216. */
  99217. /**
  99218. * Sets contrast used in the effect.
  99219. */
  99220. contrast: number;
  99221. /**
  99222. * Gets Vignette stretch size.
  99223. */
  99224. /**
  99225. * Sets Vignette stretch size.
  99226. */
  99227. vignetteStretch: number;
  99228. /**
  99229. * Gets Vignette centre X Offset.
  99230. */
  99231. /**
  99232. * Sets Vignette centre X Offset.
  99233. */
  99234. vignetteCentreX: number;
  99235. /**
  99236. * Gets Vignette centre Y Offset.
  99237. */
  99238. /**
  99239. * Sets Vignette centre Y Offset.
  99240. */
  99241. vignetteCentreY: number;
  99242. /**
  99243. * Gets Vignette weight or intensity of the vignette effect.
  99244. */
  99245. /**
  99246. * Sets Vignette weight or intensity of the vignette effect.
  99247. */
  99248. vignetteWeight: number;
  99249. /**
  99250. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99251. * if vignetteEnabled is set to true.
  99252. */
  99253. /**
  99254. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99255. * if vignetteEnabled is set to true.
  99256. */
  99257. vignetteColor: Color4;
  99258. /**
  99259. * Gets Camera field of view used by the Vignette effect.
  99260. */
  99261. /**
  99262. * Sets Camera field of view used by the Vignette effect.
  99263. */
  99264. vignetteCameraFov: number;
  99265. /**
  99266. * Gets the vignette blend mode allowing different kind of effect.
  99267. */
  99268. /**
  99269. * Sets the vignette blend mode allowing different kind of effect.
  99270. */
  99271. vignetteBlendMode: number;
  99272. /**
  99273. * Gets wether the vignette effect is enabled.
  99274. */
  99275. /**
  99276. * Sets wether the vignette effect is enabled.
  99277. */
  99278. vignetteEnabled: boolean;
  99279. private _fromLinearSpace;
  99280. /**
  99281. * Gets wether the input of the processing is in Gamma or Linear Space.
  99282. */
  99283. /**
  99284. * Sets wether the input of the processing is in Gamma or Linear Space.
  99285. */
  99286. fromLinearSpace: boolean;
  99287. /**
  99288. * Defines cache preventing GC.
  99289. */
  99290. private _defines;
  99291. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99292. /**
  99293. * "ImageProcessingPostProcess"
  99294. * @returns "ImageProcessingPostProcess"
  99295. */
  99296. getClassName(): string;
  99297. protected _updateParameters(): void;
  99298. dispose(camera?: Camera): void;
  99299. }
  99300. }
  99301. declare module BABYLON {
  99302. /**
  99303. * Class containing static functions to help procedurally build meshes
  99304. */
  99305. export class GroundBuilder {
  99306. /**
  99307. * Creates a ground mesh
  99308. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  99309. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  99310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99311. * @param name defines the name of the mesh
  99312. * @param options defines the options used to create the mesh
  99313. * @param scene defines the hosting scene
  99314. * @returns the ground mesh
  99315. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  99316. */
  99317. static CreateGround(name: string, options: {
  99318. width?: number;
  99319. height?: number;
  99320. subdivisions?: number;
  99321. subdivisionsX?: number;
  99322. subdivisionsY?: number;
  99323. updatable?: boolean;
  99324. }, scene: any): Mesh;
  99325. /**
  99326. * Creates a tiled ground mesh
  99327. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  99328. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  99329. * * 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
  99330. * * 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
  99331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99332. * @param name defines the name of the mesh
  99333. * @param options defines the options used to create the mesh
  99334. * @param scene defines the hosting scene
  99335. * @returns the tiled ground mesh
  99336. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  99337. */
  99338. static CreateTiledGround(name: string, options: {
  99339. xmin: number;
  99340. zmin: number;
  99341. xmax: number;
  99342. zmax: number;
  99343. subdivisions?: {
  99344. w: number;
  99345. h: number;
  99346. };
  99347. precision?: {
  99348. w: number;
  99349. h: number;
  99350. };
  99351. updatable?: boolean;
  99352. }, scene?: Nullable<Scene>): Mesh;
  99353. /**
  99354. * Creates a ground mesh from a height map
  99355. * * The parameter `url` sets the URL of the height map image resource.
  99356. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  99357. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  99358. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  99359. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  99360. * * 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.
  99361. * * 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).
  99362. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99364. * @param name defines the name of the mesh
  99365. * @param url defines the url to the height map
  99366. * @param options defines the options used to create the mesh
  99367. * @param scene defines the hosting scene
  99368. * @returns the ground mesh
  99369. * @see https://doc.babylonjs.com/babylon101/height_map
  99370. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  99371. */
  99372. static CreateGroundFromHeightMap(name: string, url: string, options: {
  99373. width?: number;
  99374. height?: number;
  99375. subdivisions?: number;
  99376. minHeight?: number;
  99377. maxHeight?: number;
  99378. colorFilter?: Color3;
  99379. alphaFilter?: number;
  99380. updatable?: boolean;
  99381. onReady?: (mesh: GroundMesh) => void;
  99382. }, scene?: Nullable<Scene>): GroundMesh;
  99383. }
  99384. }
  99385. declare module BABYLON {
  99386. /**
  99387. * Class containing static functions to help procedurally build meshes
  99388. */
  99389. export class TorusBuilder {
  99390. /**
  99391. * Creates a torus mesh
  99392. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  99393. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  99394. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  99395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99398. * @param name defines the name of the mesh
  99399. * @param options defines the options used to create the mesh
  99400. * @param scene defines the hosting scene
  99401. * @returns the torus mesh
  99402. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  99403. */
  99404. static CreateTorus(name: string, options: {
  99405. diameter?: number;
  99406. thickness?: number;
  99407. tessellation?: number;
  99408. updatable?: boolean;
  99409. sideOrientation?: number;
  99410. frontUVs?: Vector4;
  99411. backUVs?: Vector4;
  99412. }, scene: any): Mesh;
  99413. }
  99414. }
  99415. declare module BABYLON {
  99416. /**
  99417. * Class containing static functions to help procedurally build meshes
  99418. */
  99419. export class CylinderBuilder {
  99420. /**
  99421. * Creates a cylinder or a cone mesh
  99422. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  99423. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  99424. * * 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.
  99425. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  99426. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  99427. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  99428. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  99429. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  99430. * * 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).
  99431. * * 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
  99432. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  99433. * * 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
  99434. * * 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.
  99435. * * If `enclose` is false, a ring surface is one element.
  99436. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  99437. * * 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
  99438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99441. * @param name defines the name of the mesh
  99442. * @param options defines the options used to create the mesh
  99443. * @param scene defines the hosting scene
  99444. * @returns the cylinder mesh
  99445. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  99446. */
  99447. static CreateCylinder(name: string, options: {
  99448. height?: number;
  99449. diameterTop?: number;
  99450. diameterBottom?: number;
  99451. diameter?: number;
  99452. tessellation?: number;
  99453. subdivisions?: number;
  99454. arc?: number;
  99455. faceColors?: Color4[];
  99456. faceUV?: Vector4[];
  99457. updatable?: boolean;
  99458. hasRings?: boolean;
  99459. enclose?: boolean;
  99460. sideOrientation?: number;
  99461. frontUVs?: Vector4;
  99462. backUVs?: Vector4;
  99463. }, scene: any): Mesh;
  99464. }
  99465. }
  99466. declare module BABYLON {
  99467. /**
  99468. * Manager for handling gamepads
  99469. */
  99470. export class GamepadManager {
  99471. private _scene?;
  99472. private _babylonGamepads;
  99473. private _oneGamepadConnected;
  99474. /** @hidden */
  99475. _isMonitoring: boolean;
  99476. private _gamepadEventSupported;
  99477. private _gamepadSupport;
  99478. /**
  99479. * observable to be triggered when the gamepad controller has been connected
  99480. */
  99481. onGamepadConnectedObservable: Observable<Gamepad>;
  99482. /**
  99483. * observable to be triggered when the gamepad controller has been disconnected
  99484. */
  99485. onGamepadDisconnectedObservable: Observable<Gamepad>;
  99486. private _onGamepadConnectedEvent;
  99487. private _onGamepadDisconnectedEvent;
  99488. /**
  99489. * Initializes the gamepad manager
  99490. * @param _scene BabylonJS scene
  99491. */
  99492. constructor(_scene?: Scene | undefined);
  99493. /**
  99494. * The gamepads in the game pad manager
  99495. */
  99496. readonly gamepads: Gamepad[];
  99497. /**
  99498. * Get the gamepad controllers based on type
  99499. * @param type The type of gamepad controller
  99500. * @returns Nullable gamepad
  99501. */
  99502. getGamepadByType(type?: number): Nullable<Gamepad>;
  99503. /**
  99504. * Disposes the gamepad manager
  99505. */
  99506. dispose(): void;
  99507. private _addNewGamepad;
  99508. private _startMonitoringGamepads;
  99509. private _stopMonitoringGamepads;
  99510. /** @hidden */
  99511. _checkGamepadsStatus(): void;
  99512. private _updateGamepadObjects;
  99513. }
  99514. }
  99515. declare module BABYLON {
  99516. interface Scene {
  99517. /** @hidden */
  99518. _gamepadManager: Nullable<GamepadManager>;
  99519. /**
  99520. * Gets the gamepad manager associated with the scene
  99521. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  99522. */
  99523. gamepadManager: GamepadManager;
  99524. }
  99525. /**
  99526. * Interface representing a free camera inputs manager
  99527. */
  99528. interface FreeCameraInputsManager {
  99529. /**
  99530. * Adds gamepad input support to the FreeCameraInputsManager.
  99531. * @returns the FreeCameraInputsManager
  99532. */
  99533. addGamepad(): FreeCameraInputsManager;
  99534. }
  99535. /**
  99536. * Interface representing an arc rotate camera inputs manager
  99537. */
  99538. interface ArcRotateCameraInputsManager {
  99539. /**
  99540. * Adds gamepad input support to the ArcRotateCamera InputManager.
  99541. * @returns the camera inputs manager
  99542. */
  99543. addGamepad(): ArcRotateCameraInputsManager;
  99544. }
  99545. /**
  99546. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  99547. */
  99548. export class GamepadSystemSceneComponent implements ISceneComponent {
  99549. /**
  99550. * The component name helpfull to identify the component in the list of scene components.
  99551. */
  99552. readonly name: string;
  99553. /**
  99554. * The scene the component belongs to.
  99555. */
  99556. scene: Scene;
  99557. /**
  99558. * Creates a new instance of the component for the given scene
  99559. * @param scene Defines the scene to register the component in
  99560. */
  99561. constructor(scene: Scene);
  99562. /**
  99563. * Registers the component in a given scene
  99564. */
  99565. register(): void;
  99566. /**
  99567. * Rebuilds the elements related to this component in case of
  99568. * context lost for instance.
  99569. */
  99570. rebuild(): void;
  99571. /**
  99572. * Disposes the component and the associated ressources
  99573. */
  99574. dispose(): void;
  99575. private _beforeCameraUpdate;
  99576. }
  99577. }
  99578. declare module BABYLON {
  99579. /**
  99580. * Options to modify the vr teleportation behavior.
  99581. */
  99582. export interface VRTeleportationOptions {
  99583. /**
  99584. * The name of the mesh which should be used as the teleportation floor. (default: null)
  99585. */
  99586. floorMeshName?: string;
  99587. /**
  99588. * A list of meshes to be used as the teleportation floor. (default: empty)
  99589. */
  99590. floorMeshes?: Mesh[];
  99591. }
  99592. /**
  99593. * Options to modify the vr experience helper's behavior.
  99594. */
  99595. export interface VRExperienceHelperOptions extends WebVROptions {
  99596. /**
  99597. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  99598. */
  99599. createDeviceOrientationCamera?: boolean;
  99600. /**
  99601. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  99602. */
  99603. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  99604. /**
  99605. * Uses the main button on the controller to toggle the laser casted. (default: true)
  99606. */
  99607. laserToggle?: boolean;
  99608. /**
  99609. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  99610. */
  99611. floorMeshes?: Mesh[];
  99612. /**
  99613. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  99614. */
  99615. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  99616. }
  99617. /**
  99618. * Event containing information after VR has been entered
  99619. */
  99620. export class OnAfterEnteringVRObservableEvent {
  99621. /**
  99622. * If entering vr was successful
  99623. */
  99624. success: boolean;
  99625. }
  99626. /**
  99627. * Helps to quickly add VR support to an existing scene.
  99628. * See http://doc.babylonjs.com/how_to/webvr_helper
  99629. */
  99630. export class VRExperienceHelper {
  99631. /** Options to modify the vr experience helper's behavior. */
  99632. webVROptions: VRExperienceHelperOptions;
  99633. private _scene;
  99634. private _position;
  99635. private _btnVR;
  99636. private _btnVRDisplayed;
  99637. private _webVRsupported;
  99638. private _webVRready;
  99639. private _webVRrequesting;
  99640. private _webVRpresenting;
  99641. private _hasEnteredVR;
  99642. private _fullscreenVRpresenting;
  99643. private _canvas;
  99644. private _webVRCamera;
  99645. private _vrDeviceOrientationCamera;
  99646. private _deviceOrientationCamera;
  99647. private _existingCamera;
  99648. private _onKeyDown;
  99649. private _onVrDisplayPresentChange;
  99650. private _onVRDisplayChanged;
  99651. private _onVRRequestPresentStart;
  99652. private _onVRRequestPresentComplete;
  99653. /**
  99654. * Observable raised right before entering VR.
  99655. */
  99656. onEnteringVRObservable: Observable<VRExperienceHelper>;
  99657. /**
  99658. * Observable raised when entering VR has completed.
  99659. */
  99660. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  99661. /**
  99662. * Observable raised when exiting VR.
  99663. */
  99664. onExitingVRObservable: Observable<VRExperienceHelper>;
  99665. /**
  99666. * Observable raised when controller mesh is loaded.
  99667. */
  99668. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99669. /** Return this.onEnteringVRObservable
  99670. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  99671. */
  99672. readonly onEnteringVR: Observable<VRExperienceHelper>;
  99673. /** Return this.onExitingVRObservable
  99674. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  99675. */
  99676. readonly onExitingVR: Observable<VRExperienceHelper>;
  99677. /** Return this.onControllerMeshLoadedObservable
  99678. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  99679. */
  99680. readonly onControllerMeshLoaded: Observable<WebVRController>;
  99681. private _rayLength;
  99682. private _useCustomVRButton;
  99683. private _teleportationRequested;
  99684. private _teleportActive;
  99685. private _floorMeshName;
  99686. private _floorMeshesCollection;
  99687. private _rotationAllowed;
  99688. private _teleportBackwardsVector;
  99689. private _teleportationTarget;
  99690. private _isDefaultTeleportationTarget;
  99691. private _postProcessMove;
  99692. private _teleportationFillColor;
  99693. private _teleportationBorderColor;
  99694. private _rotationAngle;
  99695. private _haloCenter;
  99696. private _cameraGazer;
  99697. private _padSensibilityUp;
  99698. private _padSensibilityDown;
  99699. private _leftController;
  99700. private _rightController;
  99701. /**
  99702. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  99703. */
  99704. onNewMeshSelected: Observable<AbstractMesh>;
  99705. /**
  99706. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  99707. */
  99708. onNewMeshPicked: Observable<PickingInfo>;
  99709. private _circleEase;
  99710. /**
  99711. * Observable raised before camera teleportation
  99712. */
  99713. onBeforeCameraTeleport: Observable<Vector3>;
  99714. /**
  99715. * Observable raised after camera teleportation
  99716. */
  99717. onAfterCameraTeleport: Observable<Vector3>;
  99718. /**
  99719. * Observable raised when current selected mesh gets unselected
  99720. */
  99721. onSelectedMeshUnselected: Observable<AbstractMesh>;
  99722. private _raySelectionPredicate;
  99723. /**
  99724. * To be optionaly changed by user to define custom ray selection
  99725. */
  99726. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  99727. /**
  99728. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99729. */
  99730. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99731. /**
  99732. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99733. */
  99734. teleportationEnabled: boolean;
  99735. private _defaultHeight;
  99736. private _teleportationInitialized;
  99737. private _interactionsEnabled;
  99738. private _interactionsRequested;
  99739. private _displayGaze;
  99740. private _displayLaserPointer;
  99741. /**
  99742. * The mesh used to display where the user is going to teleport.
  99743. */
  99744. /**
  99745. * Sets the mesh to be used to display where the user is going to teleport.
  99746. */
  99747. teleportationTarget: Mesh;
  99748. /**
  99749. * 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
  99750. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99751. * See http://doc.babylonjs.com/resources/baking_transformations
  99752. */
  99753. gazeTrackerMesh: Mesh;
  99754. /**
  99755. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99756. */
  99757. updateGazeTrackerScale: boolean;
  99758. /**
  99759. * If the gaze trackers color should be updated when selecting meshes
  99760. */
  99761. updateGazeTrackerColor: boolean;
  99762. /**
  99763. * The gaze tracking mesh corresponding to the left controller
  99764. */
  99765. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99766. /**
  99767. * The gaze tracking mesh corresponding to the right controller
  99768. */
  99769. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99770. /**
  99771. * If the ray of the gaze should be displayed.
  99772. */
  99773. /**
  99774. * Sets if the ray of the gaze should be displayed.
  99775. */
  99776. displayGaze: boolean;
  99777. /**
  99778. * If the ray of the LaserPointer should be displayed.
  99779. */
  99780. /**
  99781. * Sets if the ray of the LaserPointer should be displayed.
  99782. */
  99783. displayLaserPointer: boolean;
  99784. /**
  99785. * The deviceOrientationCamera used as the camera when not in VR.
  99786. */
  99787. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99788. /**
  99789. * Based on the current WebVR support, returns the current VR camera used.
  99790. */
  99791. readonly currentVRCamera: Nullable<Camera>;
  99792. /**
  99793. * The webVRCamera which is used when in VR.
  99794. */
  99795. readonly webVRCamera: WebVRFreeCamera;
  99796. /**
  99797. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99798. */
  99799. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99800. private readonly _teleportationRequestInitiated;
  99801. /**
  99802. * Defines wether or not Pointer lock should be requested when switching to
  99803. * full screen.
  99804. */
  99805. requestPointerLockOnFullScreen: boolean;
  99806. /**
  99807. * Instantiates a VRExperienceHelper.
  99808. * Helps to quickly add VR support to an existing scene.
  99809. * @param scene The scene the VRExperienceHelper belongs to.
  99810. * @param webVROptions Options to modify the vr experience helper's behavior.
  99811. */
  99812. constructor(scene: Scene,
  99813. /** Options to modify the vr experience helper's behavior. */
  99814. webVROptions?: VRExperienceHelperOptions);
  99815. private _onDefaultMeshLoaded;
  99816. private _onResize;
  99817. private _onFullscreenChange;
  99818. /**
  99819. * Gets a value indicating if we are currently in VR mode.
  99820. */
  99821. readonly isInVRMode: boolean;
  99822. private onVrDisplayPresentChange;
  99823. private onVRDisplayChanged;
  99824. private moveButtonToBottomRight;
  99825. private displayVRButton;
  99826. private updateButtonVisibility;
  99827. private _cachedAngularSensibility;
  99828. /**
  99829. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99830. * Otherwise, will use the fullscreen API.
  99831. */
  99832. enterVR(): void;
  99833. /**
  99834. * Attempt to exit VR, or fullscreen.
  99835. */
  99836. exitVR(): void;
  99837. /**
  99838. * The position of the vr experience helper.
  99839. */
  99840. /**
  99841. * Sets the position of the vr experience helper.
  99842. */
  99843. position: Vector3;
  99844. /**
  99845. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99846. */
  99847. enableInteractions(): void;
  99848. private readonly _noControllerIsActive;
  99849. private beforeRender;
  99850. private _isTeleportationFloor;
  99851. /**
  99852. * Adds a floor mesh to be used for teleportation.
  99853. * @param floorMesh the mesh to be used for teleportation.
  99854. */
  99855. addFloorMesh(floorMesh: Mesh): void;
  99856. /**
  99857. * Removes a floor mesh from being used for teleportation.
  99858. * @param floorMesh the mesh to be removed.
  99859. */
  99860. removeFloorMesh(floorMesh: Mesh): void;
  99861. /**
  99862. * Enables interactions and teleportation using the VR controllers and gaze.
  99863. * @param vrTeleportationOptions options to modify teleportation behavior.
  99864. */
  99865. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99866. private _onNewGamepadConnected;
  99867. private _tryEnableInteractionOnController;
  99868. private _onNewGamepadDisconnected;
  99869. private _enableInteractionOnController;
  99870. private _checkTeleportWithRay;
  99871. private _checkRotate;
  99872. private _checkTeleportBackwards;
  99873. private _enableTeleportationOnController;
  99874. private _createTeleportationCircles;
  99875. private _displayTeleportationTarget;
  99876. private _hideTeleportationTarget;
  99877. private _rotateCamera;
  99878. private _moveTeleportationSelectorTo;
  99879. private _workingVector;
  99880. private _workingQuaternion;
  99881. private _workingMatrix;
  99882. /**
  99883. * Teleports the users feet to the desired location
  99884. * @param location The location where the user's feet should be placed
  99885. */
  99886. teleportCamera(location: Vector3): void;
  99887. private _convertNormalToDirectionOfRay;
  99888. private _castRayAndSelectObject;
  99889. private _notifySelectedMeshUnselected;
  99890. /**
  99891. * Sets the color of the laser ray from the vr controllers.
  99892. * @param color new color for the ray.
  99893. */
  99894. changeLaserColor(color: Color3): void;
  99895. /**
  99896. * Sets the color of the ray from the vr headsets gaze.
  99897. * @param color new color for the ray.
  99898. */
  99899. changeGazeColor(color: Color3): void;
  99900. /**
  99901. * Exits VR and disposes of the vr experience helper
  99902. */
  99903. dispose(): void;
  99904. /**
  99905. * Gets the name of the VRExperienceHelper class
  99906. * @returns "VRExperienceHelper"
  99907. */
  99908. getClassName(): string;
  99909. }
  99910. }
  99911. declare module BABYLON {
  99912. /**
  99913. * Manages an XRSession
  99914. * @see https://doc.babylonjs.com/how_to/webxr
  99915. */
  99916. export class WebXRSessionManager implements IDisposable {
  99917. private scene;
  99918. /**
  99919. * Fires every time a new xrFrame arrives which can be used to update the camera
  99920. */
  99921. onXRFrameObservable: Observable<any>;
  99922. /**
  99923. * Fires when the xr session is ended either by the device or manually done
  99924. */
  99925. onXRSessionEnded: Observable<any>;
  99926. /** @hidden */
  99927. _xrSession: XRSession;
  99928. /** @hidden */
  99929. _frameOfReference: XRFrameOfReference;
  99930. /** @hidden */
  99931. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99932. /** @hidden */
  99933. _currentXRFrame: Nullable<XRFrame>;
  99934. private _xrNavigator;
  99935. private _xrDevice;
  99936. private _tmpMatrix;
  99937. /**
  99938. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99939. * @param scene The scene which the session should be created for
  99940. */
  99941. constructor(scene: Scene);
  99942. /**
  99943. * Initializes the manager
  99944. * After initialization enterXR can be called to start an XR session
  99945. * @returns Promise which resolves after it is initialized
  99946. */
  99947. initializeAsync(): Promise<void>;
  99948. /**
  99949. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99950. * @param sessionCreationOptions xr options to create the session with
  99951. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99952. * @returns Promise which resolves after it enters XR
  99953. */
  99954. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99955. /**
  99956. * Stops the xrSession and restores the renderloop
  99957. * @returns Promise which resolves after it exits XR
  99958. */
  99959. exitXRAsync(): Promise<void>;
  99960. /**
  99961. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99962. * @param ray ray to cast into the environment
  99963. * @returns Promise which resolves with a collision point in the environment if it exists
  99964. */
  99965. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99966. /**
  99967. * Checks if a session would be supported for the creation options specified
  99968. * @param options creation options to check if they are supported
  99969. * @returns true if supported
  99970. */
  99971. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99972. /**
  99973. * @hidden
  99974. * Converts the render layer of xrSession to a render target
  99975. * @param session session to create render target for
  99976. * @param scene scene the new render target should be created for
  99977. */
  99978. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99979. /**
  99980. * Disposes of the session manager
  99981. */
  99982. dispose(): void;
  99983. }
  99984. }
  99985. declare module BABYLON {
  99986. /**
  99987. * WebXR Camera which holds the views for the xrSession
  99988. * @see https://doc.babylonjs.com/how_to/webxr
  99989. */
  99990. export class WebXRCamera extends FreeCamera {
  99991. private static _TmpMatrix;
  99992. /**
  99993. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99994. * @param name the name of the camera
  99995. * @param scene the scene to add the camera to
  99996. */
  99997. constructor(name: string, scene: Scene);
  99998. private _updateNumberOfRigCameras;
  99999. /** @hidden */
  100000. _updateForDualEyeDebugging(pupilDistance?: number): void;
  100001. /**
  100002. * Updates the cameras position from the current pose information of the XR session
  100003. * @param xrSessionManager the session containing pose information
  100004. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  100005. */
  100006. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  100007. }
  100008. }
  100009. declare module BABYLON {
  100010. /**
  100011. * States of the webXR experience
  100012. */
  100013. export enum WebXRState {
  100014. /**
  100015. * Transitioning to being in XR mode
  100016. */
  100017. ENTERING_XR = 0,
  100018. /**
  100019. * Transitioning to non XR mode
  100020. */
  100021. EXITING_XR = 1,
  100022. /**
  100023. * In XR mode and presenting
  100024. */
  100025. IN_XR = 2,
  100026. /**
  100027. * Not entered XR mode
  100028. */
  100029. NOT_IN_XR = 3
  100030. }
  100031. /**
  100032. * Helper class used to enable XR
  100033. * @see https://doc.babylonjs.com/how_to/webxr
  100034. */
  100035. export class WebXRExperienceHelper implements IDisposable {
  100036. private scene;
  100037. /**
  100038. * 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
  100039. */
  100040. container: AbstractMesh;
  100041. /**
  100042. * Camera used to render xr content
  100043. */
  100044. camera: WebXRCamera;
  100045. /**
  100046. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  100047. */
  100048. state: WebXRState;
  100049. private _setState;
  100050. private static _TmpVector;
  100051. /**
  100052. * Fires when the state of the experience helper has changed
  100053. */
  100054. onStateChangedObservable: Observable<WebXRState>;
  100055. /** @hidden */
  100056. _sessionManager: WebXRSessionManager;
  100057. private _nonVRCamera;
  100058. private _originalSceneAutoClear;
  100059. private _supported;
  100060. /**
  100061. * Creates the experience helper
  100062. * @param scene the scene to attach the experience helper to
  100063. * @returns a promise for the experience helper
  100064. */
  100065. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  100066. /**
  100067. * Creates a WebXRExperienceHelper
  100068. * @param scene The scene the helper should be created in
  100069. */
  100070. private constructor();
  100071. /**
  100072. * Exits XR mode and returns the scene to its original state
  100073. * @returns promise that resolves after xr mode has exited
  100074. */
  100075. exitXRAsync(): Promise<void>;
  100076. /**
  100077. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  100078. * @param sessionCreationOptions options for the XR session
  100079. * @param frameOfReference frame of reference of the XR session
  100080. * @returns promise that resolves after xr mode has entered
  100081. */
  100082. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  100083. /**
  100084. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  100085. * @param ray ray to cast into the environment
  100086. * @returns Promise which resolves with a collision point in the environment if it exists
  100087. */
  100088. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  100089. /**
  100090. * Updates the global position of the camera by moving the camera's container
  100091. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  100092. * @param position The desired global position of the camera
  100093. */
  100094. setPositionOfCameraUsingContainer(position: Vector3): void;
  100095. /**
  100096. * Rotates the xr camera by rotating the camera's container around the camera's position
  100097. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  100098. * @param rotation the desired quaternion rotation to apply to the camera
  100099. */
  100100. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  100101. /**
  100102. * Checks if the creation options are supported by the xr session
  100103. * @param options creation options
  100104. * @returns true if supported
  100105. */
  100106. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  100107. /**
  100108. * Disposes of the experience helper
  100109. */
  100110. dispose(): void;
  100111. }
  100112. }
  100113. declare module BABYLON {
  100114. /**
  100115. * Button which can be used to enter a different mode of XR
  100116. */
  100117. export class WebXREnterExitUIButton {
  100118. /** button element */
  100119. element: HTMLElement;
  100120. /** XR initialization options for the button */
  100121. initializationOptions: XRSessionCreationOptions;
  100122. /**
  100123. * Creates a WebXREnterExitUIButton
  100124. * @param element button element
  100125. * @param initializationOptions XR initialization options for the button
  100126. */
  100127. constructor(
  100128. /** button element */
  100129. element: HTMLElement,
  100130. /** XR initialization options for the button */
  100131. initializationOptions: XRSessionCreationOptions);
  100132. /**
  100133. * Overwritable function which can be used to update the button's visuals when the state changes
  100134. * @param activeButton the current active button in the UI
  100135. */
  100136. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  100137. }
  100138. /**
  100139. * Options to create the webXR UI
  100140. */
  100141. export class WebXREnterExitUIOptions {
  100142. /**
  100143. * Context to enter xr with
  100144. */
  100145. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  100146. /**
  100147. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  100148. */
  100149. customButtons?: Array<WebXREnterExitUIButton>;
  100150. }
  100151. /**
  100152. * UI to allow the user to enter/exit XR mode
  100153. */
  100154. export class WebXREnterExitUI implements IDisposable {
  100155. private scene;
  100156. private _overlay;
  100157. private _buttons;
  100158. private _activeButton;
  100159. /**
  100160. * Fired every time the active button is changed.
  100161. *
  100162. * When xr is entered via a button that launches xr that button will be the callback parameter
  100163. *
  100164. * When exiting xr the callback parameter will be null)
  100165. */
  100166. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  100167. /**
  100168. * Creates UI to allow the user to enter/exit XR mode
  100169. * @param scene the scene to add the ui to
  100170. * @param helper the xr experience helper to enter/exit xr with
  100171. * @param options options to configure the UI
  100172. * @returns the created ui
  100173. */
  100174. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  100175. private constructor();
  100176. private _updateButtons;
  100177. /**
  100178. * Disposes of the object
  100179. */
  100180. dispose(): void;
  100181. }
  100182. }
  100183. declare module BABYLON {
  100184. /**
  100185. * Represents an XR input
  100186. */
  100187. export class WebXRController {
  100188. /**
  100189. * 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
  100190. */
  100191. grip?: AbstractMesh;
  100192. /**
  100193. * Pointer which can be used to select objects or attach a visible laser to
  100194. */
  100195. pointer: AbstractMesh;
  100196. /**
  100197. * Creates the controller
  100198. * @see https://doc.babylonjs.com/how_to/webxr
  100199. * @param scene the scene which the controller should be associated to
  100200. */
  100201. constructor(scene: Scene);
  100202. /**
  100203. * Disposes of the object
  100204. */
  100205. dispose(): void;
  100206. }
  100207. /**
  100208. * XR input used to track XR inputs such as controllers/rays
  100209. */
  100210. export class WebXRInput implements IDisposable {
  100211. private helper;
  100212. /**
  100213. * XR controllers being tracked
  100214. */
  100215. controllers: Array<WebXRController>;
  100216. private _tmpMatrix;
  100217. private _frameObserver;
  100218. /**
  100219. * Initializes the WebXRInput
  100220. * @param helper experience helper which the input should be created for
  100221. */
  100222. constructor(helper: WebXRExperienceHelper);
  100223. /**
  100224. * Disposes of the object
  100225. */
  100226. dispose(): void;
  100227. }
  100228. }
  100229. declare module BABYLON {
  100230. /**
  100231. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  100232. */
  100233. export class WebXRManagedOutputCanvas implements IDisposable {
  100234. private _canvas;
  100235. /**
  100236. * xrpresent context of the canvas which can be used to display/mirror xr content
  100237. */
  100238. canvasContext: Nullable<WebGLRenderingContext>;
  100239. /**
  100240. * Initializes the canvas to be added/removed upon entering/exiting xr
  100241. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  100242. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  100243. */
  100244. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  100245. /**
  100246. * Disposes of the object
  100247. */
  100248. dispose(): void;
  100249. private _setManagedOutputCanvas;
  100250. private _addCanvas;
  100251. private _removeCanvas;
  100252. }
  100253. }
  100254. declare module BABYLON {
  100255. /**
  100256. * Contains an array of blocks representing the octree
  100257. */
  100258. export interface IOctreeContainer<T> {
  100259. /**
  100260. * Blocks within the octree
  100261. */
  100262. blocks: Array<OctreeBlock<T>>;
  100263. }
  100264. /**
  100265. * Class used to store a cell in an octree
  100266. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100267. */
  100268. export class OctreeBlock<T> {
  100269. /**
  100270. * Gets the content of the current block
  100271. */
  100272. entries: T[];
  100273. /**
  100274. * Gets the list of block children
  100275. */
  100276. blocks: Array<OctreeBlock<T>>;
  100277. private _depth;
  100278. private _maxDepth;
  100279. private _capacity;
  100280. private _minPoint;
  100281. private _maxPoint;
  100282. private _boundingVectors;
  100283. private _creationFunc;
  100284. /**
  100285. * Creates a new block
  100286. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  100287. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  100288. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100289. * @param depth defines the current depth of this block in the octree
  100290. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  100291. * @param creationFunc defines a callback to call when an element is added to the block
  100292. */
  100293. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  100294. /**
  100295. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100296. */
  100297. readonly capacity: number;
  100298. /**
  100299. * Gets the minimum vector (in world space) of the block's bounding box
  100300. */
  100301. readonly minPoint: Vector3;
  100302. /**
  100303. * Gets the maximum vector (in world space) of the block's bounding box
  100304. */
  100305. readonly maxPoint: Vector3;
  100306. /**
  100307. * Add a new element to this block
  100308. * @param entry defines the element to add
  100309. */
  100310. addEntry(entry: T): void;
  100311. /**
  100312. * Remove an element from this block
  100313. * @param entry defines the element to remove
  100314. */
  100315. removeEntry(entry: T): void;
  100316. /**
  100317. * Add an array of elements to this block
  100318. * @param entries defines the array of elements to add
  100319. */
  100320. addEntries(entries: T[]): void;
  100321. /**
  100322. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  100323. * @param frustumPlanes defines the frustum planes to test
  100324. * @param selection defines the array to store current content if selection is positive
  100325. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100326. */
  100327. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100328. /**
  100329. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  100330. * @param sphereCenter defines the bounding sphere center
  100331. * @param sphereRadius defines the bounding sphere radius
  100332. * @param selection defines the array to store current content if selection is positive
  100333. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100334. */
  100335. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100336. /**
  100337. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  100338. * @param ray defines the ray to test with
  100339. * @param selection defines the array to store current content if selection is positive
  100340. */
  100341. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  100342. /**
  100343. * Subdivide the content into child blocks (this block will then be empty)
  100344. */
  100345. createInnerBlocks(): void;
  100346. /**
  100347. * @hidden
  100348. */
  100349. 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;
  100350. }
  100351. }
  100352. declare module BABYLON {
  100353. /**
  100354. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  100355. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100356. */
  100357. export class Octree<T> {
  100358. /** 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.) */
  100359. maxDepth: number;
  100360. /**
  100361. * Blocks within the octree containing objects
  100362. */
  100363. blocks: Array<OctreeBlock<T>>;
  100364. /**
  100365. * Content stored in the octree
  100366. */
  100367. dynamicContent: T[];
  100368. private _maxBlockCapacity;
  100369. private _selectionContent;
  100370. private _creationFunc;
  100371. /**
  100372. * Creates a octree
  100373. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100374. * @param creationFunc function to be used to instatiate the octree
  100375. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  100376. * @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.)
  100377. */
  100378. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  100379. /** 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.) */
  100380. maxDepth?: number);
  100381. /**
  100382. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  100383. * @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);
  100384. * @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);
  100385. * @param entries meshes to be added to the octree blocks
  100386. */
  100387. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  100388. /**
  100389. * Adds a mesh to the octree
  100390. * @param entry Mesh to add to the octree
  100391. */
  100392. addMesh(entry: T): void;
  100393. /**
  100394. * Remove an element from the octree
  100395. * @param entry defines the element to remove
  100396. */
  100397. removeMesh(entry: T): void;
  100398. /**
  100399. * Selects an array of meshes within the frustum
  100400. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  100401. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  100402. * @returns array of meshes within the frustum
  100403. */
  100404. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  100405. /**
  100406. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  100407. * @param sphereCenter defines the bounding sphere center
  100408. * @param sphereRadius defines the bounding sphere radius
  100409. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100410. * @returns an array of objects that intersect the sphere
  100411. */
  100412. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  100413. /**
  100414. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  100415. * @param ray defines the ray to test with
  100416. * @returns array of intersected objects
  100417. */
  100418. intersectsRay(ray: Ray): SmartArray<T>;
  100419. /**
  100420. * Adds a mesh into the octree block if it intersects the block
  100421. */
  100422. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  100423. /**
  100424. * Adds a submesh into the octree block if it intersects the block
  100425. */
  100426. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  100427. }
  100428. }
  100429. declare module BABYLON {
  100430. interface Scene {
  100431. /**
  100432. * @hidden
  100433. * Backing Filed
  100434. */
  100435. _selectionOctree: Octree<AbstractMesh>;
  100436. /**
  100437. * Gets the octree used to boost mesh selection (picking)
  100438. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100439. */
  100440. selectionOctree: Octree<AbstractMesh>;
  100441. /**
  100442. * Creates or updates the octree used to boost selection (picking)
  100443. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100444. * @param maxCapacity defines the maximum capacity per leaf
  100445. * @param maxDepth defines the maximum depth of the octree
  100446. * @returns an octree of AbstractMesh
  100447. */
  100448. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  100449. }
  100450. interface AbstractMesh {
  100451. /**
  100452. * @hidden
  100453. * Backing Field
  100454. */
  100455. _submeshesOctree: Octree<SubMesh>;
  100456. /**
  100457. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  100458. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  100459. * @param maxCapacity defines the maximum size of each block (64 by default)
  100460. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  100461. * @returns the new octree
  100462. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  100463. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100464. */
  100465. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  100466. }
  100467. /**
  100468. * Defines the octree scene component responsible to manage any octrees
  100469. * in a given scene.
  100470. */
  100471. export class OctreeSceneComponent {
  100472. /**
  100473. * The component name help to identify the component in the list of scene components.
  100474. */
  100475. readonly name: string;
  100476. /**
  100477. * The scene the component belongs to.
  100478. */
  100479. scene: Scene;
  100480. /**
  100481. * Indicates if the meshes have been checked to make sure they are isEnabled()
  100482. */
  100483. readonly checksIsEnabled: boolean;
  100484. /**
  100485. * Creates a new instance of the component for the given scene
  100486. * @param scene Defines the scene to register the component in
  100487. */
  100488. constructor(scene: Scene);
  100489. /**
  100490. * Registers the component in a given scene
  100491. */
  100492. register(): void;
  100493. /**
  100494. * Return the list of active meshes
  100495. * @returns the list of active meshes
  100496. */
  100497. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100498. /**
  100499. * Return the list of active sub meshes
  100500. * @param mesh The mesh to get the candidates sub meshes from
  100501. * @returns the list of active sub meshes
  100502. */
  100503. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100504. private _tempRay;
  100505. /**
  100506. * Return the list of sub meshes intersecting with a given local ray
  100507. * @param mesh defines the mesh to find the submesh for
  100508. * @param localRay defines the ray in local space
  100509. * @returns the list of intersecting sub meshes
  100510. */
  100511. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  100512. /**
  100513. * Return the list of sub meshes colliding with a collider
  100514. * @param mesh defines the mesh to find the submesh for
  100515. * @param collider defines the collider to evaluate the collision against
  100516. * @returns the list of colliding sub meshes
  100517. */
  100518. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  100519. /**
  100520. * Rebuilds the elements related to this component in case of
  100521. * context lost for instance.
  100522. */
  100523. rebuild(): void;
  100524. /**
  100525. * Disposes the component and the associated ressources.
  100526. */
  100527. dispose(): void;
  100528. }
  100529. }
  100530. declare module BABYLON {
  100531. /**
  100532. * Renders a layer on top of an existing scene
  100533. */
  100534. export class UtilityLayerRenderer implements IDisposable {
  100535. /** the original scene that will be rendered on top of */
  100536. originalScene: Scene;
  100537. private _pointerCaptures;
  100538. private _lastPointerEvents;
  100539. private static _DefaultUtilityLayer;
  100540. private static _DefaultKeepDepthUtilityLayer;
  100541. private _sharedGizmoLight;
  100542. /**
  100543. * @hidden
  100544. * Light which used by gizmos to get light shading
  100545. */
  100546. _getSharedGizmoLight(): HemisphericLight;
  100547. /**
  100548. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  100549. */
  100550. pickUtilitySceneFirst: boolean;
  100551. /**
  100552. * 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)
  100553. */
  100554. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  100555. /**
  100556. * 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)
  100557. */
  100558. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  100559. /**
  100560. * The scene that is rendered on top of the original scene
  100561. */
  100562. utilityLayerScene: Scene;
  100563. /**
  100564. * If the utility layer should automatically be rendered on top of existing scene
  100565. */
  100566. shouldRender: boolean;
  100567. /**
  100568. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  100569. */
  100570. onlyCheckPointerDownEvents: boolean;
  100571. /**
  100572. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  100573. */
  100574. processAllEvents: boolean;
  100575. /**
  100576. * Observable raised when the pointer move from the utility layer scene to the main scene
  100577. */
  100578. onPointerOutObservable: Observable<number>;
  100579. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  100580. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  100581. private _afterRenderObserver;
  100582. private _sceneDisposeObserver;
  100583. private _originalPointerObserver;
  100584. /**
  100585. * Instantiates a UtilityLayerRenderer
  100586. * @param originalScene the original scene that will be rendered on top of
  100587. * @param handleEvents boolean indicating if the utility layer should handle events
  100588. */
  100589. constructor(
  100590. /** the original scene that will be rendered on top of */
  100591. originalScene: Scene, handleEvents?: boolean);
  100592. private _notifyObservers;
  100593. /**
  100594. * Renders the utility layers scene on top of the original scene
  100595. */
  100596. render(): void;
  100597. /**
  100598. * Disposes of the renderer
  100599. */
  100600. dispose(): void;
  100601. private _updateCamera;
  100602. }
  100603. }
  100604. declare module BABYLON {
  100605. /**
  100606. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  100607. */
  100608. export class Gizmo implements IDisposable {
  100609. /** The utility layer the gizmo will be added to */
  100610. gizmoLayer: UtilityLayerRenderer;
  100611. /**
  100612. * The root mesh of the gizmo
  100613. */
  100614. _rootMesh: Mesh;
  100615. private _attachedMesh;
  100616. /**
  100617. * Ratio for the scale of the gizmo (Default: 1)
  100618. */
  100619. scaleRatio: number;
  100620. /**
  100621. * If a custom mesh has been set (Default: false)
  100622. */
  100623. protected _customMeshSet: boolean;
  100624. /**
  100625. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  100626. * * When set, interactions will be enabled
  100627. */
  100628. attachedMesh: Nullable<AbstractMesh>;
  100629. /**
  100630. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100631. * @param mesh The mesh to replace the default mesh of the gizmo
  100632. */
  100633. setCustomMesh(mesh: Mesh): void;
  100634. /**
  100635. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  100636. */
  100637. updateGizmoRotationToMatchAttachedMesh: boolean;
  100638. /**
  100639. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  100640. */
  100641. updateGizmoPositionToMatchAttachedMesh: boolean;
  100642. /**
  100643. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  100644. */
  100645. protected _updateScale: boolean;
  100646. protected _interactionsEnabled: boolean;
  100647. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100648. private _beforeRenderObserver;
  100649. private _tempVector;
  100650. /**
  100651. * Creates a gizmo
  100652. * @param gizmoLayer The utility layer the gizmo will be added to
  100653. */
  100654. constructor(
  100655. /** The utility layer the gizmo will be added to */
  100656. gizmoLayer?: UtilityLayerRenderer);
  100657. /**
  100658. * Updates the gizmo to match the attached mesh's position/rotation
  100659. */
  100660. protected _update(): void;
  100661. /**
  100662. * Disposes of the gizmo
  100663. */
  100664. dispose(): void;
  100665. }
  100666. }
  100667. declare module BABYLON {
  100668. /**
  100669. * Single axis drag gizmo
  100670. */
  100671. export class AxisDragGizmo extends Gizmo {
  100672. /**
  100673. * Drag behavior responsible for the gizmos dragging interactions
  100674. */
  100675. dragBehavior: PointerDragBehavior;
  100676. private _pointerObserver;
  100677. /**
  100678. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100679. */
  100680. snapDistance: number;
  100681. /**
  100682. * Event that fires each time the gizmo snaps to a new location.
  100683. * * snapDistance is the the change in distance
  100684. */
  100685. onSnapObservable: Observable<{
  100686. snapDistance: number;
  100687. }>;
  100688. /** @hidden */
  100689. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  100690. /** @hidden */
  100691. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  100692. /**
  100693. * Creates an AxisDragGizmo
  100694. * @param gizmoLayer The utility layer the gizmo will be added to
  100695. * @param dragAxis The axis which the gizmo will be able to drag on
  100696. * @param color The color of the gizmo
  100697. */
  100698. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100699. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100700. /**
  100701. * Disposes of the gizmo
  100702. */
  100703. dispose(): void;
  100704. }
  100705. }
  100706. declare module BABYLON.Debug {
  100707. /**
  100708. * The Axes viewer will show 3 axes in a specific point in space
  100709. */
  100710. export class AxesViewer {
  100711. private _xAxis;
  100712. private _yAxis;
  100713. private _zAxis;
  100714. private _scaleLinesFactor;
  100715. private _instanced;
  100716. /**
  100717. * Gets the hosting scene
  100718. */
  100719. scene: Scene;
  100720. /**
  100721. * Gets or sets a number used to scale line length
  100722. */
  100723. scaleLines: number;
  100724. /** Gets the node hierarchy used to render x-axis */
  100725. readonly xAxis: TransformNode;
  100726. /** Gets the node hierarchy used to render y-axis */
  100727. readonly yAxis: TransformNode;
  100728. /** Gets the node hierarchy used to render z-axis */
  100729. readonly zAxis: TransformNode;
  100730. /**
  100731. * Creates a new AxesViewer
  100732. * @param scene defines the hosting scene
  100733. * @param scaleLines defines a number used to scale line length (1 by default)
  100734. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100735. * @param xAxis defines the node hierarchy used to render the x-axis
  100736. * @param yAxis defines the node hierarchy used to render the y-axis
  100737. * @param zAxis defines the node hierarchy used to render the z-axis
  100738. */
  100739. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100740. /**
  100741. * Force the viewer to update
  100742. * @param position defines the position of the viewer
  100743. * @param xaxis defines the x axis of the viewer
  100744. * @param yaxis defines the y axis of the viewer
  100745. * @param zaxis defines the z axis of the viewer
  100746. */
  100747. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100748. /**
  100749. * Creates an instance of this axes viewer.
  100750. * @returns a new axes viewer with instanced meshes
  100751. */
  100752. createInstance(): AxesViewer;
  100753. /** Releases resources */
  100754. dispose(): void;
  100755. private static _SetRenderingGroupId;
  100756. }
  100757. }
  100758. declare module BABYLON.Debug {
  100759. /**
  100760. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100761. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100762. */
  100763. export class BoneAxesViewer extends AxesViewer {
  100764. /**
  100765. * Gets or sets the target mesh where to display the axes viewer
  100766. */
  100767. mesh: Nullable<Mesh>;
  100768. /**
  100769. * Gets or sets the target bone where to display the axes viewer
  100770. */
  100771. bone: Nullable<Bone>;
  100772. /** Gets current position */
  100773. pos: Vector3;
  100774. /** Gets direction of X axis */
  100775. xaxis: Vector3;
  100776. /** Gets direction of Y axis */
  100777. yaxis: Vector3;
  100778. /** Gets direction of Z axis */
  100779. zaxis: Vector3;
  100780. /**
  100781. * Creates a new BoneAxesViewer
  100782. * @param scene defines the hosting scene
  100783. * @param bone defines the target bone
  100784. * @param mesh defines the target mesh
  100785. * @param scaleLines defines a scaling factor for line length (1 by default)
  100786. */
  100787. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100788. /**
  100789. * Force the viewer to update
  100790. */
  100791. update(): void;
  100792. /** Releases resources */
  100793. dispose(): void;
  100794. }
  100795. }
  100796. declare module BABYLON {
  100797. /**
  100798. * Interface used to define scene explorer extensibility option
  100799. */
  100800. export interface IExplorerExtensibilityOption {
  100801. /**
  100802. * Define the option label
  100803. */
  100804. label: string;
  100805. /**
  100806. * Defines the action to execute on click
  100807. */
  100808. action: (entity: any) => void;
  100809. }
  100810. /**
  100811. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100812. */
  100813. export interface IExplorerExtensibilityGroup {
  100814. /**
  100815. * Defines a predicate to test if a given type mut be extended
  100816. */
  100817. predicate: (entity: any) => boolean;
  100818. /**
  100819. * Gets the list of options added to a type
  100820. */
  100821. entries: IExplorerExtensibilityOption[];
  100822. }
  100823. /**
  100824. * Interface used to define the options to use to create the Inspector
  100825. */
  100826. export interface IInspectorOptions {
  100827. /**
  100828. * Display in overlay mode (default: false)
  100829. */
  100830. overlay?: boolean;
  100831. /**
  100832. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100833. */
  100834. globalRoot?: HTMLElement;
  100835. /**
  100836. * Display the Scene explorer
  100837. */
  100838. showExplorer?: boolean;
  100839. /**
  100840. * Display the property inspector
  100841. */
  100842. showInspector?: boolean;
  100843. /**
  100844. * Display in embed mode (both panes on the right)
  100845. */
  100846. embedMode?: boolean;
  100847. /**
  100848. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100849. */
  100850. handleResize?: boolean;
  100851. /**
  100852. * Allow the panes to popup (default: true)
  100853. */
  100854. enablePopup?: boolean;
  100855. /**
  100856. * Allow the panes to be closed by users (default: true)
  100857. */
  100858. enableClose?: boolean;
  100859. /**
  100860. * Optional list of extensibility entries
  100861. */
  100862. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100863. /**
  100864. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100865. */
  100866. inspectorURL?: string;
  100867. }
  100868. interface Scene {
  100869. /**
  100870. * @hidden
  100871. * Backing field
  100872. */
  100873. _debugLayer: DebugLayer;
  100874. /**
  100875. * Gets the debug layer (aka Inspector) associated with the scene
  100876. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100877. */
  100878. debugLayer: DebugLayer;
  100879. }
  100880. /**
  100881. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100882. * what is happening in your scene
  100883. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100884. */
  100885. export class DebugLayer {
  100886. /**
  100887. * Define the url to get the inspector script from.
  100888. * By default it uses the babylonjs CDN.
  100889. * @ignoreNaming
  100890. */
  100891. static InspectorURL: string;
  100892. private _scene;
  100893. private BJSINSPECTOR;
  100894. /**
  100895. * Observable triggered when a property is changed through the inspector.
  100896. */
  100897. onPropertyChangedObservable: Observable<{
  100898. object: any;
  100899. property: string;
  100900. value: any;
  100901. initialValue: any;
  100902. }>;
  100903. /**
  100904. * Instantiates a new debug layer.
  100905. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100906. * what is happening in your scene
  100907. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100908. * @param scene Defines the scene to inspect
  100909. */
  100910. constructor(scene: Scene);
  100911. /** Creates the inspector window. */
  100912. private _createInspector;
  100913. /**
  100914. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100915. * @param entity defines the entity to select
  100916. * @param lineContainerTitle defines the specific block to highlight
  100917. */
  100918. select(entity: any, lineContainerTitle?: string): void;
  100919. /** Get the inspector from bundle or global */
  100920. private _getGlobalInspector;
  100921. /**
  100922. * Get if the inspector is visible or not.
  100923. * @returns true if visible otherwise, false
  100924. */
  100925. isVisible(): boolean;
  100926. /**
  100927. * Hide the inspector and close its window.
  100928. */
  100929. hide(): void;
  100930. /**
  100931. * Launch the debugLayer.
  100932. * @param config Define the configuration of the inspector
  100933. * @return a promise fulfilled when the debug layer is visible
  100934. */
  100935. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100936. }
  100937. }
  100938. declare module BABYLON {
  100939. /**
  100940. * Class containing static functions to help procedurally build meshes
  100941. */
  100942. export class BoxBuilder {
  100943. /**
  100944. * Creates a box mesh
  100945. * * The parameter `size` sets the size (float) of each box side (default 1)
  100946. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100947. * * 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)
  100948. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100950. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100952. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100953. * @param name defines the name of the mesh
  100954. * @param options defines the options used to create the mesh
  100955. * @param scene defines the hosting scene
  100956. * @returns the box mesh
  100957. */
  100958. static CreateBox(name: string, options: {
  100959. size?: number;
  100960. width?: number;
  100961. height?: number;
  100962. depth?: number;
  100963. faceUV?: Vector4[];
  100964. faceColors?: Color4[];
  100965. sideOrientation?: number;
  100966. frontUVs?: Vector4;
  100967. backUVs?: Vector4;
  100968. wrap?: boolean;
  100969. topBaseAt?: number;
  100970. bottomBaseAt?: number;
  100971. updatable?: boolean;
  100972. }, scene?: Nullable<Scene>): Mesh;
  100973. }
  100974. }
  100975. declare module BABYLON {
  100976. /**
  100977. * Class containing static functions to help procedurally build meshes
  100978. */
  100979. export class SphereBuilder {
  100980. /**
  100981. * Creates a sphere mesh
  100982. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100983. * * 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`)
  100984. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100985. * * 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
  100986. * * 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)
  100987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100988. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100990. * @param name defines the name of the mesh
  100991. * @param options defines the options used to create the mesh
  100992. * @param scene defines the hosting scene
  100993. * @returns the sphere mesh
  100994. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100995. */
  100996. static CreateSphere(name: string, options: {
  100997. segments?: number;
  100998. diameter?: number;
  100999. diameterX?: number;
  101000. diameterY?: number;
  101001. diameterZ?: number;
  101002. arc?: number;
  101003. slice?: number;
  101004. sideOrientation?: number;
  101005. frontUVs?: Vector4;
  101006. backUVs?: Vector4;
  101007. updatable?: boolean;
  101008. }, scene: any): Mesh;
  101009. }
  101010. }
  101011. declare module BABYLON.Debug {
  101012. /**
  101013. * Used to show the physics impostor around the specific mesh
  101014. */
  101015. export class PhysicsViewer {
  101016. /** @hidden */
  101017. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  101018. /** @hidden */
  101019. protected _meshes: Array<Nullable<AbstractMesh>>;
  101020. /** @hidden */
  101021. protected _scene: Nullable<Scene>;
  101022. /** @hidden */
  101023. protected _numMeshes: number;
  101024. /** @hidden */
  101025. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  101026. private _renderFunction;
  101027. private _utilityLayer;
  101028. private _debugBoxMesh;
  101029. private _debugSphereMesh;
  101030. private _debugCylinderMesh;
  101031. private _debugMaterial;
  101032. private _debugMeshMeshes;
  101033. /**
  101034. * Creates a new PhysicsViewer
  101035. * @param scene defines the hosting scene
  101036. */
  101037. constructor(scene: Scene);
  101038. /** @hidden */
  101039. protected _updateDebugMeshes(): void;
  101040. /**
  101041. * Renders a specified physic impostor
  101042. * @param impostor defines the impostor to render
  101043. * @param targetMesh defines the mesh represented by the impostor
  101044. * @returns the new debug mesh used to render the impostor
  101045. */
  101046. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  101047. /**
  101048. * Hides a specified physic impostor
  101049. * @param impostor defines the impostor to hide
  101050. */
  101051. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  101052. private _getDebugMaterial;
  101053. private _getDebugBoxMesh;
  101054. private _getDebugSphereMesh;
  101055. private _getDebugCylinderMesh;
  101056. private _getDebugMeshMesh;
  101057. private _getDebugMesh;
  101058. /** Releases all resources */
  101059. dispose(): void;
  101060. }
  101061. }
  101062. declare module BABYLON {
  101063. /**
  101064. * Class containing static functions to help procedurally build meshes
  101065. */
  101066. export class LinesBuilder {
  101067. /**
  101068. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  101069. * * 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
  101070. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  101071. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  101072. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  101073. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  101074. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  101075. * * 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
  101076. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  101077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101078. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  101079. * @param name defines the name of the new line system
  101080. * @param options defines the options used to create the line system
  101081. * @param scene defines the hosting scene
  101082. * @returns a new line system mesh
  101083. */
  101084. static CreateLineSystem(name: string, options: {
  101085. lines: Vector3[][];
  101086. updatable?: boolean;
  101087. instance?: Nullable<LinesMesh>;
  101088. colors?: Nullable<Color4[][]>;
  101089. useVertexAlpha?: boolean;
  101090. }, scene: Nullable<Scene>): LinesMesh;
  101091. /**
  101092. * Creates a line mesh
  101093. * 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
  101094. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101095. * * The parameter `points` is an array successive Vector3
  101096. * * 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
  101097. * * The optional parameter `colors` is an array of successive Color4, one per line point
  101098. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  101099. * * When updating an instance, remember that only point positions can change, not the number of points
  101100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  101102. * @param name defines the name of the new line system
  101103. * @param options defines the options used to create the line system
  101104. * @param scene defines the hosting scene
  101105. * @returns a new line mesh
  101106. */
  101107. static CreateLines(name: string, options: {
  101108. points: Vector3[];
  101109. updatable?: boolean;
  101110. instance?: Nullable<LinesMesh>;
  101111. colors?: Color4[];
  101112. useVertexAlpha?: boolean;
  101113. }, scene?: Nullable<Scene>): LinesMesh;
  101114. /**
  101115. * Creates a dashed line mesh
  101116. * * 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
  101117. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101118. * * The parameter `points` is an array successive Vector3
  101119. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  101120. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  101121. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101122. * * 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
  101123. * * When updating an instance, remember that only point positions can change, not the number of points
  101124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101125. * @param name defines the name of the mesh
  101126. * @param options defines the options used to create the mesh
  101127. * @param scene defines the hosting scene
  101128. * @returns the dashed line mesh
  101129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  101130. */
  101131. static CreateDashedLines(name: string, options: {
  101132. points: Vector3[];
  101133. dashSize?: number;
  101134. gapSize?: number;
  101135. dashNb?: number;
  101136. updatable?: boolean;
  101137. instance?: LinesMesh;
  101138. }, scene?: Nullable<Scene>): LinesMesh;
  101139. }
  101140. }
  101141. declare module BABYLON {
  101142. /**
  101143. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101144. * in order to better appreciate the issue one might have.
  101145. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101146. */
  101147. export class RayHelper {
  101148. /**
  101149. * Defines the ray we are currently tryin to visualize.
  101150. */
  101151. ray: Nullable<Ray>;
  101152. private _renderPoints;
  101153. private _renderLine;
  101154. private _renderFunction;
  101155. private _scene;
  101156. private _updateToMeshFunction;
  101157. private _attachedToMesh;
  101158. private _meshSpaceDirection;
  101159. private _meshSpaceOrigin;
  101160. /**
  101161. * Helper function to create a colored helper in a scene in one line.
  101162. * @param ray Defines the ray we are currently tryin to visualize
  101163. * @param scene Defines the scene the ray is used in
  101164. * @param color Defines the color we want to see the ray in
  101165. * @returns The newly created ray helper.
  101166. */
  101167. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  101168. /**
  101169. * Instantiate a new ray helper.
  101170. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101171. * in order to better appreciate the issue one might have.
  101172. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101173. * @param ray Defines the ray we are currently tryin to visualize
  101174. */
  101175. constructor(ray: Ray);
  101176. /**
  101177. * Shows the ray we are willing to debug.
  101178. * @param scene Defines the scene the ray needs to be rendered in
  101179. * @param color Defines the color the ray needs to be rendered in
  101180. */
  101181. show(scene: Scene, color?: Color3): void;
  101182. /**
  101183. * Hides the ray we are debugging.
  101184. */
  101185. hide(): void;
  101186. private _render;
  101187. /**
  101188. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  101189. * @param mesh Defines the mesh we want the helper attached to
  101190. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  101191. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  101192. * @param length Defines the length of the ray
  101193. */
  101194. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  101195. /**
  101196. * Detach the ray helper from the mesh it has previously been attached to.
  101197. */
  101198. detachFromMesh(): void;
  101199. private _updateToMesh;
  101200. /**
  101201. * Dispose the helper and release its associated resources.
  101202. */
  101203. dispose(): void;
  101204. }
  101205. }
  101206. declare module BABYLON.Debug {
  101207. /**
  101208. * Class used to render a debug view of a given skeleton
  101209. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  101210. */
  101211. export class SkeletonViewer {
  101212. /** defines the skeleton to render */
  101213. skeleton: Skeleton;
  101214. /** defines the mesh attached to the skeleton */
  101215. mesh: AbstractMesh;
  101216. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101217. autoUpdateBonesMatrices: boolean;
  101218. /** defines the rendering group id to use with the viewer */
  101219. renderingGroupId: number;
  101220. /** Gets or sets the color used to render the skeleton */
  101221. color: Color3;
  101222. private _scene;
  101223. private _debugLines;
  101224. private _debugMesh;
  101225. private _isEnabled;
  101226. private _renderFunction;
  101227. private _utilityLayer;
  101228. /**
  101229. * Returns the mesh used to render the bones
  101230. */
  101231. readonly debugMesh: Nullable<LinesMesh>;
  101232. /**
  101233. * Creates a new SkeletonViewer
  101234. * @param skeleton defines the skeleton to render
  101235. * @param mesh defines the mesh attached to the skeleton
  101236. * @param scene defines the hosting scene
  101237. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  101238. * @param renderingGroupId defines the rendering group id to use with the viewer
  101239. */
  101240. constructor(
  101241. /** defines the skeleton to render */
  101242. skeleton: Skeleton,
  101243. /** defines the mesh attached to the skeleton */
  101244. mesh: AbstractMesh, scene: Scene,
  101245. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101246. autoUpdateBonesMatrices?: boolean,
  101247. /** defines the rendering group id to use with the viewer */
  101248. renderingGroupId?: number);
  101249. /** Gets or sets a boolean indicating if the viewer is enabled */
  101250. isEnabled: boolean;
  101251. private _getBonePosition;
  101252. private _getLinesForBonesWithLength;
  101253. private _getLinesForBonesNoLength;
  101254. /** Update the viewer to sync with current skeleton state */
  101255. update(): void;
  101256. /** Release associated resources */
  101257. dispose(): void;
  101258. }
  101259. }
  101260. declare module BABYLON {
  101261. /**
  101262. * Options to create the null engine
  101263. */
  101264. export class NullEngineOptions {
  101265. /**
  101266. * Render width (Default: 512)
  101267. */
  101268. renderWidth: number;
  101269. /**
  101270. * Render height (Default: 256)
  101271. */
  101272. renderHeight: number;
  101273. /**
  101274. * Texture size (Default: 512)
  101275. */
  101276. textureSize: number;
  101277. /**
  101278. * If delta time between frames should be constant
  101279. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101280. */
  101281. deterministicLockstep: boolean;
  101282. /**
  101283. * Maximum about of steps between frames (Default: 4)
  101284. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101285. */
  101286. lockstepMaxSteps: number;
  101287. }
  101288. /**
  101289. * The null engine class provides support for headless version of babylon.js.
  101290. * This can be used in server side scenario or for testing purposes
  101291. */
  101292. export class NullEngine extends Engine {
  101293. private _options;
  101294. /**
  101295. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101296. */
  101297. isDeterministicLockStep(): boolean;
  101298. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  101299. getLockstepMaxSteps(): number;
  101300. /**
  101301. * Sets hardware scaling, used to save performance if needed
  101302. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101303. */
  101304. getHardwareScalingLevel(): number;
  101305. constructor(options?: NullEngineOptions);
  101306. createVertexBuffer(vertices: FloatArray): DataBuffer;
  101307. createIndexBuffer(indices: IndicesArray): DataBuffer;
  101308. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101309. getRenderWidth(useScreen?: boolean): number;
  101310. getRenderHeight(useScreen?: boolean): number;
  101311. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  101312. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  101313. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101314. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101315. bindSamplers(effect: Effect): void;
  101316. enableEffect(effect: Effect): void;
  101317. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101318. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  101319. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  101320. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  101321. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  101322. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  101323. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  101324. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  101325. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  101326. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  101327. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  101328. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  101329. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  101330. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  101331. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  101332. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101333. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101334. setFloat(uniform: WebGLUniformLocation, value: number): void;
  101335. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  101336. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  101337. setBool(uniform: WebGLUniformLocation, bool: number): void;
  101338. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  101339. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  101340. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  101341. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101342. bindBuffers(vertexBuffers: {
  101343. [key: string]: VertexBuffer;
  101344. }, indexBuffer: DataBuffer, effect: Effect): void;
  101345. wipeCaches(bruteForce?: boolean): void;
  101346. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101347. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101348. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101349. /** @hidden */
  101350. _createTexture(): WebGLTexture;
  101351. /** @hidden */
  101352. _releaseTexture(texture: InternalTexture): void;
  101353. 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;
  101354. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  101355. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  101356. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  101357. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101358. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  101359. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  101360. areAllEffectsReady(): boolean;
  101361. /**
  101362. * @hidden
  101363. * Get the current error code of the webGL context
  101364. * @returns the error code
  101365. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  101366. */
  101367. getError(): number;
  101368. /** @hidden */
  101369. _getUnpackAlignement(): number;
  101370. /** @hidden */
  101371. _unpackFlipY(value: boolean): void;
  101372. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  101373. /**
  101374. * Updates a dynamic vertex buffer.
  101375. * @param vertexBuffer the vertex buffer to update
  101376. * @param data the data used to update the vertex buffer
  101377. * @param byteOffset the byte offset of the data (optional)
  101378. * @param byteLength the byte length of the data (optional)
  101379. */
  101380. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  101381. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  101382. /** @hidden */
  101383. _bindTexture(channel: number, texture: InternalTexture): void;
  101384. /** @hidden */
  101385. _releaseBuffer(buffer: DataBuffer): boolean;
  101386. releaseEffects(): void;
  101387. displayLoadingUI(): void;
  101388. hideLoadingUI(): void;
  101389. /** @hidden */
  101390. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101391. /** @hidden */
  101392. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101393. /** @hidden */
  101394. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101395. /** @hidden */
  101396. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  101397. }
  101398. }
  101399. declare module BABYLON {
  101400. /** @hidden */
  101401. export class _OcclusionDataStorage {
  101402. /** @hidden */
  101403. occlusionInternalRetryCounter: number;
  101404. /** @hidden */
  101405. isOcclusionQueryInProgress: boolean;
  101406. /** @hidden */
  101407. isOccluded: boolean;
  101408. /** @hidden */
  101409. occlusionRetryCount: number;
  101410. /** @hidden */
  101411. occlusionType: number;
  101412. /** @hidden */
  101413. occlusionQueryAlgorithmType: number;
  101414. }
  101415. interface Engine {
  101416. /**
  101417. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  101418. * @return the new query
  101419. */
  101420. createQuery(): WebGLQuery;
  101421. /**
  101422. * Delete and release a webGL query
  101423. * @param query defines the query to delete
  101424. * @return the current engine
  101425. */
  101426. deleteQuery(query: WebGLQuery): Engine;
  101427. /**
  101428. * Check if a given query has resolved and got its value
  101429. * @param query defines the query to check
  101430. * @returns true if the query got its value
  101431. */
  101432. isQueryResultAvailable(query: WebGLQuery): boolean;
  101433. /**
  101434. * Gets the value of a given query
  101435. * @param query defines the query to check
  101436. * @returns the value of the query
  101437. */
  101438. getQueryResult(query: WebGLQuery): number;
  101439. /**
  101440. * Initiates an occlusion query
  101441. * @param algorithmType defines the algorithm to use
  101442. * @param query defines the query to use
  101443. * @returns the current engine
  101444. * @see http://doc.babylonjs.com/features/occlusionquery
  101445. */
  101446. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  101447. /**
  101448. * Ends an occlusion query
  101449. * @see http://doc.babylonjs.com/features/occlusionquery
  101450. * @param algorithmType defines the algorithm to use
  101451. * @returns the current engine
  101452. */
  101453. endOcclusionQuery(algorithmType: number): Engine;
  101454. /**
  101455. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  101456. * Please note that only one query can be issued at a time
  101457. * @returns a time token used to track the time span
  101458. */
  101459. startTimeQuery(): Nullable<_TimeToken>;
  101460. /**
  101461. * Ends a time query
  101462. * @param token defines the token used to measure the time span
  101463. * @returns the time spent (in ns)
  101464. */
  101465. endTimeQuery(token: _TimeToken): int;
  101466. /** @hidden */
  101467. _currentNonTimestampToken: Nullable<_TimeToken>;
  101468. /** @hidden */
  101469. _createTimeQuery(): WebGLQuery;
  101470. /** @hidden */
  101471. _deleteTimeQuery(query: WebGLQuery): void;
  101472. /** @hidden */
  101473. _getGlAlgorithmType(algorithmType: number): number;
  101474. /** @hidden */
  101475. _getTimeQueryResult(query: WebGLQuery): any;
  101476. /** @hidden */
  101477. _getTimeQueryAvailability(query: WebGLQuery): any;
  101478. }
  101479. interface AbstractMesh {
  101480. /**
  101481. * Backing filed
  101482. * @hidden
  101483. */
  101484. __occlusionDataStorage: _OcclusionDataStorage;
  101485. /**
  101486. * Access property
  101487. * @hidden
  101488. */
  101489. _occlusionDataStorage: _OcclusionDataStorage;
  101490. /**
  101491. * 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.
  101492. * The default value is -1 which means don't break the query and wait till the result
  101493. * @see http://doc.babylonjs.com/features/occlusionquery
  101494. */
  101495. occlusionRetryCount: number;
  101496. /**
  101497. * 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:
  101498. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  101499. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  101500. * * 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.
  101501. * @see http://doc.babylonjs.com/features/occlusionquery
  101502. */
  101503. occlusionType: number;
  101504. /**
  101505. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  101506. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  101507. * * 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.
  101508. * @see http://doc.babylonjs.com/features/occlusionquery
  101509. */
  101510. occlusionQueryAlgorithmType: number;
  101511. /**
  101512. * 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
  101513. * @see http://doc.babylonjs.com/features/occlusionquery
  101514. */
  101515. isOccluded: boolean;
  101516. /**
  101517. * Flag to check the progress status of the query
  101518. * @see http://doc.babylonjs.com/features/occlusionquery
  101519. */
  101520. isOcclusionQueryInProgress: boolean;
  101521. }
  101522. }
  101523. declare module BABYLON {
  101524. /** @hidden */
  101525. export var _forceTransformFeedbackToBundle: boolean;
  101526. interface Engine {
  101527. /**
  101528. * Creates a webGL transform feedback object
  101529. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  101530. * @returns the webGL transform feedback object
  101531. */
  101532. createTransformFeedback(): WebGLTransformFeedback;
  101533. /**
  101534. * Delete a webGL transform feedback object
  101535. * @param value defines the webGL transform feedback object to delete
  101536. */
  101537. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  101538. /**
  101539. * Bind a webGL transform feedback object to the webgl context
  101540. * @param value defines the webGL transform feedback object to bind
  101541. */
  101542. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  101543. /**
  101544. * Begins a transform feedback operation
  101545. * @param usePoints defines if points or triangles must be used
  101546. */
  101547. beginTransformFeedback(usePoints: boolean): void;
  101548. /**
  101549. * Ends a transform feedback operation
  101550. */
  101551. endTransformFeedback(): void;
  101552. /**
  101553. * Specify the varyings to use with transform feedback
  101554. * @param program defines the associated webGL program
  101555. * @param value defines the list of strings representing the varying names
  101556. */
  101557. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  101558. /**
  101559. * Bind a webGL buffer for a transform feedback operation
  101560. * @param value defines the webGL buffer to bind
  101561. */
  101562. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  101563. }
  101564. }
  101565. declare module BABYLON {
  101566. /**
  101567. * Creation options of the multi render target texture.
  101568. */
  101569. export interface IMultiRenderTargetOptions {
  101570. /**
  101571. * Define if the texture needs to create mip maps after render.
  101572. */
  101573. generateMipMaps?: boolean;
  101574. /**
  101575. * Define the types of all the draw buffers we want to create
  101576. */
  101577. types?: number[];
  101578. /**
  101579. * Define the sampling modes of all the draw buffers we want to create
  101580. */
  101581. samplingModes?: number[];
  101582. /**
  101583. * Define if a depth buffer is required
  101584. */
  101585. generateDepthBuffer?: boolean;
  101586. /**
  101587. * Define if a stencil buffer is required
  101588. */
  101589. generateStencilBuffer?: boolean;
  101590. /**
  101591. * Define if a depth texture is required instead of a depth buffer
  101592. */
  101593. generateDepthTexture?: boolean;
  101594. /**
  101595. * Define the number of desired draw buffers
  101596. */
  101597. textureCount?: number;
  101598. /**
  101599. * Define if aspect ratio should be adapted to the texture or stay the scene one
  101600. */
  101601. doNotChangeAspectRatio?: boolean;
  101602. /**
  101603. * Define the default type of the buffers we are creating
  101604. */
  101605. defaultType?: number;
  101606. }
  101607. /**
  101608. * A multi render target, like a render target provides the ability to render to a texture.
  101609. * Unlike the render target, it can render to several draw buffers in one draw.
  101610. * This is specially interesting in deferred rendering or for any effects requiring more than
  101611. * just one color from a single pass.
  101612. */
  101613. export class MultiRenderTarget extends RenderTargetTexture {
  101614. private _internalTextures;
  101615. private _textures;
  101616. private _multiRenderTargetOptions;
  101617. /**
  101618. * Get if draw buffers are currently supported by the used hardware and browser.
  101619. */
  101620. readonly isSupported: boolean;
  101621. /**
  101622. * Get the list of textures generated by the multi render target.
  101623. */
  101624. readonly textures: Texture[];
  101625. /**
  101626. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  101627. */
  101628. readonly depthTexture: Texture;
  101629. /**
  101630. * Set the wrapping mode on U of all the textures we are rendering to.
  101631. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101632. */
  101633. wrapU: number;
  101634. /**
  101635. * Set the wrapping mode on V of all the textures we are rendering to.
  101636. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101637. */
  101638. wrapV: number;
  101639. /**
  101640. * Instantiate a new multi render target texture.
  101641. * A multi render target, like a render target provides the ability to render to a texture.
  101642. * Unlike the render target, it can render to several draw buffers in one draw.
  101643. * This is specially interesting in deferred rendering or for any effects requiring more than
  101644. * just one color from a single pass.
  101645. * @param name Define the name of the texture
  101646. * @param size Define the size of the buffers to render to
  101647. * @param count Define the number of target we are rendering into
  101648. * @param scene Define the scene the texture belongs to
  101649. * @param options Define the options used to create the multi render target
  101650. */
  101651. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  101652. /** @hidden */
  101653. _rebuild(): void;
  101654. private _createInternalTextures;
  101655. private _createTextures;
  101656. /**
  101657. * Define the number of samples used if MSAA is enabled.
  101658. */
  101659. samples: number;
  101660. /**
  101661. * Resize all the textures in the multi render target.
  101662. * Be carrefull as it will recreate all the data in the new texture.
  101663. * @param size Define the new size
  101664. */
  101665. resize(size: any): void;
  101666. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101667. /**
  101668. * Dispose the render targets and their associated resources
  101669. */
  101670. dispose(): void;
  101671. /**
  101672. * Release all the underlying texture used as draw buffers.
  101673. */
  101674. releaseInternalTextures(): void;
  101675. }
  101676. }
  101677. declare module BABYLON {
  101678. interface Engine {
  101679. /**
  101680. * Unbind a list of render target textures from the webGL context
  101681. * This is used only when drawBuffer extension or webGL2 are active
  101682. * @param textures defines the render target textures to unbind
  101683. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101684. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101685. */
  101686. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  101687. /**
  101688. * Create a multi render target texture
  101689. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  101690. * @param size defines the size of the texture
  101691. * @param options defines the creation options
  101692. * @returns the cube texture as an InternalTexture
  101693. */
  101694. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  101695. /**
  101696. * Update the sample count for a given multiple render target texture
  101697. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  101698. * @param textures defines the textures to update
  101699. * @param samples defines the sample count to set
  101700. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  101701. */
  101702. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  101703. }
  101704. }
  101705. declare module BABYLON {
  101706. /**
  101707. * Gather the list of clipboard event types as constants.
  101708. */
  101709. export class ClipboardEventTypes {
  101710. /**
  101711. * The clipboard event is fired when a copy command is active (pressed).
  101712. */
  101713. static readonly COPY: number;
  101714. /**
  101715. * The clipboard event is fired when a cut command is active (pressed).
  101716. */
  101717. static readonly CUT: number;
  101718. /**
  101719. * The clipboard event is fired when a paste command is active (pressed).
  101720. */
  101721. static readonly PASTE: number;
  101722. }
  101723. /**
  101724. * This class is used to store clipboard related info for the onClipboardObservable event.
  101725. */
  101726. export class ClipboardInfo {
  101727. /**
  101728. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101729. */
  101730. type: number;
  101731. /**
  101732. * Defines the related dom event
  101733. */
  101734. event: ClipboardEvent;
  101735. /**
  101736. *Creates an instance of ClipboardInfo.
  101737. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  101738. * @param event Defines the related dom event
  101739. */
  101740. constructor(
  101741. /**
  101742. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101743. */
  101744. type: number,
  101745. /**
  101746. * Defines the related dom event
  101747. */
  101748. event: ClipboardEvent);
  101749. /**
  101750. * Get the clipboard event's type from the keycode.
  101751. * @param keyCode Defines the keyCode for the current keyboard event.
  101752. * @return {number}
  101753. */
  101754. static GetTypeFromCharacter(keyCode: number): number;
  101755. }
  101756. }
  101757. declare module BABYLON {
  101758. /**
  101759. * Class used to represent data loading progression
  101760. */
  101761. export class SceneLoaderProgressEvent {
  101762. /** defines if data length to load can be evaluated */
  101763. readonly lengthComputable: boolean;
  101764. /** defines the loaded data length */
  101765. readonly loaded: number;
  101766. /** defines the data length to load */
  101767. readonly total: number;
  101768. /**
  101769. * Create a new progress event
  101770. * @param lengthComputable defines if data length to load can be evaluated
  101771. * @param loaded defines the loaded data length
  101772. * @param total defines the data length to load
  101773. */
  101774. constructor(
  101775. /** defines if data length to load can be evaluated */
  101776. lengthComputable: boolean,
  101777. /** defines the loaded data length */
  101778. loaded: number,
  101779. /** defines the data length to load */
  101780. total: number);
  101781. /**
  101782. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  101783. * @param event defines the source event
  101784. * @returns a new SceneLoaderProgressEvent
  101785. */
  101786. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  101787. }
  101788. /**
  101789. * Interface used by SceneLoader plugins to define supported file extensions
  101790. */
  101791. export interface ISceneLoaderPluginExtensions {
  101792. /**
  101793. * Defines the list of supported extensions
  101794. */
  101795. [extension: string]: {
  101796. isBinary: boolean;
  101797. };
  101798. }
  101799. /**
  101800. * Interface used by SceneLoader plugin factory
  101801. */
  101802. export interface ISceneLoaderPluginFactory {
  101803. /**
  101804. * Defines the name of the factory
  101805. */
  101806. name: string;
  101807. /**
  101808. * Function called to create a new plugin
  101809. * @return the new plugin
  101810. */
  101811. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  101812. /**
  101813. * Boolean indicating if the plugin can direct load specific data
  101814. */
  101815. canDirectLoad?: (data: string) => boolean;
  101816. }
  101817. /**
  101818. * Interface used to define a SceneLoader plugin
  101819. */
  101820. export interface ISceneLoaderPlugin {
  101821. /**
  101822. * The friendly name of this plugin.
  101823. */
  101824. name: string;
  101825. /**
  101826. * The file extensions supported by this plugin.
  101827. */
  101828. extensions: string | ISceneLoaderPluginExtensions;
  101829. /**
  101830. * Import meshes into a scene.
  101831. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101832. * @param scene The scene to import into
  101833. * @param data The data to import
  101834. * @param rootUrl The root url for scene and resources
  101835. * @param meshes The meshes array to import into
  101836. * @param particleSystems The particle systems array to import into
  101837. * @param skeletons The skeletons array to import into
  101838. * @param onError The callback when import fails
  101839. * @returns True if successful or false otherwise
  101840. */
  101841. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  101842. /**
  101843. * Load into a scene.
  101844. * @param scene The scene to load into
  101845. * @param data The data to import
  101846. * @param rootUrl The root url for scene and resources
  101847. * @param onError The callback when import fails
  101848. * @returns true if successful or false otherwise
  101849. */
  101850. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  101851. /**
  101852. * The callback that returns true if the data can be directly loaded.
  101853. */
  101854. canDirectLoad?: (data: string) => boolean;
  101855. /**
  101856. * The callback that allows custom handling of the root url based on the response url.
  101857. */
  101858. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101859. /**
  101860. * Load into an asset container.
  101861. * @param scene The scene to load into
  101862. * @param data The data to import
  101863. * @param rootUrl The root url for scene and resources
  101864. * @param onError The callback when import fails
  101865. * @returns The loaded asset container
  101866. */
  101867. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  101868. }
  101869. /**
  101870. * Interface used to define an async SceneLoader plugin
  101871. */
  101872. export interface ISceneLoaderPluginAsync {
  101873. /**
  101874. * The friendly name of this plugin.
  101875. */
  101876. name: string;
  101877. /**
  101878. * The file extensions supported by this plugin.
  101879. */
  101880. extensions: string | ISceneLoaderPluginExtensions;
  101881. /**
  101882. * Import meshes into a scene.
  101883. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101884. * @param scene The scene to import into
  101885. * @param data The data to import
  101886. * @param rootUrl The root url for scene and resources
  101887. * @param onProgress The callback when the load progresses
  101888. * @param fileName Defines the name of the file to load
  101889. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  101890. */
  101891. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  101892. meshes: AbstractMesh[];
  101893. particleSystems: IParticleSystem[];
  101894. skeletons: Skeleton[];
  101895. animationGroups: AnimationGroup[];
  101896. }>;
  101897. /**
  101898. * Load into a scene.
  101899. * @param scene The scene to load into
  101900. * @param data The data to import
  101901. * @param rootUrl The root url for scene and resources
  101902. * @param onProgress The callback when the load progresses
  101903. * @param fileName Defines the name of the file to load
  101904. * @returns Nothing
  101905. */
  101906. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  101907. /**
  101908. * The callback that returns true if the data can be directly loaded.
  101909. */
  101910. canDirectLoad?: (data: string) => boolean;
  101911. /**
  101912. * The callback that allows custom handling of the root url based on the response url.
  101913. */
  101914. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101915. /**
  101916. * Load into an asset container.
  101917. * @param scene The scene to load into
  101918. * @param data The data to import
  101919. * @param rootUrl The root url for scene and resources
  101920. * @param onProgress The callback when the load progresses
  101921. * @param fileName Defines the name of the file to load
  101922. * @returns The loaded asset container
  101923. */
  101924. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  101925. }
  101926. /**
  101927. * Class used to load scene from various file formats using registered plugins
  101928. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  101929. */
  101930. export class SceneLoader {
  101931. /**
  101932. * No logging while loading
  101933. */
  101934. static readonly NO_LOGGING: number;
  101935. /**
  101936. * Minimal logging while loading
  101937. */
  101938. static readonly MINIMAL_LOGGING: number;
  101939. /**
  101940. * Summary logging while loading
  101941. */
  101942. static readonly SUMMARY_LOGGING: number;
  101943. /**
  101944. * Detailled logging while loading
  101945. */
  101946. static readonly DETAILED_LOGGING: number;
  101947. /**
  101948. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101949. */
  101950. static ForceFullSceneLoadingForIncremental: boolean;
  101951. /**
  101952. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101953. */
  101954. static ShowLoadingScreen: boolean;
  101955. /**
  101956. * Defines the current logging level (while loading the scene)
  101957. * @ignorenaming
  101958. */
  101959. static loggingLevel: number;
  101960. /**
  101961. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101962. */
  101963. static CleanBoneMatrixWeights: boolean;
  101964. /**
  101965. * Event raised when a plugin is used to load a scene
  101966. */
  101967. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101968. private static _registeredPlugins;
  101969. private static _getDefaultPlugin;
  101970. private static _getPluginForExtension;
  101971. private static _getPluginForDirectLoad;
  101972. private static _getPluginForFilename;
  101973. private static _getDirectLoad;
  101974. private static _loadData;
  101975. private static _getFileInfo;
  101976. /**
  101977. * Gets a plugin that can load the given extension
  101978. * @param extension defines the extension to load
  101979. * @returns a plugin or null if none works
  101980. */
  101981. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101982. /**
  101983. * Gets a boolean indicating that the given extension can be loaded
  101984. * @param extension defines the extension to load
  101985. * @returns true if the extension is supported
  101986. */
  101987. static IsPluginForExtensionAvailable(extension: string): boolean;
  101988. /**
  101989. * Adds a new plugin to the list of registered plugins
  101990. * @param plugin defines the plugin to add
  101991. */
  101992. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101993. /**
  101994. * Import meshes into a scene
  101995. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101996. * @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)
  101997. * @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)
  101998. * @param scene the instance of BABYLON.Scene to append to
  101999. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  102000. * @param onProgress a callback with a progress event for each file being loaded
  102001. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102002. * @param pluginExtension the extension used to determine the plugin
  102003. * @returns The loaded plugin
  102004. */
  102005. 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>;
  102006. /**
  102007. * Import meshes into a scene
  102008. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  102009. * @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)
  102010. * @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)
  102011. * @param scene the instance of BABYLON.Scene to append to
  102012. * @param onProgress a callback with a progress event for each file being loaded
  102013. * @param pluginExtension the extension used to determine the plugin
  102014. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  102015. */
  102016. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  102017. meshes: AbstractMesh[];
  102018. particleSystems: IParticleSystem[];
  102019. skeletons: Skeleton[];
  102020. animationGroups: AnimationGroup[];
  102021. }>;
  102022. /**
  102023. * Load a scene
  102024. * @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)
  102025. * @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)
  102026. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102027. * @param onSuccess a callback with the scene when import succeeds
  102028. * @param onProgress a callback with a progress event for each file being loaded
  102029. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102030. * @param pluginExtension the extension used to determine the plugin
  102031. * @returns The loaded plugin
  102032. */
  102033. 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>;
  102034. /**
  102035. * Load a scene
  102036. * @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)
  102037. * @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)
  102038. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102039. * @param onProgress a callback with a progress event for each file being loaded
  102040. * @param pluginExtension the extension used to determine the plugin
  102041. * @returns The loaded scene
  102042. */
  102043. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102044. /**
  102045. * Append a scene
  102046. * @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)
  102047. * @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)
  102048. * @param scene is the instance of BABYLON.Scene to append to
  102049. * @param onSuccess a callback with the scene when import succeeds
  102050. * @param onProgress a callback with a progress event for each file being loaded
  102051. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102052. * @param pluginExtension the extension used to determine the plugin
  102053. * @returns The loaded plugin
  102054. */
  102055. 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>;
  102056. /**
  102057. * Append a scene
  102058. * @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)
  102059. * @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)
  102060. * @param scene is the instance of BABYLON.Scene to append to
  102061. * @param onProgress a callback with a progress event for each file being loaded
  102062. * @param pluginExtension the extension used to determine the plugin
  102063. * @returns The given scene
  102064. */
  102065. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102066. /**
  102067. * Load a scene into an asset container
  102068. * @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)
  102069. * @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)
  102070. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  102071. * @param onSuccess a callback with the scene when import succeeds
  102072. * @param onProgress a callback with a progress event for each file being loaded
  102073. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102074. * @param pluginExtension the extension used to determine the plugin
  102075. * @returns The loaded plugin
  102076. */
  102077. 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>;
  102078. /**
  102079. * Load a scene into an asset container
  102080. * @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)
  102081. * @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)
  102082. * @param scene is the instance of Scene to append to
  102083. * @param onProgress a callback with a progress event for each file being loaded
  102084. * @param pluginExtension the extension used to determine the plugin
  102085. * @returns The loaded asset container
  102086. */
  102087. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  102088. }
  102089. }
  102090. declare module BABYLON {
  102091. /**
  102092. * Google Daydream controller
  102093. */
  102094. export class DaydreamController extends WebVRController {
  102095. /**
  102096. * Base Url for the controller model.
  102097. */
  102098. static MODEL_BASE_URL: string;
  102099. /**
  102100. * File name for the controller model.
  102101. */
  102102. static MODEL_FILENAME: string;
  102103. /**
  102104. * Gamepad Id prefix used to identify Daydream Controller.
  102105. */
  102106. static readonly GAMEPAD_ID_PREFIX: string;
  102107. /**
  102108. * Creates a new DaydreamController from a gamepad
  102109. * @param vrGamepad the gamepad that the controller should be created from
  102110. */
  102111. constructor(vrGamepad: any);
  102112. /**
  102113. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102114. * @param scene scene in which to add meshes
  102115. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102116. */
  102117. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102118. /**
  102119. * Called once for each button that changed state since the last frame
  102120. * @param buttonIdx Which button index changed
  102121. * @param state New state of the button
  102122. * @param changes Which properties on the state changed since last frame
  102123. */
  102124. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102125. }
  102126. }
  102127. declare module BABYLON {
  102128. /**
  102129. * Gear VR Controller
  102130. */
  102131. export class GearVRController extends WebVRController {
  102132. /**
  102133. * Base Url for the controller model.
  102134. */
  102135. static MODEL_BASE_URL: string;
  102136. /**
  102137. * File name for the controller model.
  102138. */
  102139. static MODEL_FILENAME: string;
  102140. /**
  102141. * Gamepad Id prefix used to identify this controller.
  102142. */
  102143. static readonly GAMEPAD_ID_PREFIX: string;
  102144. private readonly _buttonIndexToObservableNameMap;
  102145. /**
  102146. * Creates a new GearVRController from a gamepad
  102147. * @param vrGamepad the gamepad that the controller should be created from
  102148. */
  102149. constructor(vrGamepad: any);
  102150. /**
  102151. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102152. * @param scene scene in which to add meshes
  102153. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102154. */
  102155. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102156. /**
  102157. * Called once for each button that changed state since the last frame
  102158. * @param buttonIdx Which button index changed
  102159. * @param state New state of the button
  102160. * @param changes Which properties on the state changed since last frame
  102161. */
  102162. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102163. }
  102164. }
  102165. declare module BABYLON {
  102166. /**
  102167. * Generic Controller
  102168. */
  102169. export class GenericController extends WebVRController {
  102170. /**
  102171. * Base Url for the controller model.
  102172. */
  102173. static readonly MODEL_BASE_URL: string;
  102174. /**
  102175. * File name for the controller model.
  102176. */
  102177. static readonly MODEL_FILENAME: string;
  102178. /**
  102179. * Creates a new GenericController from a gamepad
  102180. * @param vrGamepad the gamepad that the controller should be created from
  102181. */
  102182. constructor(vrGamepad: any);
  102183. /**
  102184. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102185. * @param scene scene in which to add meshes
  102186. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102187. */
  102188. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102189. /**
  102190. * Called once for each button that changed state since the last frame
  102191. * @param buttonIdx Which button index changed
  102192. * @param state New state of the button
  102193. * @param changes Which properties on the state changed since last frame
  102194. */
  102195. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102196. }
  102197. }
  102198. declare module BABYLON {
  102199. /**
  102200. * Oculus Touch Controller
  102201. */
  102202. export class OculusTouchController extends WebVRController {
  102203. /**
  102204. * Base Url for the controller model.
  102205. */
  102206. static MODEL_BASE_URL: string;
  102207. /**
  102208. * File name for the left controller model.
  102209. */
  102210. static MODEL_LEFT_FILENAME: string;
  102211. /**
  102212. * File name for the right controller model.
  102213. */
  102214. static MODEL_RIGHT_FILENAME: string;
  102215. /**
  102216. * Fired when the secondary trigger on this controller is modified
  102217. */
  102218. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  102219. /**
  102220. * Fired when the thumb rest on this controller is modified
  102221. */
  102222. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  102223. /**
  102224. * Creates a new OculusTouchController from a gamepad
  102225. * @param vrGamepad the gamepad that the controller should be created from
  102226. */
  102227. constructor(vrGamepad: any);
  102228. /**
  102229. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102230. * @param scene scene in which to add meshes
  102231. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102232. */
  102233. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102234. /**
  102235. * Fired when the A button on this controller is modified
  102236. */
  102237. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102238. /**
  102239. * Fired when the B button on this controller is modified
  102240. */
  102241. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102242. /**
  102243. * Fired when the X button on this controller is modified
  102244. */
  102245. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102246. /**
  102247. * Fired when the Y button on this controller is modified
  102248. */
  102249. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102250. /**
  102251. * Called once for each button that changed state since the last frame
  102252. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  102253. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  102254. * 2) secondary trigger (same)
  102255. * 3) A (right) X (left), touch, pressed = value
  102256. * 4) B / Y
  102257. * 5) thumb rest
  102258. * @param buttonIdx Which button index changed
  102259. * @param state New state of the button
  102260. * @param changes Which properties on the state changed since last frame
  102261. */
  102262. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102263. }
  102264. }
  102265. declare module BABYLON {
  102266. /**
  102267. * Vive Controller
  102268. */
  102269. export class ViveController extends WebVRController {
  102270. /**
  102271. * Base Url for the controller model.
  102272. */
  102273. static MODEL_BASE_URL: string;
  102274. /**
  102275. * File name for the controller model.
  102276. */
  102277. static MODEL_FILENAME: string;
  102278. /**
  102279. * Creates a new ViveController from a gamepad
  102280. * @param vrGamepad the gamepad that the controller should be created from
  102281. */
  102282. constructor(vrGamepad: any);
  102283. /**
  102284. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102285. * @param scene scene in which to add meshes
  102286. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102287. */
  102288. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102289. /**
  102290. * Fired when the left button on this controller is modified
  102291. */
  102292. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102293. /**
  102294. * Fired when the right button on this controller is modified
  102295. */
  102296. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102297. /**
  102298. * Fired when the menu button on this controller is modified
  102299. */
  102300. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102301. /**
  102302. * Called once for each button that changed state since the last frame
  102303. * Vive mapping:
  102304. * 0: touchpad
  102305. * 1: trigger
  102306. * 2: left AND right buttons
  102307. * 3: menu button
  102308. * @param buttonIdx Which button index changed
  102309. * @param state New state of the button
  102310. * @param changes Which properties on the state changed since last frame
  102311. */
  102312. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102313. }
  102314. }
  102315. declare module BABYLON {
  102316. /**
  102317. * Defines the WindowsMotionController object that the state of the windows motion controller
  102318. */
  102319. export class WindowsMotionController extends WebVRController {
  102320. /**
  102321. * The base url used to load the left and right controller models
  102322. */
  102323. static MODEL_BASE_URL: string;
  102324. /**
  102325. * The name of the left controller model file
  102326. */
  102327. static MODEL_LEFT_FILENAME: string;
  102328. /**
  102329. * The name of the right controller model file
  102330. */
  102331. static MODEL_RIGHT_FILENAME: string;
  102332. /**
  102333. * The controller name prefix for this controller type
  102334. */
  102335. static readonly GAMEPAD_ID_PREFIX: string;
  102336. /**
  102337. * The controller id pattern for this controller type
  102338. */
  102339. private static readonly GAMEPAD_ID_PATTERN;
  102340. private _loadedMeshInfo;
  102341. private readonly _mapping;
  102342. /**
  102343. * Fired when the trackpad on this controller is clicked
  102344. */
  102345. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  102346. /**
  102347. * Fired when the trackpad on this controller is modified
  102348. */
  102349. onTrackpadValuesChangedObservable: Observable<StickValues>;
  102350. /**
  102351. * The current x and y values of this controller's trackpad
  102352. */
  102353. trackpad: StickValues;
  102354. /**
  102355. * Creates a new WindowsMotionController from a gamepad
  102356. * @param vrGamepad the gamepad that the controller should be created from
  102357. */
  102358. constructor(vrGamepad: any);
  102359. /**
  102360. * Fired when the trigger on this controller is modified
  102361. */
  102362. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102363. /**
  102364. * Fired when the menu button on this controller is modified
  102365. */
  102366. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102367. /**
  102368. * Fired when the grip button on this controller is modified
  102369. */
  102370. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102371. /**
  102372. * Fired when the thumbstick button on this controller is modified
  102373. */
  102374. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102375. /**
  102376. * Fired when the touchpad button on this controller is modified
  102377. */
  102378. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102379. /**
  102380. * Fired when the touchpad values on this controller are modified
  102381. */
  102382. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  102383. private _updateTrackpad;
  102384. /**
  102385. * Called once per frame by the engine.
  102386. */
  102387. update(): void;
  102388. /**
  102389. * Called once for each button that changed state since the last frame
  102390. * @param buttonIdx Which button index changed
  102391. * @param state New state of the button
  102392. * @param changes Which properties on the state changed since last frame
  102393. */
  102394. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102395. /**
  102396. * Moves the buttons on the controller mesh based on their current state
  102397. * @param buttonName the name of the button to move
  102398. * @param buttonValue the value of the button which determines the buttons new position
  102399. */
  102400. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  102401. /**
  102402. * Moves the axis on the controller mesh based on its current state
  102403. * @param axis the index of the axis
  102404. * @param axisValue the value of the axis which determines the meshes new position
  102405. * @hidden
  102406. */
  102407. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  102408. /**
  102409. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102410. * @param scene scene in which to add meshes
  102411. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102412. */
  102413. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  102414. /**
  102415. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  102416. * can be transformed by button presses and axes values, based on this._mapping.
  102417. *
  102418. * @param scene scene in which the meshes exist
  102419. * @param meshes list of meshes that make up the controller model to process
  102420. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  102421. */
  102422. private processModel;
  102423. private createMeshInfo;
  102424. /**
  102425. * Gets the ray of the controller in the direction the controller is pointing
  102426. * @param length the length the resulting ray should be
  102427. * @returns a ray in the direction the controller is pointing
  102428. */
  102429. getForwardRay(length?: number): Ray;
  102430. /**
  102431. * Disposes of the controller
  102432. */
  102433. dispose(): void;
  102434. }
  102435. }
  102436. declare module BABYLON {
  102437. /**
  102438. * Single axis scale gizmo
  102439. */
  102440. export class AxisScaleGizmo extends Gizmo {
  102441. private _coloredMaterial;
  102442. /**
  102443. * Drag behavior responsible for the gizmos dragging interactions
  102444. */
  102445. dragBehavior: PointerDragBehavior;
  102446. private _pointerObserver;
  102447. /**
  102448. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102449. */
  102450. snapDistance: number;
  102451. /**
  102452. * Event that fires each time the gizmo snaps to a new location.
  102453. * * snapDistance is the the change in distance
  102454. */
  102455. onSnapObservable: Observable<{
  102456. snapDistance: number;
  102457. }>;
  102458. /**
  102459. * If the scaling operation should be done on all axis (default: false)
  102460. */
  102461. uniformScaling: boolean;
  102462. /**
  102463. * Creates an AxisScaleGizmo
  102464. * @param gizmoLayer The utility layer the gizmo will be added to
  102465. * @param dragAxis The axis which the gizmo will be able to scale on
  102466. * @param color The color of the gizmo
  102467. */
  102468. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102469. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102470. /**
  102471. * Disposes of the gizmo
  102472. */
  102473. dispose(): void;
  102474. /**
  102475. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  102476. * @param mesh The mesh to replace the default mesh of the gizmo
  102477. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  102478. */
  102479. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  102480. }
  102481. }
  102482. declare module BABYLON {
  102483. /**
  102484. * Bounding box gizmo
  102485. */
  102486. export class BoundingBoxGizmo extends Gizmo {
  102487. private _lineBoundingBox;
  102488. private _rotateSpheresParent;
  102489. private _scaleBoxesParent;
  102490. private _boundingDimensions;
  102491. private _renderObserver;
  102492. private _pointerObserver;
  102493. private _scaleDragSpeed;
  102494. private _tmpQuaternion;
  102495. private _tmpVector;
  102496. private _tmpRotationMatrix;
  102497. /**
  102498. * 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)
  102499. */
  102500. ignoreChildren: boolean;
  102501. /**
  102502. * 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)
  102503. */
  102504. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  102505. /**
  102506. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  102507. */
  102508. rotationSphereSize: number;
  102509. /**
  102510. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  102511. */
  102512. scaleBoxSize: number;
  102513. /**
  102514. * 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)
  102515. */
  102516. fixedDragMeshScreenSize: boolean;
  102517. /**
  102518. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  102519. */
  102520. fixedDragMeshScreenSizeDistanceFactor: number;
  102521. /**
  102522. * Fired when a rotation sphere or scale box is dragged
  102523. */
  102524. onDragStartObservable: Observable<{}>;
  102525. /**
  102526. * Fired when a scale box is dragged
  102527. */
  102528. onScaleBoxDragObservable: Observable<{}>;
  102529. /**
  102530. * Fired when a scale box drag is ended
  102531. */
  102532. onScaleBoxDragEndObservable: Observable<{}>;
  102533. /**
  102534. * Fired when a rotation sphere is dragged
  102535. */
  102536. onRotationSphereDragObservable: Observable<{}>;
  102537. /**
  102538. * Fired when a rotation sphere drag is ended
  102539. */
  102540. onRotationSphereDragEndObservable: Observable<{}>;
  102541. /**
  102542. * 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)
  102543. */
  102544. scalePivot: Nullable<Vector3>;
  102545. /**
  102546. * Mesh used as a pivot to rotate the attached mesh
  102547. */
  102548. private _anchorMesh;
  102549. private _existingMeshScale;
  102550. private _dragMesh;
  102551. private pointerDragBehavior;
  102552. private coloredMaterial;
  102553. private hoverColoredMaterial;
  102554. /**
  102555. * Sets the color of the bounding box gizmo
  102556. * @param color the color to set
  102557. */
  102558. setColor(color: Color3): void;
  102559. /**
  102560. * Creates an BoundingBoxGizmo
  102561. * @param gizmoLayer The utility layer the gizmo will be added to
  102562. * @param color The color of the gizmo
  102563. */
  102564. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102565. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102566. private _selectNode;
  102567. /**
  102568. * Updates the bounding box information for the Gizmo
  102569. */
  102570. updateBoundingBox(): void;
  102571. private _updateRotationSpheres;
  102572. private _updateScaleBoxes;
  102573. /**
  102574. * Enables rotation on the specified axis and disables rotation on the others
  102575. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  102576. */
  102577. setEnabledRotationAxis(axis: string): void;
  102578. /**
  102579. * Enables/disables scaling
  102580. * @param enable if scaling should be enabled
  102581. */
  102582. setEnabledScaling(enable: boolean): void;
  102583. private _updateDummy;
  102584. /**
  102585. * Enables a pointer drag behavior on the bounding box of the gizmo
  102586. */
  102587. enableDragBehavior(): void;
  102588. /**
  102589. * Disposes of the gizmo
  102590. */
  102591. dispose(): void;
  102592. /**
  102593. * 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)
  102594. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  102595. * @returns the bounding box mesh with the passed in mesh as a child
  102596. */
  102597. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  102598. /**
  102599. * CustomMeshes are not supported by this gizmo
  102600. * @param mesh The mesh to replace the default mesh of the gizmo
  102601. */
  102602. setCustomMesh(mesh: Mesh): void;
  102603. }
  102604. }
  102605. declare module BABYLON {
  102606. /**
  102607. * Single plane rotation gizmo
  102608. */
  102609. export class PlaneRotationGizmo extends Gizmo {
  102610. /**
  102611. * Drag behavior responsible for the gizmos dragging interactions
  102612. */
  102613. dragBehavior: PointerDragBehavior;
  102614. private _pointerObserver;
  102615. /**
  102616. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  102617. */
  102618. snapDistance: number;
  102619. /**
  102620. * Event that fires each time the gizmo snaps to a new location.
  102621. * * snapDistance is the the change in distance
  102622. */
  102623. onSnapObservable: Observable<{
  102624. snapDistance: number;
  102625. }>;
  102626. /**
  102627. * Creates a PlaneRotationGizmo
  102628. * @param gizmoLayer The utility layer the gizmo will be added to
  102629. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  102630. * @param color The color of the gizmo
  102631. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102632. */
  102633. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102634. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102635. /**
  102636. * Disposes of the gizmo
  102637. */
  102638. dispose(): void;
  102639. }
  102640. }
  102641. declare module BABYLON {
  102642. /**
  102643. * Gizmo that enables rotating a mesh along 3 axis
  102644. */
  102645. export class RotationGizmo extends Gizmo {
  102646. /**
  102647. * Internal gizmo used for interactions on the x axis
  102648. */
  102649. xGizmo: PlaneRotationGizmo;
  102650. /**
  102651. * Internal gizmo used for interactions on the y axis
  102652. */
  102653. yGizmo: PlaneRotationGizmo;
  102654. /**
  102655. * Internal gizmo used for interactions on the z axis
  102656. */
  102657. zGizmo: PlaneRotationGizmo;
  102658. /** Fires an event when any of it's sub gizmos are dragged */
  102659. onDragStartObservable: Observable<{}>;
  102660. /** Fires an event when any of it's sub gizmos are released from dragging */
  102661. onDragEndObservable: Observable<{}>;
  102662. attachedMesh: Nullable<AbstractMesh>;
  102663. /**
  102664. * Creates a RotationGizmo
  102665. * @param gizmoLayer The utility layer the gizmo will be added to
  102666. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102667. */
  102668. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102669. updateGizmoRotationToMatchAttachedMesh: boolean;
  102670. /**
  102671. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102672. */
  102673. snapDistance: number;
  102674. /**
  102675. * Ratio for the scale of the gizmo (Default: 1)
  102676. */
  102677. scaleRatio: number;
  102678. /**
  102679. * Disposes of the gizmo
  102680. */
  102681. dispose(): void;
  102682. /**
  102683. * CustomMeshes are not supported by this gizmo
  102684. * @param mesh The mesh to replace the default mesh of the gizmo
  102685. */
  102686. setCustomMesh(mesh: Mesh): void;
  102687. }
  102688. }
  102689. declare module BABYLON {
  102690. /**
  102691. * Gizmo that enables dragging a mesh along 3 axis
  102692. */
  102693. export class PositionGizmo extends Gizmo {
  102694. /**
  102695. * Internal gizmo used for interactions on the x axis
  102696. */
  102697. xGizmo: AxisDragGizmo;
  102698. /**
  102699. * Internal gizmo used for interactions on the y axis
  102700. */
  102701. yGizmo: AxisDragGizmo;
  102702. /**
  102703. * Internal gizmo used for interactions on the z axis
  102704. */
  102705. zGizmo: AxisDragGizmo;
  102706. /** Fires an event when any of it's sub gizmos are dragged */
  102707. onDragStartObservable: Observable<{}>;
  102708. /** Fires an event when any of it's sub gizmos are released from dragging */
  102709. onDragEndObservable: Observable<{}>;
  102710. attachedMesh: Nullable<AbstractMesh>;
  102711. /**
  102712. * Creates a PositionGizmo
  102713. * @param gizmoLayer The utility layer the gizmo will be added to
  102714. */
  102715. constructor(gizmoLayer?: UtilityLayerRenderer);
  102716. updateGizmoRotationToMatchAttachedMesh: boolean;
  102717. /**
  102718. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102719. */
  102720. snapDistance: number;
  102721. /**
  102722. * Ratio for the scale of the gizmo (Default: 1)
  102723. */
  102724. scaleRatio: number;
  102725. /**
  102726. * Disposes of the gizmo
  102727. */
  102728. dispose(): void;
  102729. /**
  102730. * CustomMeshes are not supported by this gizmo
  102731. * @param mesh The mesh to replace the default mesh of the gizmo
  102732. */
  102733. setCustomMesh(mesh: Mesh): void;
  102734. }
  102735. }
  102736. declare module BABYLON {
  102737. /**
  102738. * Class containing static functions to help procedurally build meshes
  102739. */
  102740. export class PolyhedronBuilder {
  102741. /**
  102742. * Creates a polyhedron mesh
  102743. * * 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
  102744. * * The parameter `size` (positive float, default 1) sets the polygon size
  102745. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  102746. * * 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`
  102747. * * 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
  102748. * * 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)`)
  102749. * * 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
  102750. * * 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
  102751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102754. * @param name defines the name of the mesh
  102755. * @param options defines the options used to create the mesh
  102756. * @param scene defines the hosting scene
  102757. * @returns the polyhedron mesh
  102758. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  102759. */
  102760. static CreatePolyhedron(name: string, options: {
  102761. type?: number;
  102762. size?: number;
  102763. sizeX?: number;
  102764. sizeY?: number;
  102765. sizeZ?: number;
  102766. custom?: any;
  102767. faceUV?: Vector4[];
  102768. faceColors?: Color4[];
  102769. flat?: boolean;
  102770. updatable?: boolean;
  102771. sideOrientation?: number;
  102772. frontUVs?: Vector4;
  102773. backUVs?: Vector4;
  102774. }, scene?: Nullable<Scene>): Mesh;
  102775. }
  102776. }
  102777. declare module BABYLON {
  102778. /**
  102779. * Gizmo that enables scaling a mesh along 3 axis
  102780. */
  102781. export class ScaleGizmo extends Gizmo {
  102782. /**
  102783. * Internal gizmo used for interactions on the x axis
  102784. */
  102785. xGizmo: AxisScaleGizmo;
  102786. /**
  102787. * Internal gizmo used for interactions on the y axis
  102788. */
  102789. yGizmo: AxisScaleGizmo;
  102790. /**
  102791. * Internal gizmo used for interactions on the z axis
  102792. */
  102793. zGizmo: AxisScaleGizmo;
  102794. /**
  102795. * Internal gizmo used to scale all axis equally
  102796. */
  102797. uniformScaleGizmo: AxisScaleGizmo;
  102798. /** Fires an event when any of it's sub gizmos are dragged */
  102799. onDragStartObservable: Observable<{}>;
  102800. /** Fires an event when any of it's sub gizmos are released from dragging */
  102801. onDragEndObservable: Observable<{}>;
  102802. attachedMesh: Nullable<AbstractMesh>;
  102803. /**
  102804. * Creates a ScaleGizmo
  102805. * @param gizmoLayer The utility layer the gizmo will be added to
  102806. */
  102807. constructor(gizmoLayer?: UtilityLayerRenderer);
  102808. updateGizmoRotationToMatchAttachedMesh: boolean;
  102809. /**
  102810. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102811. */
  102812. snapDistance: number;
  102813. /**
  102814. * Ratio for the scale of the gizmo (Default: 1)
  102815. */
  102816. scaleRatio: number;
  102817. /**
  102818. * Disposes of the gizmo
  102819. */
  102820. dispose(): void;
  102821. }
  102822. }
  102823. declare module BABYLON {
  102824. /**
  102825. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  102826. */
  102827. export class GizmoManager implements IDisposable {
  102828. private scene;
  102829. /**
  102830. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  102831. */
  102832. gizmos: {
  102833. positionGizmo: Nullable<PositionGizmo>;
  102834. rotationGizmo: Nullable<RotationGizmo>;
  102835. scaleGizmo: Nullable<ScaleGizmo>;
  102836. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  102837. };
  102838. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  102839. clearGizmoOnEmptyPointerEvent: boolean;
  102840. /** Fires an event when the manager is attached to a mesh */
  102841. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  102842. private _gizmosEnabled;
  102843. private _pointerObserver;
  102844. private _attachedMesh;
  102845. private _boundingBoxColor;
  102846. private _defaultUtilityLayer;
  102847. private _defaultKeepDepthUtilityLayer;
  102848. /**
  102849. * When bounding box gizmo is enabled, this can be used to track drag/end events
  102850. */
  102851. boundingBoxDragBehavior: SixDofDragBehavior;
  102852. /**
  102853. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  102854. */
  102855. attachableMeshes: Nullable<Array<AbstractMesh>>;
  102856. /**
  102857. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  102858. */
  102859. usePointerToAttachGizmos: boolean;
  102860. /**
  102861. * Instatiates a gizmo manager
  102862. * @param scene the scene to overlay the gizmos on top of
  102863. */
  102864. constructor(scene: Scene);
  102865. /**
  102866. * Attaches a set of gizmos to the specified mesh
  102867. * @param mesh The mesh the gizmo's should be attached to
  102868. */
  102869. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102870. /**
  102871. * If the position gizmo is enabled
  102872. */
  102873. positionGizmoEnabled: boolean;
  102874. /**
  102875. * If the rotation gizmo is enabled
  102876. */
  102877. rotationGizmoEnabled: boolean;
  102878. /**
  102879. * If the scale gizmo is enabled
  102880. */
  102881. scaleGizmoEnabled: boolean;
  102882. /**
  102883. * If the boundingBox gizmo is enabled
  102884. */
  102885. boundingBoxGizmoEnabled: boolean;
  102886. /**
  102887. * Disposes of the gizmo manager
  102888. */
  102889. dispose(): void;
  102890. }
  102891. }
  102892. declare module BABYLON {
  102893. /**
  102894. * A directional light is defined by a direction (what a surprise!).
  102895. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102896. * 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.
  102897. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102898. */
  102899. export class DirectionalLight extends ShadowLight {
  102900. private _shadowFrustumSize;
  102901. /**
  102902. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102903. */
  102904. /**
  102905. * Specifies a fix frustum size for the shadow generation.
  102906. */
  102907. shadowFrustumSize: number;
  102908. private _shadowOrthoScale;
  102909. /**
  102910. * Gets the shadow projection scale against the optimal computed one.
  102911. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102912. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102913. */
  102914. /**
  102915. * Sets the shadow projection scale against the optimal computed one.
  102916. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102917. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102918. */
  102919. shadowOrthoScale: number;
  102920. /**
  102921. * Automatically compute the projection matrix to best fit (including all the casters)
  102922. * on each frame.
  102923. */
  102924. autoUpdateExtends: boolean;
  102925. private _orthoLeft;
  102926. private _orthoRight;
  102927. private _orthoTop;
  102928. private _orthoBottom;
  102929. /**
  102930. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102931. * The directional light is emitted from everywhere in the given direction.
  102932. * It can cast shadows.
  102933. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102934. * @param name The friendly name of the light
  102935. * @param direction The direction of the light
  102936. * @param scene The scene the light belongs to
  102937. */
  102938. constructor(name: string, direction: Vector3, scene: Scene);
  102939. /**
  102940. * Returns the string "DirectionalLight".
  102941. * @return The class name
  102942. */
  102943. getClassName(): string;
  102944. /**
  102945. * Returns the integer 1.
  102946. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102947. */
  102948. getTypeID(): number;
  102949. /**
  102950. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102951. * Returns the DirectionalLight Shadow projection matrix.
  102952. */
  102953. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102954. /**
  102955. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102956. * Returns the DirectionalLight Shadow projection matrix.
  102957. */
  102958. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102959. /**
  102960. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102961. * Returns the DirectionalLight Shadow projection matrix.
  102962. */
  102963. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102964. protected _buildUniformLayout(): void;
  102965. /**
  102966. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102967. * @param effect The effect to update
  102968. * @param lightIndex The index of the light in the effect to update
  102969. * @returns The directional light
  102970. */
  102971. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102972. /**
  102973. * Gets the minZ used for shadow according to both the scene and the light.
  102974. *
  102975. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102976. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102977. * @param activeCamera The camera we are returning the min for
  102978. * @returns the depth min z
  102979. */
  102980. getDepthMinZ(activeCamera: Camera): number;
  102981. /**
  102982. * Gets the maxZ used for shadow according to both the scene and the light.
  102983. *
  102984. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102985. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102986. * @param activeCamera The camera we are returning the max for
  102987. * @returns the depth max z
  102988. */
  102989. getDepthMaxZ(activeCamera: Camera): number;
  102990. /**
  102991. * Prepares the list of defines specific to the light type.
  102992. * @param defines the list of defines
  102993. * @param lightIndex defines the index of the light for the effect
  102994. */
  102995. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102996. }
  102997. }
  102998. declare module BABYLON {
  102999. /**
  103000. * Class containing static functions to help procedurally build meshes
  103001. */
  103002. export class HemisphereBuilder {
  103003. /**
  103004. * Creates a hemisphere mesh
  103005. * @param name defines the name of the mesh
  103006. * @param options defines the options used to create the mesh
  103007. * @param scene defines the hosting scene
  103008. * @returns the hemisphere mesh
  103009. */
  103010. static CreateHemisphere(name: string, options: {
  103011. segments?: number;
  103012. diameter?: number;
  103013. sideOrientation?: number;
  103014. }, scene: any): Mesh;
  103015. }
  103016. }
  103017. declare module BABYLON {
  103018. /**
  103019. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103020. * These values define a cone of light starting from the position, emitting toward the direction.
  103021. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103022. * and the exponent defines the speed of the decay of the light with distance (reach).
  103023. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103024. */
  103025. export class SpotLight extends ShadowLight {
  103026. private _angle;
  103027. private _innerAngle;
  103028. private _cosHalfAngle;
  103029. private _lightAngleScale;
  103030. private _lightAngleOffset;
  103031. /**
  103032. * Gets the cone angle of the spot light in Radians.
  103033. */
  103034. /**
  103035. * Sets the cone angle of the spot light in Radians.
  103036. */
  103037. angle: number;
  103038. /**
  103039. * Only used in gltf falloff mode, this defines the angle where
  103040. * the directional falloff will start before cutting at angle which could be seen
  103041. * as outer angle.
  103042. */
  103043. /**
  103044. * Only used in gltf falloff mode, this defines the angle where
  103045. * the directional falloff will start before cutting at angle which could be seen
  103046. * as outer angle.
  103047. */
  103048. innerAngle: number;
  103049. private _shadowAngleScale;
  103050. /**
  103051. * Allows scaling the angle of the light for shadow generation only.
  103052. */
  103053. /**
  103054. * Allows scaling the angle of the light for shadow generation only.
  103055. */
  103056. shadowAngleScale: number;
  103057. /**
  103058. * The light decay speed with the distance from the emission spot.
  103059. */
  103060. exponent: number;
  103061. private _projectionTextureMatrix;
  103062. /**
  103063. * Allows reading the projecton texture
  103064. */
  103065. readonly projectionTextureMatrix: Matrix;
  103066. protected _projectionTextureLightNear: number;
  103067. /**
  103068. * Gets the near clip of the Spotlight for texture projection.
  103069. */
  103070. /**
  103071. * Sets the near clip of the Spotlight for texture projection.
  103072. */
  103073. projectionTextureLightNear: number;
  103074. protected _projectionTextureLightFar: number;
  103075. /**
  103076. * Gets the far clip of the Spotlight for texture projection.
  103077. */
  103078. /**
  103079. * Sets the far clip of the Spotlight for texture projection.
  103080. */
  103081. projectionTextureLightFar: number;
  103082. protected _projectionTextureUpDirection: Vector3;
  103083. /**
  103084. * Gets the Up vector of the Spotlight for texture projection.
  103085. */
  103086. /**
  103087. * Sets the Up vector of the Spotlight for texture projection.
  103088. */
  103089. projectionTextureUpDirection: Vector3;
  103090. private _projectionTexture;
  103091. /**
  103092. * Gets the projection texture of the light.
  103093. */
  103094. /**
  103095. * Sets the projection texture of the light.
  103096. */
  103097. projectionTexture: Nullable<BaseTexture>;
  103098. private _projectionTextureViewLightDirty;
  103099. private _projectionTextureProjectionLightDirty;
  103100. private _projectionTextureDirty;
  103101. private _projectionTextureViewTargetVector;
  103102. private _projectionTextureViewLightMatrix;
  103103. private _projectionTextureProjectionLightMatrix;
  103104. private _projectionTextureScalingMatrix;
  103105. /**
  103106. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103107. * It can cast shadows.
  103108. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103109. * @param name The light friendly name
  103110. * @param position The position of the spot light in the scene
  103111. * @param direction The direction of the light in the scene
  103112. * @param angle The cone angle of the light in Radians
  103113. * @param exponent The light decay speed with the distance from the emission spot
  103114. * @param scene The scene the lights belongs to
  103115. */
  103116. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103117. /**
  103118. * Returns the string "SpotLight".
  103119. * @returns the class name
  103120. */
  103121. getClassName(): string;
  103122. /**
  103123. * Returns the integer 2.
  103124. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103125. */
  103126. getTypeID(): number;
  103127. /**
  103128. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103129. */
  103130. protected _setDirection(value: Vector3): void;
  103131. /**
  103132. * Overrides the position setter to recompute the projection texture view light Matrix.
  103133. */
  103134. protected _setPosition(value: Vector3): void;
  103135. /**
  103136. * 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.
  103137. * Returns the SpotLight.
  103138. */
  103139. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103140. protected _computeProjectionTextureViewLightMatrix(): void;
  103141. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103142. /**
  103143. * Main function for light texture projection matrix computing.
  103144. */
  103145. protected _computeProjectionTextureMatrix(): void;
  103146. protected _buildUniformLayout(): void;
  103147. private _computeAngleValues;
  103148. /**
  103149. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103150. * @param effect The effect to update
  103151. * @param lightIndex The index of the light in the effect to update
  103152. * @returns The spot light
  103153. */
  103154. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103155. /**
  103156. * Disposes the light and the associated resources.
  103157. */
  103158. dispose(): void;
  103159. /**
  103160. * Prepares the list of defines specific to the light type.
  103161. * @param defines the list of defines
  103162. * @param lightIndex defines the index of the light for the effect
  103163. */
  103164. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103165. }
  103166. }
  103167. declare module BABYLON {
  103168. /**
  103169. * Gizmo that enables viewing a light
  103170. */
  103171. export class LightGizmo extends Gizmo {
  103172. private _lightMesh;
  103173. private _material;
  103174. /**
  103175. * Creates a LightGizmo
  103176. * @param gizmoLayer The utility layer the gizmo will be added to
  103177. */
  103178. constructor(gizmoLayer?: UtilityLayerRenderer);
  103179. private _light;
  103180. /**
  103181. * The light that the gizmo is attached to
  103182. */
  103183. light: Nullable<Light>;
  103184. /**
  103185. * @hidden
  103186. * Updates the gizmo to match the attached mesh's position/rotation
  103187. */
  103188. protected _update(): void;
  103189. private static _Scale;
  103190. /**
  103191. * Creates the lines for a light mesh
  103192. */
  103193. private static _createLightLines;
  103194. private static _CreateHemisphericLightMesh;
  103195. private static _CreatePointLightMesh;
  103196. private static _CreateSpotLightMesh;
  103197. private static _CreateDirectionalLightMesh;
  103198. }
  103199. }
  103200. declare module BABYLON {
  103201. /** @hidden */
  103202. export var backgroundFragmentDeclaration: {
  103203. name: string;
  103204. shader: string;
  103205. };
  103206. }
  103207. declare module BABYLON {
  103208. /** @hidden */
  103209. export var backgroundUboDeclaration: {
  103210. name: string;
  103211. shader: string;
  103212. };
  103213. }
  103214. declare module BABYLON {
  103215. /** @hidden */
  103216. export var backgroundPixelShader: {
  103217. name: string;
  103218. shader: string;
  103219. };
  103220. }
  103221. declare module BABYLON {
  103222. /** @hidden */
  103223. export var backgroundVertexDeclaration: {
  103224. name: string;
  103225. shader: string;
  103226. };
  103227. }
  103228. declare module BABYLON {
  103229. /** @hidden */
  103230. export var backgroundVertexShader: {
  103231. name: string;
  103232. shader: string;
  103233. };
  103234. }
  103235. declare module BABYLON {
  103236. /**
  103237. * Background material used to create an efficient environement around your scene.
  103238. */
  103239. export class BackgroundMaterial extends PushMaterial {
  103240. /**
  103241. * Standard reflectance value at parallel view angle.
  103242. */
  103243. static StandardReflectance0: number;
  103244. /**
  103245. * Standard reflectance value at grazing angle.
  103246. */
  103247. static StandardReflectance90: number;
  103248. protected _primaryColor: Color3;
  103249. /**
  103250. * Key light Color (multiply against the environement texture)
  103251. */
  103252. primaryColor: Color3;
  103253. protected __perceptualColor: Nullable<Color3>;
  103254. /**
  103255. * Experimental Internal Use Only.
  103256. *
  103257. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  103258. * This acts as a helper to set the primary color to a more "human friendly" value.
  103259. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  103260. * output color as close as possible from the chosen value.
  103261. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  103262. * part of lighting setup.)
  103263. */
  103264. _perceptualColor: Nullable<Color3>;
  103265. protected _primaryColorShadowLevel: float;
  103266. /**
  103267. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  103268. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  103269. */
  103270. primaryColorShadowLevel: float;
  103271. protected _primaryColorHighlightLevel: float;
  103272. /**
  103273. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  103274. * The primary color is used at the level chosen to define what the white area would look.
  103275. */
  103276. primaryColorHighlightLevel: float;
  103277. protected _reflectionTexture: Nullable<BaseTexture>;
  103278. /**
  103279. * Reflection Texture used in the material.
  103280. * Should be author in a specific way for the best result (refer to the documentation).
  103281. */
  103282. reflectionTexture: Nullable<BaseTexture>;
  103283. protected _reflectionBlur: float;
  103284. /**
  103285. * Reflection Texture level of blur.
  103286. *
  103287. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  103288. * texture twice.
  103289. */
  103290. reflectionBlur: float;
  103291. protected _diffuseTexture: Nullable<BaseTexture>;
  103292. /**
  103293. * Diffuse Texture used in the material.
  103294. * Should be author in a specific way for the best result (refer to the documentation).
  103295. */
  103296. diffuseTexture: Nullable<BaseTexture>;
  103297. protected _shadowLights: Nullable<IShadowLight[]>;
  103298. /**
  103299. * Specify the list of lights casting shadow on the material.
  103300. * All scene shadow lights will be included if null.
  103301. */
  103302. shadowLights: Nullable<IShadowLight[]>;
  103303. protected _shadowLevel: float;
  103304. /**
  103305. * Helps adjusting the shadow to a softer level if required.
  103306. * 0 means black shadows and 1 means no shadows.
  103307. */
  103308. shadowLevel: float;
  103309. protected _sceneCenter: Vector3;
  103310. /**
  103311. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  103312. * It is usually zero but might be interesting to modify according to your setup.
  103313. */
  103314. sceneCenter: Vector3;
  103315. protected _opacityFresnel: boolean;
  103316. /**
  103317. * This helps specifying that the material is falling off to the sky box at grazing angle.
  103318. * This helps ensuring a nice transition when the camera goes under the ground.
  103319. */
  103320. opacityFresnel: boolean;
  103321. protected _reflectionFresnel: boolean;
  103322. /**
  103323. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  103324. * This helps adding a mirror texture on the ground.
  103325. */
  103326. reflectionFresnel: boolean;
  103327. protected _reflectionFalloffDistance: number;
  103328. /**
  103329. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  103330. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  103331. */
  103332. reflectionFalloffDistance: number;
  103333. protected _reflectionAmount: number;
  103334. /**
  103335. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  103336. */
  103337. reflectionAmount: number;
  103338. protected _reflectionReflectance0: number;
  103339. /**
  103340. * This specifies the weight of the reflection at grazing angle.
  103341. */
  103342. reflectionReflectance0: number;
  103343. protected _reflectionReflectance90: number;
  103344. /**
  103345. * This specifies the weight of the reflection at a perpendicular point of view.
  103346. */
  103347. reflectionReflectance90: number;
  103348. /**
  103349. * Sets the reflection reflectance fresnel values according to the default standard
  103350. * empirically know to work well :-)
  103351. */
  103352. reflectionStandardFresnelWeight: number;
  103353. protected _useRGBColor: boolean;
  103354. /**
  103355. * Helps to directly use the maps channels instead of their level.
  103356. */
  103357. useRGBColor: boolean;
  103358. protected _enableNoise: boolean;
  103359. /**
  103360. * This helps reducing the banding effect that could occur on the background.
  103361. */
  103362. enableNoise: boolean;
  103363. /**
  103364. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103365. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  103366. * Recommended to be keep at 1.0 except for special cases.
  103367. */
  103368. fovMultiplier: number;
  103369. private _fovMultiplier;
  103370. /**
  103371. * Enable the FOV adjustment feature controlled by fovMultiplier.
  103372. */
  103373. useEquirectangularFOV: boolean;
  103374. private _maxSimultaneousLights;
  103375. /**
  103376. * Number of Simultaneous lights allowed on the material.
  103377. */
  103378. maxSimultaneousLights: int;
  103379. /**
  103380. * Default configuration related to image processing available in the Background Material.
  103381. */
  103382. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103383. /**
  103384. * Keep track of the image processing observer to allow dispose and replace.
  103385. */
  103386. private _imageProcessingObserver;
  103387. /**
  103388. * Attaches a new image processing configuration to the PBR Material.
  103389. * @param configuration (if null the scene configuration will be use)
  103390. */
  103391. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103392. /**
  103393. * Gets the image processing configuration used either in this material.
  103394. */
  103395. /**
  103396. * Sets the Default image processing configuration used either in the this material.
  103397. *
  103398. * If sets to null, the scene one is in use.
  103399. */
  103400. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  103401. /**
  103402. * Gets wether the color curves effect is enabled.
  103403. */
  103404. /**
  103405. * Sets wether the color curves effect is enabled.
  103406. */
  103407. cameraColorCurvesEnabled: boolean;
  103408. /**
  103409. * Gets wether the color grading effect is enabled.
  103410. */
  103411. /**
  103412. * Gets wether the color grading effect is enabled.
  103413. */
  103414. cameraColorGradingEnabled: boolean;
  103415. /**
  103416. * Gets wether tonemapping is enabled or not.
  103417. */
  103418. /**
  103419. * Sets wether tonemapping is enabled or not
  103420. */
  103421. cameraToneMappingEnabled: boolean;
  103422. /**
  103423. * The camera exposure used on this material.
  103424. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103425. * This corresponds to a photographic exposure.
  103426. */
  103427. /**
  103428. * The camera exposure used on this material.
  103429. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103430. * This corresponds to a photographic exposure.
  103431. */
  103432. cameraExposure: float;
  103433. /**
  103434. * Gets The camera contrast used on this material.
  103435. */
  103436. /**
  103437. * Sets The camera contrast used on this material.
  103438. */
  103439. cameraContrast: float;
  103440. /**
  103441. * Gets the Color Grading 2D Lookup Texture.
  103442. */
  103443. /**
  103444. * Sets the Color Grading 2D Lookup Texture.
  103445. */
  103446. cameraColorGradingTexture: Nullable<BaseTexture>;
  103447. /**
  103448. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103449. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103450. * 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;
  103451. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103452. */
  103453. /**
  103454. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103455. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103456. * 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;
  103457. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103458. */
  103459. cameraColorCurves: Nullable<ColorCurves>;
  103460. /**
  103461. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  103462. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  103463. */
  103464. switchToBGR: boolean;
  103465. private _renderTargets;
  103466. private _reflectionControls;
  103467. private _white;
  103468. private _primaryShadowColor;
  103469. private _primaryHighlightColor;
  103470. /**
  103471. * Instantiates a Background Material in the given scene
  103472. * @param name The friendly name of the material
  103473. * @param scene The scene to add the material to
  103474. */
  103475. constructor(name: string, scene: Scene);
  103476. /**
  103477. * Gets a boolean indicating that current material needs to register RTT
  103478. */
  103479. readonly hasRenderTargetTextures: boolean;
  103480. /**
  103481. * The entire material has been created in order to prevent overdraw.
  103482. * @returns false
  103483. */
  103484. needAlphaTesting(): boolean;
  103485. /**
  103486. * The entire material has been created in order to prevent overdraw.
  103487. * @returns true if blending is enable
  103488. */
  103489. needAlphaBlending(): boolean;
  103490. /**
  103491. * Checks wether the material is ready to be rendered for a given mesh.
  103492. * @param mesh The mesh to render
  103493. * @param subMesh The submesh to check against
  103494. * @param useInstances Specify wether or not the material is used with instances
  103495. * @returns true if all the dependencies are ready (Textures, Effects...)
  103496. */
  103497. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103498. /**
  103499. * Compute the primary color according to the chosen perceptual color.
  103500. */
  103501. private _computePrimaryColorFromPerceptualColor;
  103502. /**
  103503. * Compute the highlights and shadow colors according to their chosen levels.
  103504. */
  103505. private _computePrimaryColors;
  103506. /**
  103507. * Build the uniform buffer used in the material.
  103508. */
  103509. buildUniformLayout(): void;
  103510. /**
  103511. * Unbind the material.
  103512. */
  103513. unbind(): void;
  103514. /**
  103515. * Bind only the world matrix to the material.
  103516. * @param world The world matrix to bind.
  103517. */
  103518. bindOnlyWorldMatrix(world: Matrix): void;
  103519. /**
  103520. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  103521. * @param world The world matrix to bind.
  103522. * @param subMesh The submesh to bind for.
  103523. */
  103524. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103525. /**
  103526. * Dispose the material.
  103527. * @param forceDisposeEffect Force disposal of the associated effect.
  103528. * @param forceDisposeTextures Force disposal of the associated textures.
  103529. */
  103530. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103531. /**
  103532. * Clones the material.
  103533. * @param name The cloned name.
  103534. * @returns The cloned material.
  103535. */
  103536. clone(name: string): BackgroundMaterial;
  103537. /**
  103538. * Serializes the current material to its JSON representation.
  103539. * @returns The JSON representation.
  103540. */
  103541. serialize(): any;
  103542. /**
  103543. * Gets the class name of the material
  103544. * @returns "BackgroundMaterial"
  103545. */
  103546. getClassName(): string;
  103547. /**
  103548. * Parse a JSON input to create back a background material.
  103549. * @param source The JSON data to parse
  103550. * @param scene The scene to create the parsed material in
  103551. * @param rootUrl The root url of the assets the material depends upon
  103552. * @returns the instantiated BackgroundMaterial.
  103553. */
  103554. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  103555. }
  103556. }
  103557. declare module BABYLON {
  103558. /**
  103559. * Represents the different options available during the creation of
  103560. * a Environment helper.
  103561. *
  103562. * This can control the default ground, skybox and image processing setup of your scene.
  103563. */
  103564. export interface IEnvironmentHelperOptions {
  103565. /**
  103566. * Specifies wether or not to create a ground.
  103567. * True by default.
  103568. */
  103569. createGround: boolean;
  103570. /**
  103571. * Specifies the ground size.
  103572. * 15 by default.
  103573. */
  103574. groundSize: number;
  103575. /**
  103576. * The texture used on the ground for the main color.
  103577. * Comes from the BabylonJS CDN by default.
  103578. *
  103579. * Remarks: Can be either a texture or a url.
  103580. */
  103581. groundTexture: string | BaseTexture;
  103582. /**
  103583. * The color mixed in the ground texture by default.
  103584. * BabylonJS clearColor by default.
  103585. */
  103586. groundColor: Color3;
  103587. /**
  103588. * Specifies the ground opacity.
  103589. * 1 by default.
  103590. */
  103591. groundOpacity: number;
  103592. /**
  103593. * Enables the ground to receive shadows.
  103594. * True by default.
  103595. */
  103596. enableGroundShadow: boolean;
  103597. /**
  103598. * Helps preventing the shadow to be fully black on the ground.
  103599. * 0.5 by default.
  103600. */
  103601. groundShadowLevel: number;
  103602. /**
  103603. * Creates a mirror texture attach to the ground.
  103604. * false by default.
  103605. */
  103606. enableGroundMirror: boolean;
  103607. /**
  103608. * Specifies the ground mirror size ratio.
  103609. * 0.3 by default as the default kernel is 64.
  103610. */
  103611. groundMirrorSizeRatio: number;
  103612. /**
  103613. * Specifies the ground mirror blur kernel size.
  103614. * 64 by default.
  103615. */
  103616. groundMirrorBlurKernel: number;
  103617. /**
  103618. * Specifies the ground mirror visibility amount.
  103619. * 1 by default
  103620. */
  103621. groundMirrorAmount: number;
  103622. /**
  103623. * Specifies the ground mirror reflectance weight.
  103624. * This uses the standard weight of the background material to setup the fresnel effect
  103625. * of the mirror.
  103626. * 1 by default.
  103627. */
  103628. groundMirrorFresnelWeight: number;
  103629. /**
  103630. * Specifies the ground mirror Falloff distance.
  103631. * This can helps reducing the size of the reflection.
  103632. * 0 by Default.
  103633. */
  103634. groundMirrorFallOffDistance: number;
  103635. /**
  103636. * Specifies the ground mirror texture type.
  103637. * Unsigned Int by Default.
  103638. */
  103639. groundMirrorTextureType: number;
  103640. /**
  103641. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  103642. * the shown objects.
  103643. */
  103644. groundYBias: number;
  103645. /**
  103646. * Specifies wether or not to create a skybox.
  103647. * True by default.
  103648. */
  103649. createSkybox: boolean;
  103650. /**
  103651. * Specifies the skybox size.
  103652. * 20 by default.
  103653. */
  103654. skyboxSize: number;
  103655. /**
  103656. * The texture used on the skybox for the main color.
  103657. * Comes from the BabylonJS CDN by default.
  103658. *
  103659. * Remarks: Can be either a texture or a url.
  103660. */
  103661. skyboxTexture: string | BaseTexture;
  103662. /**
  103663. * The color mixed in the skybox texture by default.
  103664. * BabylonJS clearColor by default.
  103665. */
  103666. skyboxColor: Color3;
  103667. /**
  103668. * The background rotation around the Y axis of the scene.
  103669. * This helps aligning the key lights of your scene with the background.
  103670. * 0 by default.
  103671. */
  103672. backgroundYRotation: number;
  103673. /**
  103674. * Compute automatically the size of the elements to best fit with the scene.
  103675. */
  103676. sizeAuto: boolean;
  103677. /**
  103678. * Default position of the rootMesh if autoSize is not true.
  103679. */
  103680. rootPosition: Vector3;
  103681. /**
  103682. * Sets up the image processing in the scene.
  103683. * true by default.
  103684. */
  103685. setupImageProcessing: boolean;
  103686. /**
  103687. * The texture used as your environment texture in the scene.
  103688. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  103689. *
  103690. * Remarks: Can be either a texture or a url.
  103691. */
  103692. environmentTexture: string | BaseTexture;
  103693. /**
  103694. * The value of the exposure to apply to the scene.
  103695. * 0.6 by default if setupImageProcessing is true.
  103696. */
  103697. cameraExposure: number;
  103698. /**
  103699. * The value of the contrast to apply to the scene.
  103700. * 1.6 by default if setupImageProcessing is true.
  103701. */
  103702. cameraContrast: number;
  103703. /**
  103704. * Specifies wether or not tonemapping should be enabled in the scene.
  103705. * true by default if setupImageProcessing is true.
  103706. */
  103707. toneMappingEnabled: boolean;
  103708. }
  103709. /**
  103710. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  103711. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  103712. * It also helps with the default setup of your imageProcessing configuration.
  103713. */
  103714. export class EnvironmentHelper {
  103715. /**
  103716. * Default ground texture URL.
  103717. */
  103718. private static _groundTextureCDNUrl;
  103719. /**
  103720. * Default skybox texture URL.
  103721. */
  103722. private static _skyboxTextureCDNUrl;
  103723. /**
  103724. * Default environment texture URL.
  103725. */
  103726. private static _environmentTextureCDNUrl;
  103727. /**
  103728. * Creates the default options for the helper.
  103729. */
  103730. private static _getDefaultOptions;
  103731. private _rootMesh;
  103732. /**
  103733. * Gets the root mesh created by the helper.
  103734. */
  103735. readonly rootMesh: Mesh;
  103736. private _skybox;
  103737. /**
  103738. * Gets the skybox created by the helper.
  103739. */
  103740. readonly skybox: Nullable<Mesh>;
  103741. private _skyboxTexture;
  103742. /**
  103743. * Gets the skybox texture created by the helper.
  103744. */
  103745. readonly skyboxTexture: Nullable<BaseTexture>;
  103746. private _skyboxMaterial;
  103747. /**
  103748. * Gets the skybox material created by the helper.
  103749. */
  103750. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  103751. private _ground;
  103752. /**
  103753. * Gets the ground mesh created by the helper.
  103754. */
  103755. readonly ground: Nullable<Mesh>;
  103756. private _groundTexture;
  103757. /**
  103758. * Gets the ground texture created by the helper.
  103759. */
  103760. readonly groundTexture: Nullable<BaseTexture>;
  103761. private _groundMirror;
  103762. /**
  103763. * Gets the ground mirror created by the helper.
  103764. */
  103765. readonly groundMirror: Nullable<MirrorTexture>;
  103766. /**
  103767. * Gets the ground mirror render list to helps pushing the meshes
  103768. * you wish in the ground reflection.
  103769. */
  103770. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  103771. private _groundMaterial;
  103772. /**
  103773. * Gets the ground material created by the helper.
  103774. */
  103775. readonly groundMaterial: Nullable<BackgroundMaterial>;
  103776. /**
  103777. * Stores the creation options.
  103778. */
  103779. private readonly _scene;
  103780. private _options;
  103781. /**
  103782. * This observable will be notified with any error during the creation of the environment,
  103783. * mainly texture creation errors.
  103784. */
  103785. onErrorObservable: Observable<{
  103786. message?: string;
  103787. exception?: any;
  103788. }>;
  103789. /**
  103790. * constructor
  103791. * @param options Defines the options we want to customize the helper
  103792. * @param scene The scene to add the material to
  103793. */
  103794. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  103795. /**
  103796. * Updates the background according to the new options
  103797. * @param options
  103798. */
  103799. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  103800. /**
  103801. * Sets the primary color of all the available elements.
  103802. * @param color the main color to affect to the ground and the background
  103803. */
  103804. setMainColor(color: Color3): void;
  103805. /**
  103806. * Setup the image processing according to the specified options.
  103807. */
  103808. private _setupImageProcessing;
  103809. /**
  103810. * Setup the environment texture according to the specified options.
  103811. */
  103812. private _setupEnvironmentTexture;
  103813. /**
  103814. * Setup the background according to the specified options.
  103815. */
  103816. private _setupBackground;
  103817. /**
  103818. * Get the scene sizes according to the setup.
  103819. */
  103820. private _getSceneSize;
  103821. /**
  103822. * Setup the ground according to the specified options.
  103823. */
  103824. private _setupGround;
  103825. /**
  103826. * Setup the ground material according to the specified options.
  103827. */
  103828. private _setupGroundMaterial;
  103829. /**
  103830. * Setup the ground diffuse texture according to the specified options.
  103831. */
  103832. private _setupGroundDiffuseTexture;
  103833. /**
  103834. * Setup the ground mirror texture according to the specified options.
  103835. */
  103836. private _setupGroundMirrorTexture;
  103837. /**
  103838. * Setup the ground to receive the mirror texture.
  103839. */
  103840. private _setupMirrorInGroundMaterial;
  103841. /**
  103842. * Setup the skybox according to the specified options.
  103843. */
  103844. private _setupSkybox;
  103845. /**
  103846. * Setup the skybox material according to the specified options.
  103847. */
  103848. private _setupSkyboxMaterial;
  103849. /**
  103850. * Setup the skybox reflection texture according to the specified options.
  103851. */
  103852. private _setupSkyboxReflectionTexture;
  103853. private _errorHandler;
  103854. /**
  103855. * Dispose all the elements created by the Helper.
  103856. */
  103857. dispose(): void;
  103858. }
  103859. }
  103860. declare module BABYLON {
  103861. /**
  103862. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  103863. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  103864. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  103865. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103866. */
  103867. export class PhotoDome extends TransformNode {
  103868. private _useDirectMapping;
  103869. /**
  103870. * The texture being displayed on the sphere
  103871. */
  103872. protected _photoTexture: Texture;
  103873. /**
  103874. * Gets or sets the texture being displayed on the sphere
  103875. */
  103876. photoTexture: Texture;
  103877. /**
  103878. * Observable raised when an error occured while loading the 360 image
  103879. */
  103880. onLoadErrorObservable: Observable<string>;
  103881. /**
  103882. * The skybox material
  103883. */
  103884. protected _material: BackgroundMaterial;
  103885. /**
  103886. * The surface used for the skybox
  103887. */
  103888. protected _mesh: Mesh;
  103889. /**
  103890. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103891. * Also see the options.resolution property.
  103892. */
  103893. fovMultiplier: number;
  103894. /**
  103895. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  103896. * @param name Element's name, child elements will append suffixes for their own names.
  103897. * @param urlsOfPhoto defines the url of the photo to display
  103898. * @param options defines an object containing optional or exposed sub element properties
  103899. * @param onError defines a callback called when an error occured while loading the texture
  103900. */
  103901. constructor(name: string, urlOfPhoto: string, options: {
  103902. resolution?: number;
  103903. size?: number;
  103904. useDirectMapping?: boolean;
  103905. faceForward?: boolean;
  103906. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  103907. /**
  103908. * Releases resources associated with this node.
  103909. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103910. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103911. */
  103912. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103913. }
  103914. }
  103915. declare module BABYLON {
  103916. /** @hidden */
  103917. export var rgbdDecodePixelShader: {
  103918. name: string;
  103919. shader: string;
  103920. };
  103921. }
  103922. declare module BABYLON {
  103923. /**
  103924. * Class used to host texture specific utilities
  103925. */
  103926. export class BRDFTextureTools {
  103927. /**
  103928. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  103929. * @param texture the texture to expand.
  103930. */
  103931. private static _ExpandDefaultBRDFTexture;
  103932. /**
  103933. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103934. * @param scene defines the hosting scene
  103935. * @returns the environment BRDF texture
  103936. */
  103937. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103938. private static _environmentBRDFBase64Texture;
  103939. }
  103940. }
  103941. declare module BABYLON {
  103942. /**
  103943. * @hidden
  103944. */
  103945. export interface IMaterialClearCoatDefines {
  103946. CLEARCOAT: boolean;
  103947. CLEARCOAT_DEFAULTIOR: boolean;
  103948. CLEARCOAT_TEXTURE: boolean;
  103949. CLEARCOAT_TEXTUREDIRECTUV: number;
  103950. CLEARCOAT_BUMP: boolean;
  103951. CLEARCOAT_BUMPDIRECTUV: number;
  103952. CLEARCOAT_TINT: boolean;
  103953. CLEARCOAT_TINT_TEXTURE: boolean;
  103954. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103955. /** @hidden */
  103956. _areTexturesDirty: boolean;
  103957. }
  103958. /**
  103959. * Define the code related to the clear coat parameters of the pbr material.
  103960. */
  103961. export class PBRClearCoatConfiguration {
  103962. /**
  103963. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103964. * The default fits with a polyurethane material.
  103965. */
  103966. private static readonly _DefaultIndiceOfRefraction;
  103967. private _isEnabled;
  103968. /**
  103969. * Defines if the clear coat is enabled in the material.
  103970. */
  103971. isEnabled: boolean;
  103972. /**
  103973. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103974. */
  103975. intensity: number;
  103976. /**
  103977. * Defines the clear coat layer roughness.
  103978. */
  103979. roughness: number;
  103980. private _indiceOfRefraction;
  103981. /**
  103982. * Defines the indice of refraction of the clear coat.
  103983. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103984. * The default fits with a polyurethane material.
  103985. * Changing the default value is more performance intensive.
  103986. */
  103987. indiceOfRefraction: number;
  103988. private _texture;
  103989. /**
  103990. * Stores the clear coat values in a texture.
  103991. */
  103992. texture: Nullable<BaseTexture>;
  103993. private _bumpTexture;
  103994. /**
  103995. * Define the clear coat specific bump texture.
  103996. */
  103997. bumpTexture: Nullable<BaseTexture>;
  103998. private _isTintEnabled;
  103999. /**
  104000. * Defines if the clear coat tint is enabled in the material.
  104001. */
  104002. isTintEnabled: boolean;
  104003. /**
  104004. * Defines the clear coat tint of the material.
  104005. * This is only use if tint is enabled
  104006. */
  104007. tintColor: Color3;
  104008. /**
  104009. * Defines the distance at which the tint color should be found in the
  104010. * clear coat media.
  104011. * This is only use if tint is enabled
  104012. */
  104013. tintColorAtDistance: number;
  104014. /**
  104015. * Defines the clear coat layer thickness.
  104016. * This is only use if tint is enabled
  104017. */
  104018. tintThickness: number;
  104019. private _tintTexture;
  104020. /**
  104021. * Stores the clear tint values in a texture.
  104022. * rgb is tint
  104023. * a is a thickness factor
  104024. */
  104025. tintTexture: Nullable<BaseTexture>;
  104026. /** @hidden */
  104027. private _internalMarkAllSubMeshesAsTexturesDirty;
  104028. /** @hidden */
  104029. _markAllSubMeshesAsTexturesDirty(): void;
  104030. /**
  104031. * Instantiate a new istance of clear coat configuration.
  104032. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104033. */
  104034. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104035. /**
  104036. * Gets wehter the submesh is ready to be used or not.
  104037. * @param defines the list of "defines" to update.
  104038. * @param scene defines the scene the material belongs to.
  104039. * @param engine defines the engine the material belongs to.
  104040. * @param disableBumpMap defines wether the material disables bump or not.
  104041. * @returns - boolean indicating that the submesh is ready or not.
  104042. */
  104043. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  104044. /**
  104045. * Checks to see if a texture is used in the material.
  104046. * @param defines the list of "defines" to update.
  104047. * @param scene defines the scene to the material belongs to.
  104048. */
  104049. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  104050. /**
  104051. * Binds the material data.
  104052. * @param uniformBuffer defines the Uniform buffer to fill in.
  104053. * @param scene defines the scene the material belongs to.
  104054. * @param engine defines the engine the material belongs to.
  104055. * @param disableBumpMap defines wether the material disables bump or not.
  104056. * @param isFrozen defines wether the material is frozen or not.
  104057. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104058. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104059. */
  104060. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  104061. /**
  104062. * Checks to see if a texture is used in the material.
  104063. * @param texture - Base texture to use.
  104064. * @returns - Boolean specifying if a texture is used in the material.
  104065. */
  104066. hasTexture(texture: BaseTexture): boolean;
  104067. /**
  104068. * Returns an array of the actively used textures.
  104069. * @param activeTextures Array of BaseTextures
  104070. */
  104071. getActiveTextures(activeTextures: BaseTexture[]): void;
  104072. /**
  104073. * Returns the animatable textures.
  104074. * @param animatables Array of animatable textures.
  104075. */
  104076. getAnimatables(animatables: IAnimatable[]): void;
  104077. /**
  104078. * Disposes the resources of the material.
  104079. * @param forceDisposeTextures - Forces the disposal of all textures.
  104080. */
  104081. dispose(forceDisposeTextures?: boolean): void;
  104082. /**
  104083. * Get the current class name of the texture useful for serialization or dynamic coding.
  104084. * @returns "PBRClearCoatConfiguration"
  104085. */
  104086. getClassName(): string;
  104087. /**
  104088. * Add fallbacks to the effect fallbacks list.
  104089. * @param defines defines the Base texture to use.
  104090. * @param fallbacks defines the current fallback list.
  104091. * @param currentRank defines the current fallback rank.
  104092. * @returns the new fallback rank.
  104093. */
  104094. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104095. /**
  104096. * Add the required uniforms to the current list.
  104097. * @param uniforms defines the current uniform list.
  104098. */
  104099. static AddUniforms(uniforms: string[]): void;
  104100. /**
  104101. * Add the required samplers to the current list.
  104102. * @param samplers defines the current sampler list.
  104103. */
  104104. static AddSamplers(samplers: string[]): void;
  104105. /**
  104106. * Add the required uniforms to the current buffer.
  104107. * @param uniformBuffer defines the current uniform buffer.
  104108. */
  104109. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104110. /**
  104111. * Makes a duplicate of the current configuration into another one.
  104112. * @param clearCoatConfiguration define the config where to copy the info
  104113. */
  104114. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  104115. /**
  104116. * Serializes this clear coat configuration.
  104117. * @returns - An object with the serialized config.
  104118. */
  104119. serialize(): any;
  104120. /**
  104121. * Parses a Clear Coat Configuration from a serialized object.
  104122. * @param source - Serialized object.
  104123. */
  104124. parse(source: any): void;
  104125. }
  104126. }
  104127. declare module BABYLON {
  104128. /**
  104129. * @hidden
  104130. */
  104131. export interface IMaterialAnisotropicDefines {
  104132. ANISOTROPIC: boolean;
  104133. ANISOTROPIC_TEXTURE: boolean;
  104134. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104135. MAINUV1: boolean;
  104136. _areTexturesDirty: boolean;
  104137. _needUVs: boolean;
  104138. }
  104139. /**
  104140. * Define the code related to the anisotropic parameters of the pbr material.
  104141. */
  104142. export class PBRAnisotropicConfiguration {
  104143. private _isEnabled;
  104144. /**
  104145. * Defines if the anisotropy is enabled in the material.
  104146. */
  104147. isEnabled: boolean;
  104148. /**
  104149. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  104150. */
  104151. intensity: number;
  104152. /**
  104153. * Defines if the effect is along the tangents, bitangents or in between.
  104154. * By default, the effect is "strectching" the highlights along the tangents.
  104155. */
  104156. direction: Vector2;
  104157. private _texture;
  104158. /**
  104159. * Stores the anisotropy values in a texture.
  104160. * rg is direction (like normal from -1 to 1)
  104161. * b is a intensity
  104162. */
  104163. texture: Nullable<BaseTexture>;
  104164. /** @hidden */
  104165. private _internalMarkAllSubMeshesAsTexturesDirty;
  104166. /** @hidden */
  104167. _markAllSubMeshesAsTexturesDirty(): void;
  104168. /**
  104169. * Instantiate a new istance of anisotropy configuration.
  104170. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104171. */
  104172. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104173. /**
  104174. * Specifies that the submesh is ready to be used.
  104175. * @param defines the list of "defines" to update.
  104176. * @param scene defines the scene the material belongs to.
  104177. * @returns - boolean indicating that the submesh is ready or not.
  104178. */
  104179. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  104180. /**
  104181. * Checks to see if a texture is used in the material.
  104182. * @param defines the list of "defines" to update.
  104183. * @param mesh the mesh we are preparing the defines for.
  104184. * @param scene defines the scene the material belongs to.
  104185. */
  104186. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  104187. /**
  104188. * Binds the material data.
  104189. * @param uniformBuffer defines the Uniform buffer to fill in.
  104190. * @param scene defines the scene the material belongs to.
  104191. * @param isFrozen defines wether the material is frozen or not.
  104192. */
  104193. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104194. /**
  104195. * Checks to see if a texture is used in the material.
  104196. * @param texture - Base texture to use.
  104197. * @returns - Boolean specifying if a texture is used in the material.
  104198. */
  104199. hasTexture(texture: BaseTexture): boolean;
  104200. /**
  104201. * Returns an array of the actively used textures.
  104202. * @param activeTextures Array of BaseTextures
  104203. */
  104204. getActiveTextures(activeTextures: BaseTexture[]): void;
  104205. /**
  104206. * Returns the animatable textures.
  104207. * @param animatables Array of animatable textures.
  104208. */
  104209. getAnimatables(animatables: IAnimatable[]): void;
  104210. /**
  104211. * Disposes the resources of the material.
  104212. * @param forceDisposeTextures - Forces the disposal of all textures.
  104213. */
  104214. dispose(forceDisposeTextures?: boolean): void;
  104215. /**
  104216. * Get the current class name of the texture useful for serialization or dynamic coding.
  104217. * @returns "PBRAnisotropicConfiguration"
  104218. */
  104219. getClassName(): string;
  104220. /**
  104221. * Add fallbacks to the effect fallbacks list.
  104222. * @param defines defines the Base texture to use.
  104223. * @param fallbacks defines the current fallback list.
  104224. * @param currentRank defines the current fallback rank.
  104225. * @returns the new fallback rank.
  104226. */
  104227. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104228. /**
  104229. * Add the required uniforms to the current list.
  104230. * @param uniforms defines the current uniform list.
  104231. */
  104232. static AddUniforms(uniforms: string[]): void;
  104233. /**
  104234. * Add the required uniforms to the current buffer.
  104235. * @param uniformBuffer defines the current uniform buffer.
  104236. */
  104237. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104238. /**
  104239. * Add the required samplers to the current list.
  104240. * @param samplers defines the current sampler list.
  104241. */
  104242. static AddSamplers(samplers: string[]): void;
  104243. /**
  104244. * Makes a duplicate of the current configuration into another one.
  104245. * @param anisotropicConfiguration define the config where to copy the info
  104246. */
  104247. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  104248. /**
  104249. * Serializes this anisotropy configuration.
  104250. * @returns - An object with the serialized config.
  104251. */
  104252. serialize(): any;
  104253. /**
  104254. * Parses a anisotropy Configuration from a serialized object.
  104255. * @param source - Serialized object.
  104256. */
  104257. parse(source: any): void;
  104258. }
  104259. }
  104260. declare module BABYLON {
  104261. /**
  104262. * @hidden
  104263. */
  104264. export interface IMaterialBRDFDefines {
  104265. BRDF_V_HEIGHT_CORRELATED: boolean;
  104266. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104267. SPHERICAL_HARMONICS: boolean;
  104268. /** @hidden */
  104269. _areMiscDirty: boolean;
  104270. }
  104271. /**
  104272. * Define the code related to the BRDF parameters of the pbr material.
  104273. */
  104274. export class PBRBRDFConfiguration {
  104275. /**
  104276. * Default value used for the energy conservation.
  104277. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104278. */
  104279. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  104280. /**
  104281. * Default value used for the Smith Visibility Height Correlated mode.
  104282. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104283. */
  104284. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  104285. /**
  104286. * Default value used for the IBL diffuse part.
  104287. * This can help switching back to the polynomials mode globally which is a tiny bit
  104288. * less GPU intensive at the drawback of a lower quality.
  104289. */
  104290. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  104291. private _useEnergyConservation;
  104292. /**
  104293. * Defines if the material uses energy conservation.
  104294. */
  104295. useEnergyConservation: boolean;
  104296. private _useSmithVisibilityHeightCorrelated;
  104297. /**
  104298. * LEGACY Mode set to false
  104299. * Defines if the material uses height smith correlated visibility term.
  104300. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  104301. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104302. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  104303. * Not relying on height correlated will also disable energy conservation.
  104304. */
  104305. useSmithVisibilityHeightCorrelated: boolean;
  104306. private _useSphericalHarmonics;
  104307. /**
  104308. * LEGACY Mode set to false
  104309. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  104310. * diffuse part of the IBL.
  104311. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  104312. * to the ground truth.
  104313. */
  104314. useSphericalHarmonics: boolean;
  104315. /** @hidden */
  104316. private _internalMarkAllSubMeshesAsMiscDirty;
  104317. /** @hidden */
  104318. _markAllSubMeshesAsMiscDirty(): void;
  104319. /**
  104320. * Instantiate a new istance of clear coat configuration.
  104321. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  104322. */
  104323. constructor(markAllSubMeshesAsMiscDirty: () => void);
  104324. /**
  104325. * Checks to see if a texture is used in the material.
  104326. * @param defines the list of "defines" to update.
  104327. */
  104328. prepareDefines(defines: IMaterialBRDFDefines): void;
  104329. /**
  104330. * Get the current class name of the texture useful for serialization or dynamic coding.
  104331. * @returns "PBRClearCoatConfiguration"
  104332. */
  104333. getClassName(): string;
  104334. /**
  104335. * Makes a duplicate of the current configuration into another one.
  104336. * @param brdfConfiguration define the config where to copy the info
  104337. */
  104338. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  104339. /**
  104340. * Serializes this BRDF configuration.
  104341. * @returns - An object with the serialized config.
  104342. */
  104343. serialize(): any;
  104344. /**
  104345. * Parses a BRDF Configuration from a serialized object.
  104346. * @param source - Serialized object.
  104347. */
  104348. parse(source: any): void;
  104349. }
  104350. }
  104351. declare module BABYLON {
  104352. /**
  104353. * @hidden
  104354. */
  104355. export interface IMaterialSheenDefines {
  104356. SHEEN: boolean;
  104357. SHEEN_TEXTURE: boolean;
  104358. SHEEN_TEXTUREDIRECTUV: number;
  104359. SHEEN_LINKWITHALBEDO: boolean;
  104360. /** @hidden */
  104361. _areTexturesDirty: boolean;
  104362. }
  104363. /**
  104364. * Define the code related to the Sheen parameters of the pbr material.
  104365. */
  104366. export class PBRSheenConfiguration {
  104367. private _isEnabled;
  104368. /**
  104369. * Defines if the material uses sheen.
  104370. */
  104371. isEnabled: boolean;
  104372. private _linkSheenWithAlbedo;
  104373. /**
  104374. * Defines if the sheen is linked to the sheen color.
  104375. */
  104376. linkSheenWithAlbedo: boolean;
  104377. /**
  104378. * Defines the sheen intensity.
  104379. */
  104380. intensity: number;
  104381. /**
  104382. * Defines the sheen color.
  104383. */
  104384. color: Color3;
  104385. private _texture;
  104386. /**
  104387. * Stores the sheen tint values in a texture.
  104388. * rgb is tint
  104389. * a is a intensity
  104390. */
  104391. texture: Nullable<BaseTexture>;
  104392. /** @hidden */
  104393. private _internalMarkAllSubMeshesAsTexturesDirty;
  104394. /** @hidden */
  104395. _markAllSubMeshesAsTexturesDirty(): void;
  104396. /**
  104397. * Instantiate a new istance of clear coat configuration.
  104398. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104399. */
  104400. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104401. /**
  104402. * Specifies that the submesh is ready to be used.
  104403. * @param defines the list of "defines" to update.
  104404. * @param scene defines the scene the material belongs to.
  104405. * @returns - boolean indicating that the submesh is ready or not.
  104406. */
  104407. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  104408. /**
  104409. * Checks to see if a texture is used in the material.
  104410. * @param defines the list of "defines" to update.
  104411. * @param scene defines the scene the material belongs to.
  104412. */
  104413. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  104414. /**
  104415. * Binds the material data.
  104416. * @param uniformBuffer defines the Uniform buffer to fill in.
  104417. * @param scene defines the scene the material belongs to.
  104418. * @param isFrozen defines wether the material is frozen or not.
  104419. */
  104420. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104421. /**
  104422. * Checks to see if a texture is used in the material.
  104423. * @param texture - Base texture to use.
  104424. * @returns - Boolean specifying if a texture is used in the material.
  104425. */
  104426. hasTexture(texture: BaseTexture): boolean;
  104427. /**
  104428. * Returns an array of the actively used textures.
  104429. * @param activeTextures Array of BaseTextures
  104430. */
  104431. getActiveTextures(activeTextures: BaseTexture[]): void;
  104432. /**
  104433. * Returns the animatable textures.
  104434. * @param animatables Array of animatable textures.
  104435. */
  104436. getAnimatables(animatables: IAnimatable[]): void;
  104437. /**
  104438. * Disposes the resources of the material.
  104439. * @param forceDisposeTextures - Forces the disposal of all textures.
  104440. */
  104441. dispose(forceDisposeTextures?: boolean): void;
  104442. /**
  104443. * Get the current class name of the texture useful for serialization or dynamic coding.
  104444. * @returns "PBRSheenConfiguration"
  104445. */
  104446. getClassName(): string;
  104447. /**
  104448. * Add fallbacks to the effect fallbacks list.
  104449. * @param defines defines the Base texture to use.
  104450. * @param fallbacks defines the current fallback list.
  104451. * @param currentRank defines the current fallback rank.
  104452. * @returns the new fallback rank.
  104453. */
  104454. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104455. /**
  104456. * Add the required uniforms to the current list.
  104457. * @param uniforms defines the current uniform list.
  104458. */
  104459. static AddUniforms(uniforms: string[]): void;
  104460. /**
  104461. * Add the required uniforms to the current buffer.
  104462. * @param uniformBuffer defines the current uniform buffer.
  104463. */
  104464. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104465. /**
  104466. * Add the required samplers to the current list.
  104467. * @param samplers defines the current sampler list.
  104468. */
  104469. static AddSamplers(samplers: string[]): void;
  104470. /**
  104471. * Makes a duplicate of the current configuration into another one.
  104472. * @param sheenConfiguration define the config where to copy the info
  104473. */
  104474. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  104475. /**
  104476. * Serializes this BRDF configuration.
  104477. * @returns - An object with the serialized config.
  104478. */
  104479. serialize(): any;
  104480. /**
  104481. * Parses a Sheen Configuration from a serialized object.
  104482. * @param source - Serialized object.
  104483. */
  104484. parse(source: any): void;
  104485. }
  104486. }
  104487. declare module BABYLON {
  104488. /**
  104489. * @hidden
  104490. */
  104491. export interface IMaterialSubSurfaceDefines {
  104492. SUBSURFACE: boolean;
  104493. SS_REFRACTION: boolean;
  104494. SS_TRANSLUCENCY: boolean;
  104495. SS_SCATERRING: boolean;
  104496. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104497. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104498. SS_REFRACTIONMAP_3D: boolean;
  104499. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104500. SS_LODINREFRACTIONALPHA: boolean;
  104501. SS_GAMMAREFRACTION: boolean;
  104502. SS_RGBDREFRACTION: boolean;
  104503. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104504. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104505. /** @hidden */
  104506. _areTexturesDirty: boolean;
  104507. }
  104508. /**
  104509. * Define the code related to the sub surface parameters of the pbr material.
  104510. */
  104511. export class PBRSubSurfaceConfiguration {
  104512. private _isRefractionEnabled;
  104513. /**
  104514. * Defines if the refraction is enabled in the material.
  104515. */
  104516. isRefractionEnabled: boolean;
  104517. private _isTranslucencyEnabled;
  104518. /**
  104519. * Defines if the translucency is enabled in the material.
  104520. */
  104521. isTranslucencyEnabled: boolean;
  104522. private _isScatteringEnabled;
  104523. /**
  104524. * Defines the refraction intensity of the material.
  104525. * The refraction when enabled replaces the Diffuse part of the material.
  104526. * The intensity helps transitionning between diffuse and refraction.
  104527. */
  104528. refractionIntensity: number;
  104529. /**
  104530. * Defines the translucency intensity of the material.
  104531. * When translucency has been enabled, this defines how much of the "translucency"
  104532. * is addded to the diffuse part of the material.
  104533. */
  104534. translucencyIntensity: number;
  104535. /**
  104536. * Defines the scattering intensity of the material.
  104537. * When scattering has been enabled, this defines how much of the "scattered light"
  104538. * is addded to the diffuse part of the material.
  104539. */
  104540. scatteringIntensity: number;
  104541. private _thicknessTexture;
  104542. /**
  104543. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  104544. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  104545. * 0 would mean minimumThickness
  104546. * 1 would mean maximumThickness
  104547. * The other channels might be use as a mask to vary the different effects intensity.
  104548. */
  104549. thicknessTexture: Nullable<BaseTexture>;
  104550. private _refractionTexture;
  104551. /**
  104552. * Defines the texture to use for refraction.
  104553. */
  104554. refractionTexture: Nullable<BaseTexture>;
  104555. private _indexOfRefraction;
  104556. /**
  104557. * Defines the indice of refraction used in the material.
  104558. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  104559. */
  104560. indexOfRefraction: number;
  104561. private _invertRefractionY;
  104562. /**
  104563. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104564. */
  104565. invertRefractionY: boolean;
  104566. private _linkRefractionWithTransparency;
  104567. /**
  104568. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104569. * Materials half opaque for instance using refraction could benefit from this control.
  104570. */
  104571. linkRefractionWithTransparency: boolean;
  104572. /**
  104573. * Defines the minimum thickness stored in the thickness map.
  104574. * If no thickness map is defined, this value will be used to simulate thickness.
  104575. */
  104576. minimumThickness: number;
  104577. /**
  104578. * Defines the maximum thickness stored in the thickness map.
  104579. */
  104580. maximumThickness: number;
  104581. /**
  104582. * Defines the volume tint of the material.
  104583. * This is used for both translucency and scattering.
  104584. */
  104585. tintColor: Color3;
  104586. /**
  104587. * Defines the distance at which the tint color should be found in the media.
  104588. * This is used for refraction only.
  104589. */
  104590. tintColorAtDistance: number;
  104591. /**
  104592. * Defines how far each channel transmit through the media.
  104593. * It is defined as a color to simplify it selection.
  104594. */
  104595. diffusionDistance: Color3;
  104596. private _useMaskFromThicknessTexture;
  104597. /**
  104598. * Stores the intensity of the different subsurface effects in the thickness texture.
  104599. * * the green channel is the translucency intensity.
  104600. * * the blue channel is the scattering intensity.
  104601. * * the alpha channel is the refraction intensity.
  104602. */
  104603. useMaskFromThicknessTexture: boolean;
  104604. /** @hidden */
  104605. private _internalMarkAllSubMeshesAsTexturesDirty;
  104606. /** @hidden */
  104607. _markAllSubMeshesAsTexturesDirty(): void;
  104608. /**
  104609. * Instantiate a new istance of sub surface configuration.
  104610. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104611. */
  104612. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104613. /**
  104614. * Gets wehter the submesh is ready to be used or not.
  104615. * @param defines the list of "defines" to update.
  104616. * @param scene defines the scene the material belongs to.
  104617. * @returns - boolean indicating that the submesh is ready or not.
  104618. */
  104619. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  104620. /**
  104621. * Checks to see if a texture is used in the material.
  104622. * @param defines the list of "defines" to update.
  104623. * @param scene defines the scene to the material belongs to.
  104624. */
  104625. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  104626. /**
  104627. * Binds the material data.
  104628. * @param uniformBuffer defines the Uniform buffer to fill in.
  104629. * @param scene defines the scene the material belongs to.
  104630. * @param engine defines the engine the material belongs to.
  104631. * @param isFrozen defines wether the material is frozen or not.
  104632. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  104633. */
  104634. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  104635. /**
  104636. * Unbinds the material from the mesh.
  104637. * @param activeEffect defines the effect that should be unbound from.
  104638. * @returns true if unbound, otherwise false
  104639. */
  104640. unbind(activeEffect: Effect): boolean;
  104641. /**
  104642. * Returns the texture used for refraction or null if none is used.
  104643. * @param scene defines the scene the material belongs to.
  104644. * @returns - Refraction texture if present. If no refraction texture and refraction
  104645. * is linked with transparency, returns environment texture. Otherwise, returns null.
  104646. */
  104647. private _getRefractionTexture;
  104648. /**
  104649. * Returns true if alpha blending should be disabled.
  104650. */
  104651. readonly disableAlphaBlending: boolean;
  104652. /**
  104653. * Fills the list of render target textures.
  104654. * @param renderTargets the list of render targets to update
  104655. */
  104656. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  104657. /**
  104658. * Checks to see if a texture is used in the material.
  104659. * @param texture - Base texture to use.
  104660. * @returns - Boolean specifying if a texture is used in the material.
  104661. */
  104662. hasTexture(texture: BaseTexture): boolean;
  104663. /**
  104664. * Gets a boolean indicating that current material needs to register RTT
  104665. * @returns true if this uses a render target otherwise false.
  104666. */
  104667. hasRenderTargetTextures(): boolean;
  104668. /**
  104669. * Returns an array of the actively used textures.
  104670. * @param activeTextures Array of BaseTextures
  104671. */
  104672. getActiveTextures(activeTextures: BaseTexture[]): void;
  104673. /**
  104674. * Returns the animatable textures.
  104675. * @param animatables Array of animatable textures.
  104676. */
  104677. getAnimatables(animatables: IAnimatable[]): void;
  104678. /**
  104679. * Disposes the resources of the material.
  104680. * @param forceDisposeTextures - Forces the disposal of all textures.
  104681. */
  104682. dispose(forceDisposeTextures?: boolean): void;
  104683. /**
  104684. * Get the current class name of the texture useful for serialization or dynamic coding.
  104685. * @returns "PBRSubSurfaceConfiguration"
  104686. */
  104687. getClassName(): string;
  104688. /**
  104689. * Add fallbacks to the effect fallbacks list.
  104690. * @param defines defines the Base texture to use.
  104691. * @param fallbacks defines the current fallback list.
  104692. * @param currentRank defines the current fallback rank.
  104693. * @returns the new fallback rank.
  104694. */
  104695. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104696. /**
  104697. * Add the required uniforms to the current list.
  104698. * @param uniforms defines the current uniform list.
  104699. */
  104700. static AddUniforms(uniforms: string[]): void;
  104701. /**
  104702. * Add the required samplers to the current list.
  104703. * @param samplers defines the current sampler list.
  104704. */
  104705. static AddSamplers(samplers: string[]): void;
  104706. /**
  104707. * Add the required uniforms to the current buffer.
  104708. * @param uniformBuffer defines the current uniform buffer.
  104709. */
  104710. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104711. /**
  104712. * Makes a duplicate of the current configuration into another one.
  104713. * @param configuration define the config where to copy the info
  104714. */
  104715. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  104716. /**
  104717. * Serializes this Sub Surface configuration.
  104718. * @returns - An object with the serialized config.
  104719. */
  104720. serialize(): any;
  104721. /**
  104722. * Parses a Sub Surface Configuration from a serialized object.
  104723. * @param source - Serialized object.
  104724. */
  104725. parse(source: any): void;
  104726. }
  104727. }
  104728. declare module BABYLON {
  104729. /** @hidden */
  104730. export var pbrFragmentDeclaration: {
  104731. name: string;
  104732. shader: string;
  104733. };
  104734. }
  104735. declare module BABYLON {
  104736. /** @hidden */
  104737. export var pbrUboDeclaration: {
  104738. name: string;
  104739. shader: string;
  104740. };
  104741. }
  104742. declare module BABYLON {
  104743. /** @hidden */
  104744. export var pbrFragmentExtraDeclaration: {
  104745. name: string;
  104746. shader: string;
  104747. };
  104748. }
  104749. declare module BABYLON {
  104750. /** @hidden */
  104751. export var pbrFragmentSamplersDeclaration: {
  104752. name: string;
  104753. shader: string;
  104754. };
  104755. }
  104756. declare module BABYLON {
  104757. /** @hidden */
  104758. export var pbrHelperFunctions: {
  104759. name: string;
  104760. shader: string;
  104761. };
  104762. }
  104763. declare module BABYLON {
  104764. /** @hidden */
  104765. export var harmonicsFunctions: {
  104766. name: string;
  104767. shader: string;
  104768. };
  104769. }
  104770. declare module BABYLON {
  104771. /** @hidden */
  104772. export var pbrDirectLightingSetupFunctions: {
  104773. name: string;
  104774. shader: string;
  104775. };
  104776. }
  104777. declare module BABYLON {
  104778. /** @hidden */
  104779. export var pbrDirectLightingFalloffFunctions: {
  104780. name: string;
  104781. shader: string;
  104782. };
  104783. }
  104784. declare module BABYLON {
  104785. /** @hidden */
  104786. export var pbrBRDFFunctions: {
  104787. name: string;
  104788. shader: string;
  104789. };
  104790. }
  104791. declare module BABYLON {
  104792. /** @hidden */
  104793. export var pbrDirectLightingFunctions: {
  104794. name: string;
  104795. shader: string;
  104796. };
  104797. }
  104798. declare module BABYLON {
  104799. /** @hidden */
  104800. export var pbrIBLFunctions: {
  104801. name: string;
  104802. shader: string;
  104803. };
  104804. }
  104805. declare module BABYLON {
  104806. /** @hidden */
  104807. export var pbrDebug: {
  104808. name: string;
  104809. shader: string;
  104810. };
  104811. }
  104812. declare module BABYLON {
  104813. /** @hidden */
  104814. export var pbrPixelShader: {
  104815. name: string;
  104816. shader: string;
  104817. };
  104818. }
  104819. declare module BABYLON {
  104820. /** @hidden */
  104821. export var pbrVertexDeclaration: {
  104822. name: string;
  104823. shader: string;
  104824. };
  104825. }
  104826. declare module BABYLON {
  104827. /** @hidden */
  104828. export var pbrVertexShader: {
  104829. name: string;
  104830. shader: string;
  104831. };
  104832. }
  104833. declare module BABYLON {
  104834. /**
  104835. * Manages the defines for the PBR Material.
  104836. * @hidden
  104837. */
  104838. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  104839. PBR: boolean;
  104840. MAINUV1: boolean;
  104841. MAINUV2: boolean;
  104842. UV1: boolean;
  104843. UV2: boolean;
  104844. ALBEDO: boolean;
  104845. ALBEDODIRECTUV: number;
  104846. VERTEXCOLOR: boolean;
  104847. AMBIENT: boolean;
  104848. AMBIENTDIRECTUV: number;
  104849. AMBIENTINGRAYSCALE: boolean;
  104850. OPACITY: boolean;
  104851. VERTEXALPHA: boolean;
  104852. OPACITYDIRECTUV: number;
  104853. OPACITYRGB: boolean;
  104854. ALPHATEST: boolean;
  104855. DEPTHPREPASS: boolean;
  104856. ALPHABLEND: boolean;
  104857. ALPHAFROMALBEDO: boolean;
  104858. ALPHATESTVALUE: string;
  104859. SPECULAROVERALPHA: boolean;
  104860. RADIANCEOVERALPHA: boolean;
  104861. ALPHAFRESNEL: boolean;
  104862. LINEARALPHAFRESNEL: boolean;
  104863. PREMULTIPLYALPHA: boolean;
  104864. EMISSIVE: boolean;
  104865. EMISSIVEDIRECTUV: number;
  104866. REFLECTIVITY: boolean;
  104867. REFLECTIVITYDIRECTUV: number;
  104868. SPECULARTERM: boolean;
  104869. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  104870. MICROSURFACEAUTOMATIC: boolean;
  104871. LODBASEDMICROSFURACE: boolean;
  104872. MICROSURFACEMAP: boolean;
  104873. MICROSURFACEMAPDIRECTUV: number;
  104874. METALLICWORKFLOW: boolean;
  104875. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  104876. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  104877. METALLNESSSTOREINMETALMAPBLUE: boolean;
  104878. AOSTOREINMETALMAPRED: boolean;
  104879. ENVIRONMENTBRDF: boolean;
  104880. ENVIRONMENTBRDF_RGBD: boolean;
  104881. NORMAL: boolean;
  104882. TANGENT: boolean;
  104883. BUMP: boolean;
  104884. BUMPDIRECTUV: number;
  104885. OBJECTSPACE_NORMALMAP: boolean;
  104886. PARALLAX: boolean;
  104887. PARALLAXOCCLUSION: boolean;
  104888. NORMALXYSCALE: boolean;
  104889. LIGHTMAP: boolean;
  104890. LIGHTMAPDIRECTUV: number;
  104891. USELIGHTMAPASSHADOWMAP: boolean;
  104892. GAMMALIGHTMAP: boolean;
  104893. REFLECTION: boolean;
  104894. REFLECTIONMAP_3D: boolean;
  104895. REFLECTIONMAP_SPHERICAL: boolean;
  104896. REFLECTIONMAP_PLANAR: boolean;
  104897. REFLECTIONMAP_CUBIC: boolean;
  104898. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104899. REFLECTIONMAP_PROJECTION: boolean;
  104900. REFLECTIONMAP_SKYBOX: boolean;
  104901. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104902. REFLECTIONMAP_EXPLICIT: boolean;
  104903. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104904. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104905. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104906. INVERTCUBICMAP: boolean;
  104907. USESPHERICALFROMREFLECTIONMAP: boolean;
  104908. SPHERICAL_HARMONICS: boolean;
  104909. USESPHERICALINVERTEX: boolean;
  104910. REFLECTIONMAP_OPPOSITEZ: boolean;
  104911. LODINREFLECTIONALPHA: boolean;
  104912. GAMMAREFLECTION: boolean;
  104913. RGBDREFLECTION: boolean;
  104914. RADIANCEOCCLUSION: boolean;
  104915. HORIZONOCCLUSION: boolean;
  104916. INSTANCES: boolean;
  104917. NUM_BONE_INFLUENCERS: number;
  104918. BonesPerMesh: number;
  104919. BONETEXTURE: boolean;
  104920. NONUNIFORMSCALING: boolean;
  104921. MORPHTARGETS: boolean;
  104922. MORPHTARGETS_NORMAL: boolean;
  104923. MORPHTARGETS_TANGENT: boolean;
  104924. NUM_MORPH_INFLUENCERS: number;
  104925. IMAGEPROCESSING: boolean;
  104926. VIGNETTE: boolean;
  104927. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104928. VIGNETTEBLENDMODEOPAQUE: boolean;
  104929. TONEMAPPING: boolean;
  104930. TONEMAPPING_ACES: boolean;
  104931. CONTRAST: boolean;
  104932. COLORCURVES: boolean;
  104933. COLORGRADING: boolean;
  104934. COLORGRADING3D: boolean;
  104935. SAMPLER3DGREENDEPTH: boolean;
  104936. SAMPLER3DBGRMAP: boolean;
  104937. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104938. EXPOSURE: boolean;
  104939. MULTIVIEW: boolean;
  104940. USEPHYSICALLIGHTFALLOFF: boolean;
  104941. USEGLTFLIGHTFALLOFF: boolean;
  104942. TWOSIDEDLIGHTING: boolean;
  104943. SHADOWFLOAT: boolean;
  104944. CLIPPLANE: boolean;
  104945. CLIPPLANE2: boolean;
  104946. CLIPPLANE3: boolean;
  104947. CLIPPLANE4: boolean;
  104948. POINTSIZE: boolean;
  104949. FOG: boolean;
  104950. LOGARITHMICDEPTH: boolean;
  104951. FORCENORMALFORWARD: boolean;
  104952. SPECULARAA: boolean;
  104953. CLEARCOAT: boolean;
  104954. CLEARCOAT_DEFAULTIOR: boolean;
  104955. CLEARCOAT_TEXTURE: boolean;
  104956. CLEARCOAT_TEXTUREDIRECTUV: number;
  104957. CLEARCOAT_BUMP: boolean;
  104958. CLEARCOAT_BUMPDIRECTUV: number;
  104959. CLEARCOAT_TINT: boolean;
  104960. CLEARCOAT_TINT_TEXTURE: boolean;
  104961. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104962. ANISOTROPIC: boolean;
  104963. ANISOTROPIC_TEXTURE: boolean;
  104964. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104965. BRDF_V_HEIGHT_CORRELATED: boolean;
  104966. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104967. SHEEN: boolean;
  104968. SHEEN_TEXTURE: boolean;
  104969. SHEEN_TEXTUREDIRECTUV: number;
  104970. SHEEN_LINKWITHALBEDO: boolean;
  104971. SUBSURFACE: boolean;
  104972. SS_REFRACTION: boolean;
  104973. SS_TRANSLUCENCY: boolean;
  104974. SS_SCATERRING: boolean;
  104975. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104976. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104977. SS_REFRACTIONMAP_3D: boolean;
  104978. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104979. SS_LODINREFRACTIONALPHA: boolean;
  104980. SS_GAMMAREFRACTION: boolean;
  104981. SS_RGBDREFRACTION: boolean;
  104982. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104983. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104984. UNLIT: boolean;
  104985. DEBUGMODE: number;
  104986. /**
  104987. * Initializes the PBR Material defines.
  104988. */
  104989. constructor();
  104990. /**
  104991. * Resets the PBR Material defines.
  104992. */
  104993. reset(): void;
  104994. }
  104995. /**
  104996. * The Physically based material base class of BJS.
  104997. *
  104998. * This offers the main features of a standard PBR material.
  104999. * For more information, please refer to the documentation :
  105000. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105001. */
  105002. export abstract class PBRBaseMaterial extends PushMaterial {
  105003. /**
  105004. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105005. */
  105006. static readonly PBRMATERIAL_OPAQUE: number;
  105007. /**
  105008. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105009. */
  105010. static readonly PBRMATERIAL_ALPHATEST: number;
  105011. /**
  105012. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105013. */
  105014. static readonly PBRMATERIAL_ALPHABLEND: number;
  105015. /**
  105016. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105017. * They are also discarded below the alpha cutoff threshold to improve performances.
  105018. */
  105019. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105020. /**
  105021. * Defines the default value of how much AO map is occluding the analytical lights
  105022. * (point spot...).
  105023. */
  105024. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105025. /**
  105026. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  105027. */
  105028. static readonly LIGHTFALLOFF_PHYSICAL: number;
  105029. /**
  105030. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  105031. * to enhance interoperability with other engines.
  105032. */
  105033. static readonly LIGHTFALLOFF_GLTF: number;
  105034. /**
  105035. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  105036. * to enhance interoperability with other materials.
  105037. */
  105038. static readonly LIGHTFALLOFF_STANDARD: number;
  105039. /**
  105040. * Intensity of the direct lights e.g. the four lights available in your scene.
  105041. * This impacts both the direct diffuse and specular highlights.
  105042. */
  105043. protected _directIntensity: number;
  105044. /**
  105045. * Intensity of the emissive part of the material.
  105046. * This helps controlling the emissive effect without modifying the emissive color.
  105047. */
  105048. protected _emissiveIntensity: number;
  105049. /**
  105050. * Intensity of the environment e.g. how much the environment will light the object
  105051. * either through harmonics for rough material or through the refelction for shiny ones.
  105052. */
  105053. protected _environmentIntensity: number;
  105054. /**
  105055. * This is a special control allowing the reduction of the specular highlights coming from the
  105056. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105057. */
  105058. protected _specularIntensity: number;
  105059. /**
  105060. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  105061. */
  105062. private _lightingInfos;
  105063. /**
  105064. * Debug Control allowing disabling the bump map on this material.
  105065. */
  105066. protected _disableBumpMap: boolean;
  105067. /**
  105068. * AKA Diffuse Texture in standard nomenclature.
  105069. */
  105070. protected _albedoTexture: Nullable<BaseTexture>;
  105071. /**
  105072. * AKA Occlusion Texture in other nomenclature.
  105073. */
  105074. protected _ambientTexture: Nullable<BaseTexture>;
  105075. /**
  105076. * AKA Occlusion Texture Intensity in other nomenclature.
  105077. */
  105078. protected _ambientTextureStrength: number;
  105079. /**
  105080. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105081. * 1 means it completely occludes it
  105082. * 0 mean it has no impact
  105083. */
  105084. protected _ambientTextureImpactOnAnalyticalLights: number;
  105085. /**
  105086. * Stores the alpha values in a texture.
  105087. */
  105088. protected _opacityTexture: Nullable<BaseTexture>;
  105089. /**
  105090. * Stores the reflection values in a texture.
  105091. */
  105092. protected _reflectionTexture: Nullable<BaseTexture>;
  105093. /**
  105094. * Stores the emissive values in a texture.
  105095. */
  105096. protected _emissiveTexture: Nullable<BaseTexture>;
  105097. /**
  105098. * AKA Specular texture in other nomenclature.
  105099. */
  105100. protected _reflectivityTexture: Nullable<BaseTexture>;
  105101. /**
  105102. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105103. */
  105104. protected _metallicTexture: Nullable<BaseTexture>;
  105105. /**
  105106. * Specifies the metallic scalar of the metallic/roughness workflow.
  105107. * Can also be used to scale the metalness values of the metallic texture.
  105108. */
  105109. protected _metallic: Nullable<number>;
  105110. /**
  105111. * Specifies the roughness scalar of the metallic/roughness workflow.
  105112. * Can also be used to scale the roughness values of the metallic texture.
  105113. */
  105114. protected _roughness: Nullable<number>;
  105115. /**
  105116. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105117. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105118. */
  105119. protected _microSurfaceTexture: Nullable<BaseTexture>;
  105120. /**
  105121. * Stores surface normal data used to displace a mesh in a texture.
  105122. */
  105123. protected _bumpTexture: Nullable<BaseTexture>;
  105124. /**
  105125. * Stores the pre-calculated light information of a mesh in a texture.
  105126. */
  105127. protected _lightmapTexture: Nullable<BaseTexture>;
  105128. /**
  105129. * The color of a material in ambient lighting.
  105130. */
  105131. protected _ambientColor: Color3;
  105132. /**
  105133. * AKA Diffuse Color in other nomenclature.
  105134. */
  105135. protected _albedoColor: Color3;
  105136. /**
  105137. * AKA Specular Color in other nomenclature.
  105138. */
  105139. protected _reflectivityColor: Color3;
  105140. /**
  105141. * The color applied when light is reflected from a material.
  105142. */
  105143. protected _reflectionColor: Color3;
  105144. /**
  105145. * The color applied when light is emitted from a material.
  105146. */
  105147. protected _emissiveColor: Color3;
  105148. /**
  105149. * AKA Glossiness in other nomenclature.
  105150. */
  105151. protected _microSurface: number;
  105152. /**
  105153. * Specifies that the material will use the light map as a show map.
  105154. */
  105155. protected _useLightmapAsShadowmap: boolean;
  105156. /**
  105157. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105158. * makes the reflect vector face the model (under horizon).
  105159. */
  105160. protected _useHorizonOcclusion: boolean;
  105161. /**
  105162. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105163. * too much the area relying on ambient texture to define their ambient occlusion.
  105164. */
  105165. protected _useRadianceOcclusion: boolean;
  105166. /**
  105167. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105168. */
  105169. protected _useAlphaFromAlbedoTexture: boolean;
  105170. /**
  105171. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  105172. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105173. */
  105174. protected _useSpecularOverAlpha: boolean;
  105175. /**
  105176. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105177. */
  105178. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105179. /**
  105180. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105181. */
  105182. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  105183. /**
  105184. * Specifies if the metallic texture contains the roughness information in its green channel.
  105185. */
  105186. protected _useRoughnessFromMetallicTextureGreen: boolean;
  105187. /**
  105188. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105189. */
  105190. protected _useMetallnessFromMetallicTextureBlue: boolean;
  105191. /**
  105192. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105193. */
  105194. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  105195. /**
  105196. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105197. */
  105198. protected _useAmbientInGrayScale: boolean;
  105199. /**
  105200. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105201. * The material will try to infer what glossiness each pixel should be.
  105202. */
  105203. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  105204. /**
  105205. * Defines the falloff type used in this material.
  105206. * It by default is Physical.
  105207. */
  105208. protected _lightFalloff: number;
  105209. /**
  105210. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105211. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105212. */
  105213. protected _useRadianceOverAlpha: boolean;
  105214. /**
  105215. * Allows using an object space normal map (instead of tangent space).
  105216. */
  105217. protected _useObjectSpaceNormalMap: boolean;
  105218. /**
  105219. * Allows using the bump map in parallax mode.
  105220. */
  105221. protected _useParallax: boolean;
  105222. /**
  105223. * Allows using the bump map in parallax occlusion mode.
  105224. */
  105225. protected _useParallaxOcclusion: boolean;
  105226. /**
  105227. * Controls the scale bias of the parallax mode.
  105228. */
  105229. protected _parallaxScaleBias: number;
  105230. /**
  105231. * If sets to true, disables all the lights affecting the material.
  105232. */
  105233. protected _disableLighting: boolean;
  105234. /**
  105235. * Number of Simultaneous lights allowed on the material.
  105236. */
  105237. protected _maxSimultaneousLights: number;
  105238. /**
  105239. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105240. */
  105241. protected _invertNormalMapX: boolean;
  105242. /**
  105243. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105244. */
  105245. protected _invertNormalMapY: boolean;
  105246. /**
  105247. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105248. */
  105249. protected _twoSidedLighting: boolean;
  105250. /**
  105251. * Defines the alpha limits in alpha test mode.
  105252. */
  105253. protected _alphaCutOff: number;
  105254. /**
  105255. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105256. */
  105257. protected _forceAlphaTest: boolean;
  105258. /**
  105259. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105260. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105261. */
  105262. protected _useAlphaFresnel: boolean;
  105263. /**
  105264. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105265. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105266. */
  105267. protected _useLinearAlphaFresnel: boolean;
  105268. /**
  105269. * The transparency mode of the material.
  105270. */
  105271. protected _transparencyMode: Nullable<number>;
  105272. /**
  105273. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  105274. * from cos thetav and roughness:
  105275. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  105276. */
  105277. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  105278. /**
  105279. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105280. */
  105281. protected _forceIrradianceInFragment: boolean;
  105282. /**
  105283. * Force normal to face away from face.
  105284. */
  105285. protected _forceNormalForward: boolean;
  105286. /**
  105287. * Enables specular anti aliasing in the PBR shader.
  105288. * It will both interacts on the Geometry for analytical and IBL lighting.
  105289. * It also prefilter the roughness map based on the bump values.
  105290. */
  105291. protected _enableSpecularAntiAliasing: boolean;
  105292. /**
  105293. * Default configuration related to image processing available in the PBR Material.
  105294. */
  105295. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105296. /**
  105297. * Keep track of the image processing observer to allow dispose and replace.
  105298. */
  105299. private _imageProcessingObserver;
  105300. /**
  105301. * Attaches a new image processing configuration to the PBR Material.
  105302. * @param configuration
  105303. */
  105304. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105305. /**
  105306. * Stores the available render targets.
  105307. */
  105308. private _renderTargets;
  105309. /**
  105310. * Sets the global ambient color for the material used in lighting calculations.
  105311. */
  105312. private _globalAmbientColor;
  105313. /**
  105314. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  105315. */
  105316. private _useLogarithmicDepth;
  105317. /**
  105318. * If set to true, no lighting calculations will be applied.
  105319. */
  105320. private _unlit;
  105321. private _debugMode;
  105322. /**
  105323. * @hidden
  105324. * This is reserved for the inspector.
  105325. * Defines the material debug mode.
  105326. * It helps seeing only some components of the material while troubleshooting.
  105327. */
  105328. debugMode: number;
  105329. /**
  105330. * @hidden
  105331. * This is reserved for the inspector.
  105332. * Specify from where on screen the debug mode should start.
  105333. * The value goes from -1 (full screen) to 1 (not visible)
  105334. * It helps with side by side comparison against the final render
  105335. * This defaults to -1
  105336. */
  105337. private debugLimit;
  105338. /**
  105339. * @hidden
  105340. * This is reserved for the inspector.
  105341. * As the default viewing range might not be enough (if the ambient is really small for instance)
  105342. * You can use the factor to better multiply the final value.
  105343. */
  105344. private debugFactor;
  105345. /**
  105346. * Defines the clear coat layer parameters for the material.
  105347. */
  105348. readonly clearCoat: PBRClearCoatConfiguration;
  105349. /**
  105350. * Defines the anisotropic parameters for the material.
  105351. */
  105352. readonly anisotropy: PBRAnisotropicConfiguration;
  105353. /**
  105354. * Defines the BRDF parameters for the material.
  105355. */
  105356. readonly brdf: PBRBRDFConfiguration;
  105357. /**
  105358. * Defines the Sheen parameters for the material.
  105359. */
  105360. readonly sheen: PBRSheenConfiguration;
  105361. /**
  105362. * Defines the SubSurface parameters for the material.
  105363. */
  105364. readonly subSurface: PBRSubSurfaceConfiguration;
  105365. /**
  105366. * Custom callback helping to override the default shader used in the material.
  105367. */
  105368. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  105369. /**
  105370. * Instantiates a new PBRMaterial instance.
  105371. *
  105372. * @param name The material name
  105373. * @param scene The scene the material will be use in.
  105374. */
  105375. constructor(name: string, scene: Scene);
  105376. /**
  105377. * Gets a boolean indicating that current material needs to register RTT
  105378. */
  105379. readonly hasRenderTargetTextures: boolean;
  105380. /**
  105381. * Gets the name of the material class.
  105382. */
  105383. getClassName(): string;
  105384. /**
  105385. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105386. */
  105387. /**
  105388. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105389. */
  105390. useLogarithmicDepth: boolean;
  105391. /**
  105392. * Gets the current transparency mode.
  105393. */
  105394. /**
  105395. * Sets the transparency mode of the material.
  105396. *
  105397. * | Value | Type | Description |
  105398. * | ----- | ----------------------------------- | ----------- |
  105399. * | 0 | OPAQUE | |
  105400. * | 1 | ALPHATEST | |
  105401. * | 2 | ALPHABLEND | |
  105402. * | 3 | ALPHATESTANDBLEND | |
  105403. *
  105404. */
  105405. transparencyMode: Nullable<number>;
  105406. /**
  105407. * Returns true if alpha blending should be disabled.
  105408. */
  105409. private readonly _disableAlphaBlending;
  105410. /**
  105411. * Specifies whether or not this material should be rendered in alpha blend mode.
  105412. */
  105413. needAlphaBlending(): boolean;
  105414. /**
  105415. * Specifies if the mesh will require alpha blending.
  105416. * @param mesh - BJS mesh.
  105417. */
  105418. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105419. /**
  105420. * Specifies whether or not this material should be rendered in alpha test mode.
  105421. */
  105422. needAlphaTesting(): boolean;
  105423. /**
  105424. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  105425. */
  105426. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  105427. /**
  105428. * Gets the texture used for the alpha test.
  105429. */
  105430. getAlphaTestTexture(): Nullable<BaseTexture>;
  105431. /**
  105432. * Specifies that the submesh is ready to be used.
  105433. * @param mesh - BJS mesh.
  105434. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  105435. * @param useInstances - Specifies that instances should be used.
  105436. * @returns - boolean indicating that the submesh is ready or not.
  105437. */
  105438. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105439. /**
  105440. * Specifies if the material uses metallic roughness workflow.
  105441. * @returns boolean specifiying if the material uses metallic roughness workflow.
  105442. */
  105443. isMetallicWorkflow(): boolean;
  105444. private _prepareEffect;
  105445. private _prepareDefines;
  105446. /**
  105447. * Force shader compilation
  105448. */
  105449. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  105450. clipPlane: boolean;
  105451. }>): void;
  105452. /**
  105453. * Initializes the uniform buffer layout for the shader.
  105454. */
  105455. buildUniformLayout(): void;
  105456. /**
  105457. * Unbinds the material from the mesh
  105458. */
  105459. unbind(): void;
  105460. /**
  105461. * Binds the submesh data.
  105462. * @param world - The world matrix.
  105463. * @param mesh - The BJS mesh.
  105464. * @param subMesh - A submesh of the BJS mesh.
  105465. */
  105466. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105467. /**
  105468. * Returns the animatable textures.
  105469. * @returns - Array of animatable textures.
  105470. */
  105471. getAnimatables(): IAnimatable[];
  105472. /**
  105473. * Returns the texture used for reflections.
  105474. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  105475. */
  105476. private _getReflectionTexture;
  105477. /**
  105478. * Returns an array of the actively used textures.
  105479. * @returns - Array of BaseTextures
  105480. */
  105481. getActiveTextures(): BaseTexture[];
  105482. /**
  105483. * Checks to see if a texture is used in the material.
  105484. * @param texture - Base texture to use.
  105485. * @returns - Boolean specifying if a texture is used in the material.
  105486. */
  105487. hasTexture(texture: BaseTexture): boolean;
  105488. /**
  105489. * Disposes the resources of the material.
  105490. * @param forceDisposeEffect - Forces the disposal of effects.
  105491. * @param forceDisposeTextures - Forces the disposal of all textures.
  105492. */
  105493. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105494. }
  105495. }
  105496. declare module BABYLON {
  105497. /**
  105498. * The Physically based material of BJS.
  105499. *
  105500. * This offers the main features of a standard PBR material.
  105501. * For more information, please refer to the documentation :
  105502. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105503. */
  105504. export class PBRMaterial extends PBRBaseMaterial {
  105505. /**
  105506. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105507. */
  105508. static readonly PBRMATERIAL_OPAQUE: number;
  105509. /**
  105510. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105511. */
  105512. static readonly PBRMATERIAL_ALPHATEST: number;
  105513. /**
  105514. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105515. */
  105516. static readonly PBRMATERIAL_ALPHABLEND: number;
  105517. /**
  105518. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105519. * They are also discarded below the alpha cutoff threshold to improve performances.
  105520. */
  105521. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105522. /**
  105523. * Defines the default value of how much AO map is occluding the analytical lights
  105524. * (point spot...).
  105525. */
  105526. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105527. /**
  105528. * Intensity of the direct lights e.g. the four lights available in your scene.
  105529. * This impacts both the direct diffuse and specular highlights.
  105530. */
  105531. directIntensity: number;
  105532. /**
  105533. * Intensity of the emissive part of the material.
  105534. * This helps controlling the emissive effect without modifying the emissive color.
  105535. */
  105536. emissiveIntensity: number;
  105537. /**
  105538. * Intensity of the environment e.g. how much the environment will light the object
  105539. * either through harmonics for rough material or through the refelction for shiny ones.
  105540. */
  105541. environmentIntensity: number;
  105542. /**
  105543. * This is a special control allowing the reduction of the specular highlights coming from the
  105544. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105545. */
  105546. specularIntensity: number;
  105547. /**
  105548. * Debug Control allowing disabling the bump map on this material.
  105549. */
  105550. disableBumpMap: boolean;
  105551. /**
  105552. * AKA Diffuse Texture in standard nomenclature.
  105553. */
  105554. albedoTexture: BaseTexture;
  105555. /**
  105556. * AKA Occlusion Texture in other nomenclature.
  105557. */
  105558. ambientTexture: BaseTexture;
  105559. /**
  105560. * AKA Occlusion Texture Intensity in other nomenclature.
  105561. */
  105562. ambientTextureStrength: number;
  105563. /**
  105564. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105565. * 1 means it completely occludes it
  105566. * 0 mean it has no impact
  105567. */
  105568. ambientTextureImpactOnAnalyticalLights: number;
  105569. /**
  105570. * Stores the alpha values in a texture.
  105571. */
  105572. opacityTexture: BaseTexture;
  105573. /**
  105574. * Stores the reflection values in a texture.
  105575. */
  105576. reflectionTexture: Nullable<BaseTexture>;
  105577. /**
  105578. * Stores the emissive values in a texture.
  105579. */
  105580. emissiveTexture: BaseTexture;
  105581. /**
  105582. * AKA Specular texture in other nomenclature.
  105583. */
  105584. reflectivityTexture: BaseTexture;
  105585. /**
  105586. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105587. */
  105588. metallicTexture: BaseTexture;
  105589. /**
  105590. * Specifies the metallic scalar of the metallic/roughness workflow.
  105591. * Can also be used to scale the metalness values of the metallic texture.
  105592. */
  105593. metallic: Nullable<number>;
  105594. /**
  105595. * Specifies the roughness scalar of the metallic/roughness workflow.
  105596. * Can also be used to scale the roughness values of the metallic texture.
  105597. */
  105598. roughness: Nullable<number>;
  105599. /**
  105600. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105601. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105602. */
  105603. microSurfaceTexture: BaseTexture;
  105604. /**
  105605. * Stores surface normal data used to displace a mesh in a texture.
  105606. */
  105607. bumpTexture: BaseTexture;
  105608. /**
  105609. * Stores the pre-calculated light information of a mesh in a texture.
  105610. */
  105611. lightmapTexture: BaseTexture;
  105612. /**
  105613. * Stores the refracted light information in a texture.
  105614. */
  105615. refractionTexture: Nullable<BaseTexture>;
  105616. /**
  105617. * The color of a material in ambient lighting.
  105618. */
  105619. ambientColor: Color3;
  105620. /**
  105621. * AKA Diffuse Color in other nomenclature.
  105622. */
  105623. albedoColor: Color3;
  105624. /**
  105625. * AKA Specular Color in other nomenclature.
  105626. */
  105627. reflectivityColor: Color3;
  105628. /**
  105629. * The color reflected from the material.
  105630. */
  105631. reflectionColor: Color3;
  105632. /**
  105633. * The color emitted from the material.
  105634. */
  105635. emissiveColor: Color3;
  105636. /**
  105637. * AKA Glossiness in other nomenclature.
  105638. */
  105639. microSurface: number;
  105640. /**
  105641. * source material index of refraction (IOR)' / 'destination material IOR.
  105642. */
  105643. indexOfRefraction: number;
  105644. /**
  105645. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105646. */
  105647. invertRefractionY: boolean;
  105648. /**
  105649. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105650. * Materials half opaque for instance using refraction could benefit from this control.
  105651. */
  105652. linkRefractionWithTransparency: boolean;
  105653. /**
  105654. * If true, the light map contains occlusion information instead of lighting info.
  105655. */
  105656. useLightmapAsShadowmap: boolean;
  105657. /**
  105658. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105659. */
  105660. useAlphaFromAlbedoTexture: boolean;
  105661. /**
  105662. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105663. */
  105664. forceAlphaTest: boolean;
  105665. /**
  105666. * Defines the alpha limits in alpha test mode.
  105667. */
  105668. alphaCutOff: number;
  105669. /**
  105670. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105671. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105672. */
  105673. useSpecularOverAlpha: boolean;
  105674. /**
  105675. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105676. */
  105677. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105678. /**
  105679. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105680. */
  105681. useRoughnessFromMetallicTextureAlpha: boolean;
  105682. /**
  105683. * Specifies if the metallic texture contains the roughness information in its green channel.
  105684. */
  105685. useRoughnessFromMetallicTextureGreen: boolean;
  105686. /**
  105687. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105688. */
  105689. useMetallnessFromMetallicTextureBlue: boolean;
  105690. /**
  105691. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105692. */
  105693. useAmbientOcclusionFromMetallicTextureRed: boolean;
  105694. /**
  105695. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105696. */
  105697. useAmbientInGrayScale: boolean;
  105698. /**
  105699. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105700. * The material will try to infer what glossiness each pixel should be.
  105701. */
  105702. useAutoMicroSurfaceFromReflectivityMap: boolean;
  105703. /**
  105704. * BJS is using an harcoded light falloff based on a manually sets up range.
  105705. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105706. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105707. */
  105708. /**
  105709. * BJS is using an harcoded light falloff based on a manually sets up range.
  105710. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105711. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105712. */
  105713. usePhysicalLightFalloff: boolean;
  105714. /**
  105715. * In order to support the falloff compatibility with gltf, a special mode has been added
  105716. * to reproduce the gltf light falloff.
  105717. */
  105718. /**
  105719. * In order to support the falloff compatibility with gltf, a special mode has been added
  105720. * to reproduce the gltf light falloff.
  105721. */
  105722. useGLTFLightFalloff: boolean;
  105723. /**
  105724. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105725. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105726. */
  105727. useRadianceOverAlpha: boolean;
  105728. /**
  105729. * Allows using an object space normal map (instead of tangent space).
  105730. */
  105731. useObjectSpaceNormalMap: boolean;
  105732. /**
  105733. * Allows using the bump map in parallax mode.
  105734. */
  105735. useParallax: boolean;
  105736. /**
  105737. * Allows using the bump map in parallax occlusion mode.
  105738. */
  105739. useParallaxOcclusion: boolean;
  105740. /**
  105741. * Controls the scale bias of the parallax mode.
  105742. */
  105743. parallaxScaleBias: number;
  105744. /**
  105745. * If sets to true, disables all the lights affecting the material.
  105746. */
  105747. disableLighting: boolean;
  105748. /**
  105749. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105750. */
  105751. forceIrradianceInFragment: boolean;
  105752. /**
  105753. * Number of Simultaneous lights allowed on the material.
  105754. */
  105755. maxSimultaneousLights: number;
  105756. /**
  105757. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105758. */
  105759. invertNormalMapX: boolean;
  105760. /**
  105761. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105762. */
  105763. invertNormalMapY: boolean;
  105764. /**
  105765. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105766. */
  105767. twoSidedLighting: boolean;
  105768. /**
  105769. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105770. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105771. */
  105772. useAlphaFresnel: boolean;
  105773. /**
  105774. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105775. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105776. */
  105777. useLinearAlphaFresnel: boolean;
  105778. /**
  105779. * Let user defines the brdf lookup texture used for IBL.
  105780. * A default 8bit version is embedded but you could point at :
  105781. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  105782. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105783. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105784. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105785. */
  105786. environmentBRDFTexture: Nullable<BaseTexture>;
  105787. /**
  105788. * Force normal to face away from face.
  105789. */
  105790. forceNormalForward: boolean;
  105791. /**
  105792. * Enables specular anti aliasing in the PBR shader.
  105793. * It will both interacts on the Geometry for analytical and IBL lighting.
  105794. * It also prefilter the roughness map based on the bump values.
  105795. */
  105796. enableSpecularAntiAliasing: boolean;
  105797. /**
  105798. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105799. * makes the reflect vector face the model (under horizon).
  105800. */
  105801. useHorizonOcclusion: boolean;
  105802. /**
  105803. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105804. * too much the area relying on ambient texture to define their ambient occlusion.
  105805. */
  105806. useRadianceOcclusion: boolean;
  105807. /**
  105808. * If set to true, no lighting calculations will be applied.
  105809. */
  105810. unlit: boolean;
  105811. /**
  105812. * Gets the image processing configuration used either in this material.
  105813. */
  105814. /**
  105815. * Sets the Default image processing configuration used either in the this material.
  105816. *
  105817. * If sets to null, the scene one is in use.
  105818. */
  105819. imageProcessingConfiguration: ImageProcessingConfiguration;
  105820. /**
  105821. * Gets wether the color curves effect is enabled.
  105822. */
  105823. /**
  105824. * Sets wether the color curves effect is enabled.
  105825. */
  105826. cameraColorCurvesEnabled: boolean;
  105827. /**
  105828. * Gets wether the color grading effect is enabled.
  105829. */
  105830. /**
  105831. * Gets wether the color grading effect is enabled.
  105832. */
  105833. cameraColorGradingEnabled: boolean;
  105834. /**
  105835. * Gets wether tonemapping is enabled or not.
  105836. */
  105837. /**
  105838. * Sets wether tonemapping is enabled or not
  105839. */
  105840. cameraToneMappingEnabled: boolean;
  105841. /**
  105842. * The camera exposure used on this material.
  105843. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105844. * This corresponds to a photographic exposure.
  105845. */
  105846. /**
  105847. * The camera exposure used on this material.
  105848. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105849. * This corresponds to a photographic exposure.
  105850. */
  105851. cameraExposure: number;
  105852. /**
  105853. * Gets The camera contrast used on this material.
  105854. */
  105855. /**
  105856. * Sets The camera contrast used on this material.
  105857. */
  105858. cameraContrast: number;
  105859. /**
  105860. * Gets the Color Grading 2D Lookup Texture.
  105861. */
  105862. /**
  105863. * Sets the Color Grading 2D Lookup Texture.
  105864. */
  105865. cameraColorGradingTexture: Nullable<BaseTexture>;
  105866. /**
  105867. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105868. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105869. * 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;
  105870. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105871. */
  105872. /**
  105873. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105874. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105875. * 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;
  105876. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105877. */
  105878. cameraColorCurves: Nullable<ColorCurves>;
  105879. /**
  105880. * Instantiates a new PBRMaterial instance.
  105881. *
  105882. * @param name The material name
  105883. * @param scene The scene the material will be use in.
  105884. */
  105885. constructor(name: string, scene: Scene);
  105886. /**
  105887. * Returns the name of this material class.
  105888. */
  105889. getClassName(): string;
  105890. /**
  105891. * Makes a duplicate of the current material.
  105892. * @param name - name to use for the new material.
  105893. */
  105894. clone(name: string): PBRMaterial;
  105895. /**
  105896. * Serializes this PBR Material.
  105897. * @returns - An object with the serialized material.
  105898. */
  105899. serialize(): any;
  105900. /**
  105901. * Parses a PBR Material from a serialized object.
  105902. * @param source - Serialized object.
  105903. * @param scene - BJS scene instance.
  105904. * @param rootUrl - url for the scene object
  105905. * @returns - PBRMaterial
  105906. */
  105907. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  105908. }
  105909. }
  105910. declare module BABYLON {
  105911. /**
  105912. * Direct draw surface info
  105913. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  105914. */
  105915. export interface DDSInfo {
  105916. /**
  105917. * Width of the texture
  105918. */
  105919. width: number;
  105920. /**
  105921. * Width of the texture
  105922. */
  105923. height: number;
  105924. /**
  105925. * Number of Mipmaps for the texture
  105926. * @see https://en.wikipedia.org/wiki/Mipmap
  105927. */
  105928. mipmapCount: number;
  105929. /**
  105930. * If the textures format is a known fourCC format
  105931. * @see https://www.fourcc.org/
  105932. */
  105933. isFourCC: boolean;
  105934. /**
  105935. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  105936. */
  105937. isRGB: boolean;
  105938. /**
  105939. * If the texture is a lumincance format
  105940. */
  105941. isLuminance: boolean;
  105942. /**
  105943. * If this is a cube texture
  105944. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  105945. */
  105946. isCube: boolean;
  105947. /**
  105948. * If the texture is a compressed format eg. FOURCC_DXT1
  105949. */
  105950. isCompressed: boolean;
  105951. /**
  105952. * The dxgiFormat of the texture
  105953. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  105954. */
  105955. dxgiFormat: number;
  105956. /**
  105957. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  105958. */
  105959. textureType: number;
  105960. /**
  105961. * Sphericle polynomial created for the dds texture
  105962. */
  105963. sphericalPolynomial?: SphericalPolynomial;
  105964. }
  105965. /**
  105966. * Class used to provide DDS decompression tools
  105967. */
  105968. export class DDSTools {
  105969. /**
  105970. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  105971. */
  105972. static StoreLODInAlphaChannel: boolean;
  105973. /**
  105974. * Gets DDS information from an array buffer
  105975. * @param arrayBuffer defines the array buffer to read data from
  105976. * @returns the DDS information
  105977. */
  105978. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105979. private static _FloatView;
  105980. private static _Int32View;
  105981. private static _ToHalfFloat;
  105982. private static _FromHalfFloat;
  105983. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105984. private static _GetHalfFloatRGBAArrayBuffer;
  105985. private static _GetFloatRGBAArrayBuffer;
  105986. private static _GetFloatAsUIntRGBAArrayBuffer;
  105987. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105988. private static _GetRGBAArrayBuffer;
  105989. private static _ExtractLongWordOrder;
  105990. private static _GetRGBArrayBuffer;
  105991. private static _GetLuminanceArrayBuffer;
  105992. /**
  105993. * Uploads DDS Levels to a Babylon Texture
  105994. * @hidden
  105995. */
  105996. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105997. }
  105998. interface Engine {
  105999. /**
  106000. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  106001. * @param rootUrl defines the url where the file to load is located
  106002. * @param scene defines the current scene
  106003. * @param lodScale defines scale to apply to the mip map selection
  106004. * @param lodOffset defines offset to apply to the mip map selection
  106005. * @param onLoad defines an optional callback raised when the texture is loaded
  106006. * @param onError defines an optional callback raised if there is an issue to load the texture
  106007. * @param format defines the format of the data
  106008. * @param forcedExtension defines the extension to use to pick the right loader
  106009. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  106010. * @returns the cube texture as an InternalTexture
  106011. */
  106012. 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;
  106013. }
  106014. }
  106015. declare module BABYLON {
  106016. /**
  106017. * Implementation of the DDS Texture Loader.
  106018. * @hidden
  106019. */
  106020. export class _DDSTextureLoader implements IInternalTextureLoader {
  106021. /**
  106022. * Defines wether the loader supports cascade loading the different faces.
  106023. */
  106024. readonly supportCascades: boolean;
  106025. /**
  106026. * This returns if the loader support the current file information.
  106027. * @param extension defines the file extension of the file being loaded
  106028. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106029. * @param fallback defines the fallback internal texture if any
  106030. * @param isBase64 defines whether the texture is encoded as a base64
  106031. * @param isBuffer defines whether the texture data are stored as a buffer
  106032. * @returns true if the loader can load the specified file
  106033. */
  106034. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106035. /**
  106036. * Transform the url before loading if required.
  106037. * @param rootUrl the url of the texture
  106038. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106039. * @returns the transformed texture
  106040. */
  106041. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106042. /**
  106043. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106044. * @param rootUrl the url of the texture
  106045. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106046. * @returns the fallback texture
  106047. */
  106048. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106049. /**
  106050. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106051. * @param data contains the texture data
  106052. * @param texture defines the BabylonJS internal texture
  106053. * @param createPolynomials will be true if polynomials have been requested
  106054. * @param onLoad defines the callback to trigger once the texture is ready
  106055. * @param onError defines the callback to trigger in case of error
  106056. */
  106057. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106058. /**
  106059. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106060. * @param data contains the texture data
  106061. * @param texture defines the BabylonJS internal texture
  106062. * @param callback defines the method to call once ready to upload
  106063. */
  106064. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106065. }
  106066. }
  106067. declare module BABYLON {
  106068. /** @hidden */
  106069. export var rgbdEncodePixelShader: {
  106070. name: string;
  106071. shader: string;
  106072. };
  106073. }
  106074. declare module BABYLON {
  106075. /**
  106076. * Raw texture data and descriptor sufficient for WebGL texture upload
  106077. */
  106078. export interface EnvironmentTextureInfo {
  106079. /**
  106080. * Version of the environment map
  106081. */
  106082. version: number;
  106083. /**
  106084. * Width of image
  106085. */
  106086. width: number;
  106087. /**
  106088. * Irradiance information stored in the file.
  106089. */
  106090. irradiance: any;
  106091. /**
  106092. * Specular information stored in the file.
  106093. */
  106094. specular: any;
  106095. }
  106096. /**
  106097. * Sets of helpers addressing the serialization and deserialization of environment texture
  106098. * stored in a BabylonJS env file.
  106099. * Those files are usually stored as .env files.
  106100. */
  106101. export class EnvironmentTextureTools {
  106102. /**
  106103. * Magic number identifying the env file.
  106104. */
  106105. private static _MagicBytes;
  106106. /**
  106107. * Gets the environment info from an env file.
  106108. * @param data The array buffer containing the .env bytes.
  106109. * @returns the environment file info (the json header) if successfully parsed.
  106110. */
  106111. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  106112. /**
  106113. * Creates an environment texture from a loaded cube texture.
  106114. * @param texture defines the cube texture to convert in env file
  106115. * @return a promise containing the environment data if succesfull.
  106116. */
  106117. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  106118. /**
  106119. * Creates a JSON representation of the spherical data.
  106120. * @param texture defines the texture containing the polynomials
  106121. * @return the JSON representation of the spherical info
  106122. */
  106123. private static _CreateEnvTextureIrradiance;
  106124. /**
  106125. * Uploads the texture info contained in the env file to the GPU.
  106126. * @param texture defines the internal texture to upload to
  106127. * @param arrayBuffer defines the buffer cotaining the data to load
  106128. * @param info defines the texture info retrieved through the GetEnvInfo method
  106129. * @returns a promise
  106130. */
  106131. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  106132. /**
  106133. * Uploads the levels of image data to the GPU.
  106134. * @param texture defines the internal texture to upload to
  106135. * @param imageData defines the array buffer views of image data [mipmap][face]
  106136. * @returns a promise
  106137. */
  106138. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  106139. /**
  106140. * Uploads spherical polynomials information to the texture.
  106141. * @param texture defines the texture we are trying to upload the information to
  106142. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  106143. */
  106144. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  106145. /** @hidden */
  106146. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106147. }
  106148. }
  106149. declare module BABYLON {
  106150. /**
  106151. * Implementation of the ENV Texture Loader.
  106152. * @hidden
  106153. */
  106154. export class _ENVTextureLoader implements IInternalTextureLoader {
  106155. /**
  106156. * Defines wether the loader supports cascade loading the different faces.
  106157. */
  106158. readonly supportCascades: boolean;
  106159. /**
  106160. * This returns if the loader support the current file information.
  106161. * @param extension defines the file extension of the file being loaded
  106162. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106163. * @param fallback defines the fallback internal texture if any
  106164. * @param isBase64 defines whether the texture is encoded as a base64
  106165. * @param isBuffer defines whether the texture data are stored as a buffer
  106166. * @returns true if the loader can load the specified file
  106167. */
  106168. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106169. /**
  106170. * Transform the url before loading if required.
  106171. * @param rootUrl the url of the texture
  106172. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106173. * @returns the transformed texture
  106174. */
  106175. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106176. /**
  106177. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106178. * @param rootUrl the url of the texture
  106179. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106180. * @returns the fallback texture
  106181. */
  106182. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106183. /**
  106184. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106185. * @param data contains the texture data
  106186. * @param texture defines the BabylonJS internal texture
  106187. * @param createPolynomials will be true if polynomials have been requested
  106188. * @param onLoad defines the callback to trigger once the texture is ready
  106189. * @param onError defines the callback to trigger in case of error
  106190. */
  106191. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106192. /**
  106193. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106194. * @param data contains the texture data
  106195. * @param texture defines the BabylonJS internal texture
  106196. * @param callback defines the method to call once ready to upload
  106197. */
  106198. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106199. }
  106200. }
  106201. declare module BABYLON {
  106202. /**
  106203. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106204. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106205. */
  106206. export class KhronosTextureContainer {
  106207. /** contents of the KTX container file */
  106208. arrayBuffer: any;
  106209. private static HEADER_LEN;
  106210. private static COMPRESSED_2D;
  106211. private static COMPRESSED_3D;
  106212. private static TEX_2D;
  106213. private static TEX_3D;
  106214. /**
  106215. * Gets the openGL type
  106216. */
  106217. glType: number;
  106218. /**
  106219. * Gets the openGL type size
  106220. */
  106221. glTypeSize: number;
  106222. /**
  106223. * Gets the openGL format
  106224. */
  106225. glFormat: number;
  106226. /**
  106227. * Gets the openGL internal format
  106228. */
  106229. glInternalFormat: number;
  106230. /**
  106231. * Gets the base internal format
  106232. */
  106233. glBaseInternalFormat: number;
  106234. /**
  106235. * Gets image width in pixel
  106236. */
  106237. pixelWidth: number;
  106238. /**
  106239. * Gets image height in pixel
  106240. */
  106241. pixelHeight: number;
  106242. /**
  106243. * Gets image depth in pixels
  106244. */
  106245. pixelDepth: number;
  106246. /**
  106247. * Gets the number of array elements
  106248. */
  106249. numberOfArrayElements: number;
  106250. /**
  106251. * Gets the number of faces
  106252. */
  106253. numberOfFaces: number;
  106254. /**
  106255. * Gets the number of mipmap levels
  106256. */
  106257. numberOfMipmapLevels: number;
  106258. /**
  106259. * Gets the bytes of key value data
  106260. */
  106261. bytesOfKeyValueData: number;
  106262. /**
  106263. * Gets the load type
  106264. */
  106265. loadType: number;
  106266. /**
  106267. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  106268. */
  106269. isInvalid: boolean;
  106270. /**
  106271. * Creates a new KhronosTextureContainer
  106272. * @param arrayBuffer contents of the KTX container file
  106273. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  106274. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  106275. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  106276. */
  106277. constructor(
  106278. /** contents of the KTX container file */
  106279. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  106280. /**
  106281. * Uploads KTX content to a Babylon Texture.
  106282. * It is assumed that the texture has already been created & is currently bound
  106283. * @hidden
  106284. */
  106285. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  106286. private _upload2DCompressedLevels;
  106287. }
  106288. }
  106289. declare module BABYLON {
  106290. /**
  106291. * Implementation of the KTX Texture Loader.
  106292. * @hidden
  106293. */
  106294. export class _KTXTextureLoader implements IInternalTextureLoader {
  106295. /**
  106296. * Defines wether the loader supports cascade loading the different faces.
  106297. */
  106298. readonly supportCascades: boolean;
  106299. /**
  106300. * This returns if the loader support the current file information.
  106301. * @param extension defines the file extension of the file being loaded
  106302. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106303. * @param fallback defines the fallback internal texture if any
  106304. * @param isBase64 defines whether the texture is encoded as a base64
  106305. * @param isBuffer defines whether the texture data are stored as a buffer
  106306. * @returns true if the loader can load the specified file
  106307. */
  106308. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106309. /**
  106310. * Transform the url before loading if required.
  106311. * @param rootUrl the url of the texture
  106312. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106313. * @returns the transformed texture
  106314. */
  106315. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106316. /**
  106317. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106318. * @param rootUrl the url of the texture
  106319. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106320. * @returns the fallback texture
  106321. */
  106322. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106323. /**
  106324. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106325. * @param data contains the texture data
  106326. * @param texture defines the BabylonJS internal texture
  106327. * @param createPolynomials will be true if polynomials have been requested
  106328. * @param onLoad defines the callback to trigger once the texture is ready
  106329. * @param onError defines the callback to trigger in case of error
  106330. */
  106331. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106332. /**
  106333. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106334. * @param data contains the texture data
  106335. * @param texture defines the BabylonJS internal texture
  106336. * @param callback defines the method to call once ready to upload
  106337. */
  106338. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  106339. }
  106340. }
  106341. declare module BABYLON {
  106342. /** @hidden */
  106343. export var _forceSceneHelpersToBundle: boolean;
  106344. interface Scene {
  106345. /**
  106346. * Creates a default light for the scene.
  106347. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  106348. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  106349. */
  106350. createDefaultLight(replace?: boolean): void;
  106351. /**
  106352. * Creates a default camera for the scene.
  106353. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  106354. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106355. * @param replace has default false, when true replaces the active camera in the scene
  106356. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  106357. */
  106358. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106359. /**
  106360. * Creates a default camera and a default light.
  106361. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  106362. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106363. * @param replace has the default false, when true replaces the active camera/light in the scene
  106364. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  106365. */
  106366. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106367. /**
  106368. * Creates a new sky box
  106369. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  106370. * @param environmentTexture defines the texture to use as environment texture
  106371. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  106372. * @param scale defines the overall scale of the skybox
  106373. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  106374. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  106375. * @returns a new mesh holding the sky box
  106376. */
  106377. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  106378. /**
  106379. * Creates a new environment
  106380. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  106381. * @param options defines the options you can use to configure the environment
  106382. * @returns the new EnvironmentHelper
  106383. */
  106384. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  106385. /**
  106386. * Creates a new VREXperienceHelper
  106387. * @see http://doc.babylonjs.com/how_to/webvr_helper
  106388. * @param webVROptions defines the options used to create the new VREXperienceHelper
  106389. * @returns a new VREXperienceHelper
  106390. */
  106391. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  106392. /**
  106393. * Creates a new XREXperienceHelper
  106394. * @see http://doc.babylonjs.com/how_to/webxr
  106395. * @returns a promise for a new XREXperienceHelper
  106396. */
  106397. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  106398. }
  106399. }
  106400. declare module BABYLON {
  106401. /**
  106402. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  106403. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  106404. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  106405. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106406. */
  106407. export class VideoDome extends TransformNode {
  106408. /**
  106409. * Define the video source as a Monoscopic panoramic 360 video.
  106410. */
  106411. static readonly MODE_MONOSCOPIC: number;
  106412. /**
  106413. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106414. */
  106415. static readonly MODE_TOPBOTTOM: number;
  106416. /**
  106417. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106418. */
  106419. static readonly MODE_SIDEBYSIDE: number;
  106420. private _useDirectMapping;
  106421. /**
  106422. * The video texture being displayed on the sphere
  106423. */
  106424. protected _videoTexture: VideoTexture;
  106425. /**
  106426. * Gets the video texture being displayed on the sphere
  106427. */
  106428. readonly videoTexture: VideoTexture;
  106429. /**
  106430. * The skybox material
  106431. */
  106432. protected _material: BackgroundMaterial;
  106433. /**
  106434. * The surface used for the skybox
  106435. */
  106436. protected _mesh: Mesh;
  106437. /**
  106438. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106439. * Also see the options.resolution property.
  106440. */
  106441. fovMultiplier: number;
  106442. private _videoMode;
  106443. /**
  106444. * Gets or set the current video mode for the video. It can be:
  106445. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  106446. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106447. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106448. */
  106449. videoMode: number;
  106450. /**
  106451. * Oberserver used in Stereoscopic VR Mode.
  106452. */
  106453. private _onBeforeCameraRenderObserver;
  106454. /**
  106455. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  106456. * @param name Element's name, child elements will append suffixes for their own names.
  106457. * @param urlsOrVideo defines the url(s) or the video element to use
  106458. * @param options An object containing optional or exposed sub element properties
  106459. */
  106460. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  106461. resolution?: number;
  106462. clickToPlay?: boolean;
  106463. autoPlay?: boolean;
  106464. loop?: boolean;
  106465. size?: number;
  106466. poster?: string;
  106467. faceForward?: boolean;
  106468. useDirectMapping?: boolean;
  106469. }, scene: Scene);
  106470. private _changeVideoMode;
  106471. /**
  106472. * Releases resources associated with this node.
  106473. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106474. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106475. */
  106476. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106477. }
  106478. }
  106479. declare module BABYLON {
  106480. /**
  106481. * This class can be used to get instrumentation data from a Babylon engine
  106482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106483. */
  106484. export class EngineInstrumentation implements IDisposable {
  106485. /**
  106486. * Define the instrumented engine.
  106487. */
  106488. engine: Engine;
  106489. private _captureGPUFrameTime;
  106490. private _gpuFrameTimeToken;
  106491. private _gpuFrameTime;
  106492. private _captureShaderCompilationTime;
  106493. private _shaderCompilationTime;
  106494. private _onBeginFrameObserver;
  106495. private _onEndFrameObserver;
  106496. private _onBeforeShaderCompilationObserver;
  106497. private _onAfterShaderCompilationObserver;
  106498. /**
  106499. * Gets the perf counter used for GPU frame time
  106500. */
  106501. readonly gpuFrameTimeCounter: PerfCounter;
  106502. /**
  106503. * Gets the GPU frame time capture status
  106504. */
  106505. /**
  106506. * Enable or disable the GPU frame time capture
  106507. */
  106508. captureGPUFrameTime: boolean;
  106509. /**
  106510. * Gets the perf counter used for shader compilation time
  106511. */
  106512. readonly shaderCompilationTimeCounter: PerfCounter;
  106513. /**
  106514. * Gets the shader compilation time capture status
  106515. */
  106516. /**
  106517. * Enable or disable the shader compilation time capture
  106518. */
  106519. captureShaderCompilationTime: boolean;
  106520. /**
  106521. * Instantiates a new engine instrumentation.
  106522. * This class can be used to get instrumentation data from a Babylon engine
  106523. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106524. * @param engine Defines the engine to instrument
  106525. */
  106526. constructor(
  106527. /**
  106528. * Define the instrumented engine.
  106529. */
  106530. engine: Engine);
  106531. /**
  106532. * Dispose and release associated resources.
  106533. */
  106534. dispose(): void;
  106535. }
  106536. }
  106537. declare module BABYLON {
  106538. /**
  106539. * This class can be used to get instrumentation data from a Babylon engine
  106540. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106541. */
  106542. export class SceneInstrumentation implements IDisposable {
  106543. /**
  106544. * Defines the scene to instrument
  106545. */
  106546. scene: Scene;
  106547. private _captureActiveMeshesEvaluationTime;
  106548. private _activeMeshesEvaluationTime;
  106549. private _captureRenderTargetsRenderTime;
  106550. private _renderTargetsRenderTime;
  106551. private _captureFrameTime;
  106552. private _frameTime;
  106553. private _captureRenderTime;
  106554. private _renderTime;
  106555. private _captureInterFrameTime;
  106556. private _interFrameTime;
  106557. private _captureParticlesRenderTime;
  106558. private _particlesRenderTime;
  106559. private _captureSpritesRenderTime;
  106560. private _spritesRenderTime;
  106561. private _capturePhysicsTime;
  106562. private _physicsTime;
  106563. private _captureAnimationsTime;
  106564. private _animationsTime;
  106565. private _captureCameraRenderTime;
  106566. private _cameraRenderTime;
  106567. private _onBeforeActiveMeshesEvaluationObserver;
  106568. private _onAfterActiveMeshesEvaluationObserver;
  106569. private _onBeforeRenderTargetsRenderObserver;
  106570. private _onAfterRenderTargetsRenderObserver;
  106571. private _onAfterRenderObserver;
  106572. private _onBeforeDrawPhaseObserver;
  106573. private _onAfterDrawPhaseObserver;
  106574. private _onBeforeAnimationsObserver;
  106575. private _onBeforeParticlesRenderingObserver;
  106576. private _onAfterParticlesRenderingObserver;
  106577. private _onBeforeSpritesRenderingObserver;
  106578. private _onAfterSpritesRenderingObserver;
  106579. private _onBeforePhysicsObserver;
  106580. private _onAfterPhysicsObserver;
  106581. private _onAfterAnimationsObserver;
  106582. private _onBeforeCameraRenderObserver;
  106583. private _onAfterCameraRenderObserver;
  106584. /**
  106585. * Gets the perf counter used for active meshes evaluation time
  106586. */
  106587. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  106588. /**
  106589. * Gets the active meshes evaluation time capture status
  106590. */
  106591. /**
  106592. * Enable or disable the active meshes evaluation time capture
  106593. */
  106594. captureActiveMeshesEvaluationTime: boolean;
  106595. /**
  106596. * Gets the perf counter used for render targets render time
  106597. */
  106598. readonly renderTargetsRenderTimeCounter: PerfCounter;
  106599. /**
  106600. * Gets the render targets render time capture status
  106601. */
  106602. /**
  106603. * Enable or disable the render targets render time capture
  106604. */
  106605. captureRenderTargetsRenderTime: boolean;
  106606. /**
  106607. * Gets the perf counter used for particles render time
  106608. */
  106609. readonly particlesRenderTimeCounter: PerfCounter;
  106610. /**
  106611. * Gets the particles render time capture status
  106612. */
  106613. /**
  106614. * Enable or disable the particles render time capture
  106615. */
  106616. captureParticlesRenderTime: boolean;
  106617. /**
  106618. * Gets the perf counter used for sprites render time
  106619. */
  106620. readonly spritesRenderTimeCounter: PerfCounter;
  106621. /**
  106622. * Gets the sprites render time capture status
  106623. */
  106624. /**
  106625. * Enable or disable the sprites render time capture
  106626. */
  106627. captureSpritesRenderTime: boolean;
  106628. /**
  106629. * Gets the perf counter used for physics time
  106630. */
  106631. readonly physicsTimeCounter: PerfCounter;
  106632. /**
  106633. * Gets the physics time capture status
  106634. */
  106635. /**
  106636. * Enable or disable the physics time capture
  106637. */
  106638. capturePhysicsTime: boolean;
  106639. /**
  106640. * Gets the perf counter used for animations time
  106641. */
  106642. readonly animationsTimeCounter: PerfCounter;
  106643. /**
  106644. * Gets the animations time capture status
  106645. */
  106646. /**
  106647. * Enable or disable the animations time capture
  106648. */
  106649. captureAnimationsTime: boolean;
  106650. /**
  106651. * Gets the perf counter used for frame time capture
  106652. */
  106653. readonly frameTimeCounter: PerfCounter;
  106654. /**
  106655. * Gets the frame time capture status
  106656. */
  106657. /**
  106658. * Enable or disable the frame time capture
  106659. */
  106660. captureFrameTime: boolean;
  106661. /**
  106662. * Gets the perf counter used for inter-frames time capture
  106663. */
  106664. readonly interFrameTimeCounter: PerfCounter;
  106665. /**
  106666. * Gets the inter-frames time capture status
  106667. */
  106668. /**
  106669. * Enable or disable the inter-frames time capture
  106670. */
  106671. captureInterFrameTime: boolean;
  106672. /**
  106673. * Gets the perf counter used for render time capture
  106674. */
  106675. readonly renderTimeCounter: PerfCounter;
  106676. /**
  106677. * Gets the render time capture status
  106678. */
  106679. /**
  106680. * Enable or disable the render time capture
  106681. */
  106682. captureRenderTime: boolean;
  106683. /**
  106684. * Gets the perf counter used for camera render time capture
  106685. */
  106686. readonly cameraRenderTimeCounter: PerfCounter;
  106687. /**
  106688. * Gets the camera render time capture status
  106689. */
  106690. /**
  106691. * Enable or disable the camera render time capture
  106692. */
  106693. captureCameraRenderTime: boolean;
  106694. /**
  106695. * Gets the perf counter used for draw calls
  106696. */
  106697. readonly drawCallsCounter: PerfCounter;
  106698. /**
  106699. * Instantiates a new scene instrumentation.
  106700. * This class can be used to get instrumentation data from a Babylon engine
  106701. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106702. * @param scene Defines the scene to instrument
  106703. */
  106704. constructor(
  106705. /**
  106706. * Defines the scene to instrument
  106707. */
  106708. scene: Scene);
  106709. /**
  106710. * Dispose and release associated resources.
  106711. */
  106712. dispose(): void;
  106713. }
  106714. }
  106715. declare module BABYLON {
  106716. /** @hidden */
  106717. export var glowMapGenerationPixelShader: {
  106718. name: string;
  106719. shader: string;
  106720. };
  106721. }
  106722. declare module BABYLON {
  106723. /** @hidden */
  106724. export var glowMapGenerationVertexShader: {
  106725. name: string;
  106726. shader: string;
  106727. };
  106728. }
  106729. declare module BABYLON {
  106730. /**
  106731. * Effect layer options. This helps customizing the behaviour
  106732. * of the effect layer.
  106733. */
  106734. export interface IEffectLayerOptions {
  106735. /**
  106736. * Multiplication factor apply to the canvas size to compute the render target size
  106737. * used to generated the objects (the smaller the faster).
  106738. */
  106739. mainTextureRatio: number;
  106740. /**
  106741. * Enforces a fixed size texture to ensure effect stability across devices.
  106742. */
  106743. mainTextureFixedSize?: number;
  106744. /**
  106745. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  106746. */
  106747. alphaBlendingMode: number;
  106748. /**
  106749. * The camera attached to the layer.
  106750. */
  106751. camera: Nullable<Camera>;
  106752. /**
  106753. * The rendering group to draw the layer in.
  106754. */
  106755. renderingGroupId: number;
  106756. }
  106757. /**
  106758. * The effect layer Helps adding post process effect blended with the main pass.
  106759. *
  106760. * This can be for instance use to generate glow or higlight effects on the scene.
  106761. *
  106762. * The effect layer class can not be used directly and is intented to inherited from to be
  106763. * customized per effects.
  106764. */
  106765. export abstract class EffectLayer {
  106766. private _vertexBuffers;
  106767. private _indexBuffer;
  106768. private _cachedDefines;
  106769. private _effectLayerMapGenerationEffect;
  106770. private _effectLayerOptions;
  106771. private _mergeEffect;
  106772. protected _scene: Scene;
  106773. protected _engine: Engine;
  106774. protected _maxSize: number;
  106775. protected _mainTextureDesiredSize: ISize;
  106776. protected _mainTexture: RenderTargetTexture;
  106777. protected _shouldRender: boolean;
  106778. protected _postProcesses: PostProcess[];
  106779. protected _textures: BaseTexture[];
  106780. protected _emissiveTextureAndColor: {
  106781. texture: Nullable<BaseTexture>;
  106782. color: Color4;
  106783. };
  106784. /**
  106785. * The name of the layer
  106786. */
  106787. name: string;
  106788. /**
  106789. * The clear color of the texture used to generate the glow map.
  106790. */
  106791. neutralColor: Color4;
  106792. /**
  106793. * Specifies wether the highlight layer is enabled or not.
  106794. */
  106795. isEnabled: boolean;
  106796. /**
  106797. * Gets the camera attached to the layer.
  106798. */
  106799. readonly camera: Nullable<Camera>;
  106800. /**
  106801. * Gets the rendering group id the layer should render in.
  106802. */
  106803. readonly renderingGroupId: number;
  106804. /**
  106805. * An event triggered when the effect layer has been disposed.
  106806. */
  106807. onDisposeObservable: Observable<EffectLayer>;
  106808. /**
  106809. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  106810. */
  106811. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  106812. /**
  106813. * An event triggered when the generated texture is being merged in the scene.
  106814. */
  106815. onBeforeComposeObservable: Observable<EffectLayer>;
  106816. /**
  106817. * An event triggered when the generated texture has been merged in the scene.
  106818. */
  106819. onAfterComposeObservable: Observable<EffectLayer>;
  106820. /**
  106821. * An event triggered when the efffect layer changes its size.
  106822. */
  106823. onSizeChangedObservable: Observable<EffectLayer>;
  106824. /** @hidden */
  106825. static _SceneComponentInitialization: (scene: Scene) => void;
  106826. /**
  106827. * Instantiates a new effect Layer and references it in the scene.
  106828. * @param name The name of the layer
  106829. * @param scene The scene to use the layer in
  106830. */
  106831. constructor(
  106832. /** The Friendly of the effect in the scene */
  106833. name: string, scene: Scene);
  106834. /**
  106835. * Get the effect name of the layer.
  106836. * @return The effect name
  106837. */
  106838. abstract getEffectName(): string;
  106839. /**
  106840. * Checks for the readiness of the element composing the layer.
  106841. * @param subMesh the mesh to check for
  106842. * @param useInstances specify wether or not to use instances to render the mesh
  106843. * @return true if ready otherwise, false
  106844. */
  106845. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106846. /**
  106847. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106848. * @returns true if the effect requires stencil during the main canvas render pass.
  106849. */
  106850. abstract needStencil(): boolean;
  106851. /**
  106852. * Create the merge effect. This is the shader use to blit the information back
  106853. * to the main canvas at the end of the scene rendering.
  106854. * @returns The effect containing the shader used to merge the effect on the main canvas
  106855. */
  106856. protected abstract _createMergeEffect(): Effect;
  106857. /**
  106858. * Creates the render target textures and post processes used in the effect layer.
  106859. */
  106860. protected abstract _createTextureAndPostProcesses(): void;
  106861. /**
  106862. * Implementation specific of rendering the generating effect on the main canvas.
  106863. * @param effect The effect used to render through
  106864. */
  106865. protected abstract _internalRender(effect: Effect): void;
  106866. /**
  106867. * Sets the required values for both the emissive texture and and the main color.
  106868. */
  106869. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106870. /**
  106871. * Free any resources and references associated to a mesh.
  106872. * Internal use
  106873. * @param mesh The mesh to free.
  106874. */
  106875. abstract _disposeMesh(mesh: Mesh): void;
  106876. /**
  106877. * Serializes this layer (Glow or Highlight for example)
  106878. * @returns a serialized layer object
  106879. */
  106880. abstract serialize?(): any;
  106881. /**
  106882. * Initializes the effect layer with the required options.
  106883. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  106884. */
  106885. protected _init(options: Partial<IEffectLayerOptions>): void;
  106886. /**
  106887. * Generates the index buffer of the full screen quad blending to the main canvas.
  106888. */
  106889. private _generateIndexBuffer;
  106890. /**
  106891. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  106892. */
  106893. private _generateVertexBuffer;
  106894. /**
  106895. * Sets the main texture desired size which is the closest power of two
  106896. * of the engine canvas size.
  106897. */
  106898. private _setMainTextureSize;
  106899. /**
  106900. * Creates the main texture for the effect layer.
  106901. */
  106902. protected _createMainTexture(): void;
  106903. /**
  106904. * Adds specific effects defines.
  106905. * @param defines The defines to add specifics to.
  106906. */
  106907. protected _addCustomEffectDefines(defines: string[]): void;
  106908. /**
  106909. * Checks for the readiness of the element composing the layer.
  106910. * @param subMesh the mesh to check for
  106911. * @param useInstances specify wether or not to use instances to render the mesh
  106912. * @param emissiveTexture the associated emissive texture used to generate the glow
  106913. * @return true if ready otherwise, false
  106914. */
  106915. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  106916. /**
  106917. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  106918. */
  106919. render(): void;
  106920. /**
  106921. * Determine if a given mesh will be used in the current effect.
  106922. * @param mesh mesh to test
  106923. * @returns true if the mesh will be used
  106924. */
  106925. hasMesh(mesh: AbstractMesh): boolean;
  106926. /**
  106927. * Returns true if the layer contains information to display, otherwise false.
  106928. * @returns true if the glow layer should be rendered
  106929. */
  106930. shouldRender(): boolean;
  106931. /**
  106932. * Returns true if the mesh should render, otherwise false.
  106933. * @param mesh The mesh to render
  106934. * @returns true if it should render otherwise false
  106935. */
  106936. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  106937. /**
  106938. * Returns true if the mesh can be rendered, otherwise false.
  106939. * @param mesh The mesh to render
  106940. * @param material The material used on the mesh
  106941. * @returns true if it can be rendered otherwise false
  106942. */
  106943. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106944. /**
  106945. * Returns true if the mesh should render, otherwise false.
  106946. * @param mesh The mesh to render
  106947. * @returns true if it should render otherwise false
  106948. */
  106949. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106950. /**
  106951. * Renders the submesh passed in parameter to the generation map.
  106952. */
  106953. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  106954. /**
  106955. * Rebuild the required buffers.
  106956. * @hidden Internal use only.
  106957. */
  106958. _rebuild(): void;
  106959. /**
  106960. * Dispose only the render target textures and post process.
  106961. */
  106962. private _disposeTextureAndPostProcesses;
  106963. /**
  106964. * Dispose the highlight layer and free resources.
  106965. */
  106966. dispose(): void;
  106967. /**
  106968. * Gets the class name of the effect layer
  106969. * @returns the string with the class name of the effect layer
  106970. */
  106971. getClassName(): string;
  106972. /**
  106973. * Creates an effect layer from parsed effect layer data
  106974. * @param parsedEffectLayer defines effect layer data
  106975. * @param scene defines the current scene
  106976. * @param rootUrl defines the root URL containing the effect layer information
  106977. * @returns a parsed effect Layer
  106978. */
  106979. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106980. }
  106981. }
  106982. declare module BABYLON {
  106983. interface AbstractScene {
  106984. /**
  106985. * The list of effect layers (highlights/glow) added to the scene
  106986. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106987. * @see http://doc.babylonjs.com/how_to/glow_layer
  106988. */
  106989. effectLayers: Array<EffectLayer>;
  106990. /**
  106991. * Removes the given effect layer from this scene.
  106992. * @param toRemove defines the effect layer to remove
  106993. * @returns the index of the removed effect layer
  106994. */
  106995. removeEffectLayer(toRemove: EffectLayer): number;
  106996. /**
  106997. * Adds the given effect layer to this scene
  106998. * @param newEffectLayer defines the effect layer to add
  106999. */
  107000. addEffectLayer(newEffectLayer: EffectLayer): void;
  107001. }
  107002. /**
  107003. * Defines the layer scene component responsible to manage any effect layers
  107004. * in a given scene.
  107005. */
  107006. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  107007. /**
  107008. * The component name helpfull to identify the component in the list of scene components.
  107009. */
  107010. readonly name: string;
  107011. /**
  107012. * The scene the component belongs to.
  107013. */
  107014. scene: Scene;
  107015. private _engine;
  107016. private _renderEffects;
  107017. private _needStencil;
  107018. private _previousStencilState;
  107019. /**
  107020. * Creates a new instance of the component for the given scene
  107021. * @param scene Defines the scene to register the component in
  107022. */
  107023. constructor(scene: Scene);
  107024. /**
  107025. * Registers the component in a given scene
  107026. */
  107027. register(): void;
  107028. /**
  107029. * Rebuilds the elements related to this component in case of
  107030. * context lost for instance.
  107031. */
  107032. rebuild(): void;
  107033. /**
  107034. * Serializes the component data to the specified json object
  107035. * @param serializationObject The object to serialize to
  107036. */
  107037. serialize(serializationObject: any): void;
  107038. /**
  107039. * Adds all the element from the container to the scene
  107040. * @param container the container holding the elements
  107041. */
  107042. addFromContainer(container: AbstractScene): void;
  107043. /**
  107044. * Removes all the elements in the container from the scene
  107045. * @param container contains the elements to remove
  107046. * @param dispose if the removed element should be disposed (default: false)
  107047. */
  107048. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107049. /**
  107050. * Disposes the component and the associated ressources.
  107051. */
  107052. dispose(): void;
  107053. private _isReadyForMesh;
  107054. private _renderMainTexture;
  107055. private _setStencil;
  107056. private _setStencilBack;
  107057. private _draw;
  107058. private _drawCamera;
  107059. private _drawRenderingGroup;
  107060. }
  107061. }
  107062. declare module BABYLON {
  107063. /** @hidden */
  107064. export var glowMapMergePixelShader: {
  107065. name: string;
  107066. shader: string;
  107067. };
  107068. }
  107069. declare module BABYLON {
  107070. /** @hidden */
  107071. export var glowMapMergeVertexShader: {
  107072. name: string;
  107073. shader: string;
  107074. };
  107075. }
  107076. declare module BABYLON {
  107077. interface AbstractScene {
  107078. /**
  107079. * Return a the first highlight layer of the scene with a given name.
  107080. * @param name The name of the highlight layer to look for.
  107081. * @return The highlight layer if found otherwise null.
  107082. */
  107083. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  107084. }
  107085. /**
  107086. * Glow layer options. This helps customizing the behaviour
  107087. * of the glow layer.
  107088. */
  107089. export interface IGlowLayerOptions {
  107090. /**
  107091. * Multiplication factor apply to the canvas size to compute the render target size
  107092. * used to generated the glowing objects (the smaller the faster).
  107093. */
  107094. mainTextureRatio: number;
  107095. /**
  107096. * Enforces a fixed size texture to ensure resize independant blur.
  107097. */
  107098. mainTextureFixedSize?: number;
  107099. /**
  107100. * How big is the kernel of the blur texture.
  107101. */
  107102. blurKernelSize: number;
  107103. /**
  107104. * The camera attached to the layer.
  107105. */
  107106. camera: Nullable<Camera>;
  107107. /**
  107108. * Enable MSAA by chosing the number of samples.
  107109. */
  107110. mainTextureSamples?: number;
  107111. /**
  107112. * The rendering group to draw the layer in.
  107113. */
  107114. renderingGroupId: number;
  107115. }
  107116. /**
  107117. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  107118. *
  107119. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107120. * glowy meshes to your scene.
  107121. *
  107122. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  107123. */
  107124. export class GlowLayer extends EffectLayer {
  107125. /**
  107126. * Effect Name of the layer.
  107127. */
  107128. static readonly EffectName: string;
  107129. /**
  107130. * The default blur kernel size used for the glow.
  107131. */
  107132. static DefaultBlurKernelSize: number;
  107133. /**
  107134. * The default texture size ratio used for the glow.
  107135. */
  107136. static DefaultTextureRatio: number;
  107137. /**
  107138. * Sets the kernel size of the blur.
  107139. */
  107140. /**
  107141. * Gets the kernel size of the blur.
  107142. */
  107143. blurKernelSize: number;
  107144. /**
  107145. * Sets the glow intensity.
  107146. */
  107147. /**
  107148. * Gets the glow intensity.
  107149. */
  107150. intensity: number;
  107151. private _options;
  107152. private _intensity;
  107153. private _horizontalBlurPostprocess1;
  107154. private _verticalBlurPostprocess1;
  107155. private _horizontalBlurPostprocess2;
  107156. private _verticalBlurPostprocess2;
  107157. private _blurTexture1;
  107158. private _blurTexture2;
  107159. private _postProcesses1;
  107160. private _postProcesses2;
  107161. private _includedOnlyMeshes;
  107162. private _excludedMeshes;
  107163. /**
  107164. * Callback used to let the user override the color selection on a per mesh basis
  107165. */
  107166. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  107167. /**
  107168. * Callback used to let the user override the texture selection on a per mesh basis
  107169. */
  107170. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  107171. /**
  107172. * Instantiates a new glow Layer and references it to the scene.
  107173. * @param name The name of the layer
  107174. * @param scene The scene to use the layer in
  107175. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  107176. */
  107177. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  107178. /**
  107179. * Get the effect name of the layer.
  107180. * @return The effect name
  107181. */
  107182. getEffectName(): string;
  107183. /**
  107184. * Create the merge effect. This is the shader use to blit the information back
  107185. * to the main canvas at the end of the scene rendering.
  107186. */
  107187. protected _createMergeEffect(): Effect;
  107188. /**
  107189. * Creates the render target textures and post processes used in the glow layer.
  107190. */
  107191. protected _createTextureAndPostProcesses(): void;
  107192. /**
  107193. * Checks for the readiness of the element composing the layer.
  107194. * @param subMesh the mesh to check for
  107195. * @param useInstances specify wether or not to use instances to render the mesh
  107196. * @param emissiveTexture the associated emissive texture used to generate the glow
  107197. * @return true if ready otherwise, false
  107198. */
  107199. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107200. /**
  107201. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107202. */
  107203. needStencil(): boolean;
  107204. /**
  107205. * Returns true if the mesh can be rendered, otherwise false.
  107206. * @param mesh The mesh to render
  107207. * @param material The material used on the mesh
  107208. * @returns true if it can be rendered otherwise false
  107209. */
  107210. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  107211. /**
  107212. * Implementation specific of rendering the generating effect on the main canvas.
  107213. * @param effect The effect used to render through
  107214. */
  107215. protected _internalRender(effect: Effect): void;
  107216. /**
  107217. * Sets the required values for both the emissive texture and and the main color.
  107218. */
  107219. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107220. /**
  107221. * Returns true if the mesh should render, otherwise false.
  107222. * @param mesh The mesh to render
  107223. * @returns true if it should render otherwise false
  107224. */
  107225. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107226. /**
  107227. * Adds specific effects defines.
  107228. * @param defines The defines to add specifics to.
  107229. */
  107230. protected _addCustomEffectDefines(defines: string[]): void;
  107231. /**
  107232. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  107233. * @param mesh The mesh to exclude from the glow layer
  107234. */
  107235. addExcludedMesh(mesh: Mesh): void;
  107236. /**
  107237. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  107238. * @param mesh The mesh to remove
  107239. */
  107240. removeExcludedMesh(mesh: Mesh): void;
  107241. /**
  107242. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  107243. * @param mesh The mesh to include in the glow layer
  107244. */
  107245. addIncludedOnlyMesh(mesh: Mesh): void;
  107246. /**
  107247. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  107248. * @param mesh The mesh to remove
  107249. */
  107250. removeIncludedOnlyMesh(mesh: Mesh): void;
  107251. /**
  107252. * Determine if a given mesh will be used in the glow layer
  107253. * @param mesh The mesh to test
  107254. * @returns true if the mesh will be highlighted by the current glow layer
  107255. */
  107256. hasMesh(mesh: AbstractMesh): boolean;
  107257. /**
  107258. * Free any resources and references associated to a mesh.
  107259. * Internal use
  107260. * @param mesh The mesh to free.
  107261. * @hidden
  107262. */
  107263. _disposeMesh(mesh: Mesh): void;
  107264. /**
  107265. * Gets the class name of the effect layer
  107266. * @returns the string with the class name of the effect layer
  107267. */
  107268. getClassName(): string;
  107269. /**
  107270. * Serializes this glow layer
  107271. * @returns a serialized glow layer object
  107272. */
  107273. serialize(): any;
  107274. /**
  107275. * Creates a Glow Layer from parsed glow layer data
  107276. * @param parsedGlowLayer defines glow layer data
  107277. * @param scene defines the current scene
  107278. * @param rootUrl defines the root URL containing the glow layer information
  107279. * @returns a parsed Glow Layer
  107280. */
  107281. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  107282. }
  107283. }
  107284. declare module BABYLON {
  107285. /** @hidden */
  107286. export var glowBlurPostProcessPixelShader: {
  107287. name: string;
  107288. shader: string;
  107289. };
  107290. }
  107291. declare module BABYLON {
  107292. interface AbstractScene {
  107293. /**
  107294. * Return a the first highlight layer of the scene with a given name.
  107295. * @param name The name of the highlight layer to look for.
  107296. * @return The highlight layer if found otherwise null.
  107297. */
  107298. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  107299. }
  107300. /**
  107301. * Highlight layer options. This helps customizing the behaviour
  107302. * of the highlight layer.
  107303. */
  107304. export interface IHighlightLayerOptions {
  107305. /**
  107306. * Multiplication factor apply to the canvas size to compute the render target size
  107307. * used to generated the glowing objects (the smaller the faster).
  107308. */
  107309. mainTextureRatio: number;
  107310. /**
  107311. * Enforces a fixed size texture to ensure resize independant blur.
  107312. */
  107313. mainTextureFixedSize?: number;
  107314. /**
  107315. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  107316. * of the picture to blur (the smaller the faster).
  107317. */
  107318. blurTextureSizeRatio: number;
  107319. /**
  107320. * How big in texel of the blur texture is the vertical blur.
  107321. */
  107322. blurVerticalSize: number;
  107323. /**
  107324. * How big in texel of the blur texture is the horizontal blur.
  107325. */
  107326. blurHorizontalSize: number;
  107327. /**
  107328. * Alpha blending mode used to apply the blur. Default is combine.
  107329. */
  107330. alphaBlendingMode: number;
  107331. /**
  107332. * The camera attached to the layer.
  107333. */
  107334. camera: Nullable<Camera>;
  107335. /**
  107336. * Should we display highlight as a solid stroke?
  107337. */
  107338. isStroke?: boolean;
  107339. /**
  107340. * The rendering group to draw the layer in.
  107341. */
  107342. renderingGroupId: number;
  107343. }
  107344. /**
  107345. * The highlight layer Helps adding a glow effect around a mesh.
  107346. *
  107347. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107348. * glowy meshes to your scene.
  107349. *
  107350. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  107351. */
  107352. export class HighlightLayer extends EffectLayer {
  107353. name: string;
  107354. /**
  107355. * Effect Name of the highlight layer.
  107356. */
  107357. static readonly EffectName: string;
  107358. /**
  107359. * The neutral color used during the preparation of the glow effect.
  107360. * This is black by default as the blend operation is a blend operation.
  107361. */
  107362. static NeutralColor: Color4;
  107363. /**
  107364. * Stencil value used for glowing meshes.
  107365. */
  107366. static GlowingMeshStencilReference: number;
  107367. /**
  107368. * Stencil value used for the other meshes in the scene.
  107369. */
  107370. static NormalMeshStencilReference: number;
  107371. /**
  107372. * Specifies whether or not the inner glow is ACTIVE in the layer.
  107373. */
  107374. innerGlow: boolean;
  107375. /**
  107376. * Specifies whether or not the outer glow is ACTIVE in the layer.
  107377. */
  107378. outerGlow: boolean;
  107379. /**
  107380. * Specifies the horizontal size of the blur.
  107381. */
  107382. /**
  107383. * Gets the horizontal size of the blur.
  107384. */
  107385. blurHorizontalSize: number;
  107386. /**
  107387. * Specifies the vertical size of the blur.
  107388. */
  107389. /**
  107390. * Gets the vertical size of the blur.
  107391. */
  107392. blurVerticalSize: number;
  107393. /**
  107394. * An event triggered when the highlight layer is being blurred.
  107395. */
  107396. onBeforeBlurObservable: Observable<HighlightLayer>;
  107397. /**
  107398. * An event triggered when the highlight layer has been blurred.
  107399. */
  107400. onAfterBlurObservable: Observable<HighlightLayer>;
  107401. private _instanceGlowingMeshStencilReference;
  107402. private _options;
  107403. private _downSamplePostprocess;
  107404. private _horizontalBlurPostprocess;
  107405. private _verticalBlurPostprocess;
  107406. private _blurTexture;
  107407. private _meshes;
  107408. private _excludedMeshes;
  107409. /**
  107410. * Instantiates a new highlight Layer and references it to the scene..
  107411. * @param name The name of the layer
  107412. * @param scene The scene to use the layer in
  107413. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  107414. */
  107415. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  107416. /**
  107417. * Get the effect name of the layer.
  107418. * @return The effect name
  107419. */
  107420. getEffectName(): string;
  107421. /**
  107422. * Create the merge effect. This is the shader use to blit the information back
  107423. * to the main canvas at the end of the scene rendering.
  107424. */
  107425. protected _createMergeEffect(): Effect;
  107426. /**
  107427. * Creates the render target textures and post processes used in the highlight layer.
  107428. */
  107429. protected _createTextureAndPostProcesses(): void;
  107430. /**
  107431. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107432. */
  107433. needStencil(): boolean;
  107434. /**
  107435. * Checks for the readiness of the element composing the layer.
  107436. * @param subMesh the mesh to check for
  107437. * @param useInstances specify wether or not to use instances to render the mesh
  107438. * @param emissiveTexture the associated emissive texture used to generate the glow
  107439. * @return true if ready otherwise, false
  107440. */
  107441. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107442. /**
  107443. * Implementation specific of rendering the generating effect on the main canvas.
  107444. * @param effect The effect used to render through
  107445. */
  107446. protected _internalRender(effect: Effect): void;
  107447. /**
  107448. * Returns true if the layer contains information to display, otherwise false.
  107449. */
  107450. shouldRender(): boolean;
  107451. /**
  107452. * Returns true if the mesh should render, otherwise false.
  107453. * @param mesh The mesh to render
  107454. * @returns true if it should render otherwise false
  107455. */
  107456. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107457. /**
  107458. * Sets the required values for both the emissive texture and and the main color.
  107459. */
  107460. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107461. /**
  107462. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  107463. * @param mesh The mesh to exclude from the highlight layer
  107464. */
  107465. addExcludedMesh(mesh: Mesh): void;
  107466. /**
  107467. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  107468. * @param mesh The mesh to highlight
  107469. */
  107470. removeExcludedMesh(mesh: Mesh): void;
  107471. /**
  107472. * Determine if a given mesh will be highlighted by the current HighlightLayer
  107473. * @param mesh mesh to test
  107474. * @returns true if the mesh will be highlighted by the current HighlightLayer
  107475. */
  107476. hasMesh(mesh: AbstractMesh): boolean;
  107477. /**
  107478. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  107479. * @param mesh The mesh to highlight
  107480. * @param color The color of the highlight
  107481. * @param glowEmissiveOnly Extract the glow from the emissive texture
  107482. */
  107483. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  107484. /**
  107485. * Remove a mesh from the highlight layer in order to make it stop glowing.
  107486. * @param mesh The mesh to highlight
  107487. */
  107488. removeMesh(mesh: Mesh): void;
  107489. /**
  107490. * Force the stencil to the normal expected value for none glowing parts
  107491. */
  107492. private _defaultStencilReference;
  107493. /**
  107494. * Free any resources and references associated to a mesh.
  107495. * Internal use
  107496. * @param mesh The mesh to free.
  107497. * @hidden
  107498. */
  107499. _disposeMesh(mesh: Mesh): void;
  107500. /**
  107501. * Dispose the highlight layer and free resources.
  107502. */
  107503. dispose(): void;
  107504. /**
  107505. * Gets the class name of the effect layer
  107506. * @returns the string with the class name of the effect layer
  107507. */
  107508. getClassName(): string;
  107509. /**
  107510. * Serializes this Highlight layer
  107511. * @returns a serialized Highlight layer object
  107512. */
  107513. serialize(): any;
  107514. /**
  107515. * Creates a Highlight layer from parsed Highlight layer data
  107516. * @param parsedHightlightLayer defines the Highlight layer data
  107517. * @param scene defines the current scene
  107518. * @param rootUrl defines the root URL containing the Highlight layer information
  107519. * @returns a parsed Highlight layer
  107520. */
  107521. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  107522. }
  107523. }
  107524. declare module BABYLON {
  107525. /** @hidden */
  107526. export var lensFlarePixelShader: {
  107527. name: string;
  107528. shader: string;
  107529. };
  107530. }
  107531. declare module BABYLON {
  107532. /** @hidden */
  107533. export var lensFlareVertexShader: {
  107534. name: string;
  107535. shader: string;
  107536. };
  107537. }
  107538. declare module BABYLON {
  107539. /**
  107540. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107541. * It is usually composed of several `lensFlare`.
  107542. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107543. */
  107544. export class LensFlareSystem {
  107545. /**
  107546. * Define the name of the lens flare system
  107547. */
  107548. name: string;
  107549. /**
  107550. * List of lens flares used in this system.
  107551. */
  107552. lensFlares: LensFlare[];
  107553. /**
  107554. * Define a limit from the border the lens flare can be visible.
  107555. */
  107556. borderLimit: number;
  107557. /**
  107558. * Define a viewport border we do not want to see the lens flare in.
  107559. */
  107560. viewportBorder: number;
  107561. /**
  107562. * Define a predicate which could limit the list of meshes able to occlude the effect.
  107563. */
  107564. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107565. /**
  107566. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  107567. */
  107568. layerMask: number;
  107569. /**
  107570. * Define the id of the lens flare system in the scene.
  107571. * (equal to name by default)
  107572. */
  107573. id: string;
  107574. private _scene;
  107575. private _emitter;
  107576. private _vertexBuffers;
  107577. private _indexBuffer;
  107578. private _effect;
  107579. private _positionX;
  107580. private _positionY;
  107581. private _isEnabled;
  107582. /** @hidden */
  107583. static _SceneComponentInitialization: (scene: Scene) => void;
  107584. /**
  107585. * Instantiates a lens flare system.
  107586. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107587. * It is usually composed of several `lensFlare`.
  107588. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107589. * @param name Define the name of the lens flare system in the scene
  107590. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  107591. * @param scene Define the scene the lens flare system belongs to
  107592. */
  107593. constructor(
  107594. /**
  107595. * Define the name of the lens flare system
  107596. */
  107597. name: string, emitter: any, scene: Scene);
  107598. /**
  107599. * Define if the lens flare system is enabled.
  107600. */
  107601. isEnabled: boolean;
  107602. /**
  107603. * Get the scene the effects belongs to.
  107604. * @returns the scene holding the lens flare system
  107605. */
  107606. getScene(): Scene;
  107607. /**
  107608. * Get the emitter of the lens flare system.
  107609. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107610. * @returns the emitter of the lens flare system
  107611. */
  107612. getEmitter(): any;
  107613. /**
  107614. * Set the emitter of the lens flare system.
  107615. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107616. * @param newEmitter Define the new emitter of the system
  107617. */
  107618. setEmitter(newEmitter: any): void;
  107619. /**
  107620. * Get the lens flare system emitter position.
  107621. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  107622. * @returns the position
  107623. */
  107624. getEmitterPosition(): Vector3;
  107625. /**
  107626. * @hidden
  107627. */
  107628. computeEffectivePosition(globalViewport: Viewport): boolean;
  107629. /** @hidden */
  107630. _isVisible(): boolean;
  107631. /**
  107632. * @hidden
  107633. */
  107634. render(): boolean;
  107635. /**
  107636. * Dispose and release the lens flare with its associated resources.
  107637. */
  107638. dispose(): void;
  107639. /**
  107640. * Parse a lens flare system from a JSON repressentation
  107641. * @param parsedLensFlareSystem Define the JSON to parse
  107642. * @param scene Define the scene the parsed system should be instantiated in
  107643. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  107644. * @returns the parsed system
  107645. */
  107646. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  107647. /**
  107648. * Serialize the current Lens Flare System into a JSON representation.
  107649. * @returns the serialized JSON
  107650. */
  107651. serialize(): any;
  107652. }
  107653. }
  107654. declare module BABYLON {
  107655. /**
  107656. * This represents one of the lens effect in a `lensFlareSystem`.
  107657. * It controls one of the indiviual texture used in the effect.
  107658. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107659. */
  107660. export class LensFlare {
  107661. /**
  107662. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107663. */
  107664. size: number;
  107665. /**
  107666. * 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.
  107667. */
  107668. position: number;
  107669. /**
  107670. * Define the lens color.
  107671. */
  107672. color: Color3;
  107673. /**
  107674. * Define the lens texture.
  107675. */
  107676. texture: Nullable<Texture>;
  107677. /**
  107678. * Define the alpha mode to render this particular lens.
  107679. */
  107680. alphaMode: number;
  107681. private _system;
  107682. /**
  107683. * Creates a new Lens Flare.
  107684. * This represents one of the lens effect in a `lensFlareSystem`.
  107685. * It controls one of the indiviual texture used in the effect.
  107686. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107687. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  107688. * @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.
  107689. * @param color Define the lens color
  107690. * @param imgUrl Define the lens texture url
  107691. * @param system Define the `lensFlareSystem` this flare is part of
  107692. * @returns The newly created Lens Flare
  107693. */
  107694. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  107695. /**
  107696. * Instantiates a new Lens Flare.
  107697. * This represents one of the lens effect in a `lensFlareSystem`.
  107698. * It controls one of the indiviual texture used in the effect.
  107699. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107700. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  107701. * @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.
  107702. * @param color Define the lens color
  107703. * @param imgUrl Define the lens texture url
  107704. * @param system Define the `lensFlareSystem` this flare is part of
  107705. */
  107706. constructor(
  107707. /**
  107708. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107709. */
  107710. size: number,
  107711. /**
  107712. * 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.
  107713. */
  107714. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  107715. /**
  107716. * Dispose and release the lens flare with its associated resources.
  107717. */
  107718. dispose(): void;
  107719. }
  107720. }
  107721. declare module BABYLON {
  107722. interface AbstractScene {
  107723. /**
  107724. * The list of lens flare system added to the scene
  107725. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107726. */
  107727. lensFlareSystems: Array<LensFlareSystem>;
  107728. /**
  107729. * Removes the given lens flare system from this scene.
  107730. * @param toRemove The lens flare system to remove
  107731. * @returns The index of the removed lens flare system
  107732. */
  107733. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  107734. /**
  107735. * Adds the given lens flare system to this scene
  107736. * @param newLensFlareSystem The lens flare system to add
  107737. */
  107738. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  107739. /**
  107740. * Gets a lens flare system using its name
  107741. * @param name defines the name to look for
  107742. * @returns the lens flare system or null if not found
  107743. */
  107744. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  107745. /**
  107746. * Gets a lens flare system using its id
  107747. * @param id defines the id to look for
  107748. * @returns the lens flare system or null if not found
  107749. */
  107750. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  107751. }
  107752. /**
  107753. * Defines the lens flare scene component responsible to manage any lens flares
  107754. * in a given scene.
  107755. */
  107756. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  107757. /**
  107758. * The component name helpfull to identify the component in the list of scene components.
  107759. */
  107760. readonly name: string;
  107761. /**
  107762. * The scene the component belongs to.
  107763. */
  107764. scene: Scene;
  107765. /**
  107766. * Creates a new instance of the component for the given scene
  107767. * @param scene Defines the scene to register the component in
  107768. */
  107769. constructor(scene: Scene);
  107770. /**
  107771. * Registers the component in a given scene
  107772. */
  107773. register(): void;
  107774. /**
  107775. * Rebuilds the elements related to this component in case of
  107776. * context lost for instance.
  107777. */
  107778. rebuild(): void;
  107779. /**
  107780. * Adds all the element from the container to the scene
  107781. * @param container the container holding the elements
  107782. */
  107783. addFromContainer(container: AbstractScene): void;
  107784. /**
  107785. * Removes all the elements in the container from the scene
  107786. * @param container contains the elements to remove
  107787. * @param dispose if the removed element should be disposed (default: false)
  107788. */
  107789. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107790. /**
  107791. * Serializes the component data to the specified json object
  107792. * @param serializationObject The object to serialize to
  107793. */
  107794. serialize(serializationObject: any): void;
  107795. /**
  107796. * Disposes the component and the associated ressources.
  107797. */
  107798. dispose(): void;
  107799. private _draw;
  107800. }
  107801. }
  107802. declare module BABYLON {
  107803. /**
  107804. * Defines the shadow generator component responsible to manage any shadow generators
  107805. * in a given scene.
  107806. */
  107807. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  107808. /**
  107809. * The component name helpfull to identify the component in the list of scene components.
  107810. */
  107811. readonly name: string;
  107812. /**
  107813. * The scene the component belongs to.
  107814. */
  107815. scene: Scene;
  107816. /**
  107817. * Creates a new instance of the component for the given scene
  107818. * @param scene Defines the scene to register the component in
  107819. */
  107820. constructor(scene: Scene);
  107821. /**
  107822. * Registers the component in a given scene
  107823. */
  107824. register(): void;
  107825. /**
  107826. * Rebuilds the elements related to this component in case of
  107827. * context lost for instance.
  107828. */
  107829. rebuild(): void;
  107830. /**
  107831. * Serializes the component data to the specified json object
  107832. * @param serializationObject The object to serialize to
  107833. */
  107834. serialize(serializationObject: any): void;
  107835. /**
  107836. * Adds all the element from the container to the scene
  107837. * @param container the container holding the elements
  107838. */
  107839. addFromContainer(container: AbstractScene): void;
  107840. /**
  107841. * Removes all the elements in the container from the scene
  107842. * @param container contains the elements to remove
  107843. * @param dispose if the removed element should be disposed (default: false)
  107844. */
  107845. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107846. /**
  107847. * Rebuilds the elements related to this component in case of
  107848. * context lost for instance.
  107849. */
  107850. dispose(): void;
  107851. private _gatherRenderTargets;
  107852. }
  107853. }
  107854. declare module BABYLON {
  107855. /**
  107856. * A point light is a light defined by an unique point in world space.
  107857. * The light is emitted in every direction from this point.
  107858. * A good example of a point light is a standard light bulb.
  107859. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107860. */
  107861. export class PointLight extends ShadowLight {
  107862. private _shadowAngle;
  107863. /**
  107864. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107865. * This specifies what angle the shadow will use to be created.
  107866. *
  107867. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107868. */
  107869. /**
  107870. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107871. * This specifies what angle the shadow will use to be created.
  107872. *
  107873. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107874. */
  107875. shadowAngle: number;
  107876. /**
  107877. * Gets the direction if it has been set.
  107878. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107879. */
  107880. /**
  107881. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107882. */
  107883. direction: Vector3;
  107884. /**
  107885. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  107886. * A PointLight emits the light in every direction.
  107887. * It can cast shadows.
  107888. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  107889. * ```javascript
  107890. * var pointLight = new PointLight("pl", camera.position, scene);
  107891. * ```
  107892. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107893. * @param name The light friendly name
  107894. * @param position The position of the point light in the scene
  107895. * @param scene The scene the lights belongs to
  107896. */
  107897. constructor(name: string, position: Vector3, scene: Scene);
  107898. /**
  107899. * Returns the string "PointLight"
  107900. * @returns the class name
  107901. */
  107902. getClassName(): string;
  107903. /**
  107904. * Returns the integer 0.
  107905. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107906. */
  107907. getTypeID(): number;
  107908. /**
  107909. * Specifies wether or not the shadowmap should be a cube texture.
  107910. * @returns true if the shadowmap needs to be a cube texture.
  107911. */
  107912. needCube(): boolean;
  107913. /**
  107914. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  107915. * @param faceIndex The index of the face we are computed the direction to generate shadow
  107916. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  107917. */
  107918. getShadowDirection(faceIndex?: number): Vector3;
  107919. /**
  107920. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  107921. * - fov = PI / 2
  107922. * - aspect ratio : 1.0
  107923. * - z-near and far equal to the active camera minZ and maxZ.
  107924. * Returns the PointLight.
  107925. */
  107926. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107927. protected _buildUniformLayout(): void;
  107928. /**
  107929. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  107930. * @param effect The effect to update
  107931. * @param lightIndex The index of the light in the effect to update
  107932. * @returns The point light
  107933. */
  107934. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  107935. /**
  107936. * Prepares the list of defines specific to the light type.
  107937. * @param defines the list of defines
  107938. * @param lightIndex defines the index of the light for the effect
  107939. */
  107940. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107941. }
  107942. }
  107943. declare module BABYLON {
  107944. /**
  107945. * Header information of HDR texture files.
  107946. */
  107947. export interface HDRInfo {
  107948. /**
  107949. * The height of the texture in pixels.
  107950. */
  107951. height: number;
  107952. /**
  107953. * The width of the texture in pixels.
  107954. */
  107955. width: number;
  107956. /**
  107957. * The index of the beginning of the data in the binary file.
  107958. */
  107959. dataPosition: number;
  107960. }
  107961. /**
  107962. * This groups tools to convert HDR texture to native colors array.
  107963. */
  107964. export class HDRTools {
  107965. private static Ldexp;
  107966. private static Rgbe2float;
  107967. private static readStringLine;
  107968. /**
  107969. * Reads header information from an RGBE texture stored in a native array.
  107970. * More information on this format are available here:
  107971. * https://en.wikipedia.org/wiki/RGBE_image_format
  107972. *
  107973. * @param uint8array The binary file stored in native array.
  107974. * @return The header information.
  107975. */
  107976. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107977. /**
  107978. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107979. * This RGBE texture needs to store the information as a panorama.
  107980. *
  107981. * More information on this format are available here:
  107982. * https://en.wikipedia.org/wiki/RGBE_image_format
  107983. *
  107984. * @param buffer The binary file stored in an array buffer.
  107985. * @param size The expected size of the extracted cubemap.
  107986. * @return The Cube Map information.
  107987. */
  107988. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107989. /**
  107990. * Returns the pixels data extracted from an RGBE texture.
  107991. * This pixels will be stored left to right up to down in the R G B order in one array.
  107992. *
  107993. * More information on this format are available here:
  107994. * https://en.wikipedia.org/wiki/RGBE_image_format
  107995. *
  107996. * @param uint8array The binary file stored in an array buffer.
  107997. * @param hdrInfo The header information of the file.
  107998. * @return The pixels data in RGB right to left up to down order.
  107999. */
  108000. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  108001. private static RGBE_ReadPixels_RLE;
  108002. }
  108003. }
  108004. declare module BABYLON {
  108005. /**
  108006. * This represents a texture coming from an HDR input.
  108007. *
  108008. * The only supported format is currently panorama picture stored in RGBE format.
  108009. * Example of such files can be found on HDRLib: http://hdrlib.com/
  108010. */
  108011. export class HDRCubeTexture extends BaseTexture {
  108012. private static _facesMapping;
  108013. private _generateHarmonics;
  108014. private _noMipmap;
  108015. private _textureMatrix;
  108016. private _size;
  108017. private _onLoad;
  108018. private _onError;
  108019. /**
  108020. * The texture URL.
  108021. */
  108022. url: string;
  108023. /**
  108024. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  108025. */
  108026. coordinatesMode: number;
  108027. protected _isBlocking: boolean;
  108028. /**
  108029. * Sets wether or not the texture is blocking during loading.
  108030. */
  108031. /**
  108032. * Gets wether or not the texture is blocking during loading.
  108033. */
  108034. isBlocking: boolean;
  108035. protected _rotationY: number;
  108036. /**
  108037. * Sets texture matrix rotation angle around Y axis in radians.
  108038. */
  108039. /**
  108040. * Gets texture matrix rotation angle around Y axis radians.
  108041. */
  108042. rotationY: number;
  108043. /**
  108044. * Gets or sets the center of the bounding box associated with the cube texture
  108045. * It must define where the camera used to render the texture was set
  108046. */
  108047. boundingBoxPosition: Vector3;
  108048. private _boundingBoxSize;
  108049. /**
  108050. * Gets or sets the size of the bounding box associated with the cube texture
  108051. * When defined, the cubemap will switch to local mode
  108052. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  108053. * @example https://www.babylonjs-playground.com/#RNASML
  108054. */
  108055. boundingBoxSize: Vector3;
  108056. /**
  108057. * Instantiates an HDRTexture from the following parameters.
  108058. *
  108059. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  108060. * @param scene The scene the texture will be used in
  108061. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108062. * @param noMipmap Forces to not generate the mipmap if true
  108063. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  108064. * @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)
  108065. * @param reserved Reserved flag for internal use.
  108066. */
  108067. 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>);
  108068. /**
  108069. * Get the current class name of the texture useful for serialization or dynamic coding.
  108070. * @returns "HDRCubeTexture"
  108071. */
  108072. getClassName(): string;
  108073. /**
  108074. * Occurs when the file is raw .hdr file.
  108075. */
  108076. private loadTexture;
  108077. clone(): HDRCubeTexture;
  108078. delayLoad(): void;
  108079. /**
  108080. * Get the texture reflection matrix used to rotate/transform the reflection.
  108081. * @returns the reflection matrix
  108082. */
  108083. getReflectionTextureMatrix(): Matrix;
  108084. /**
  108085. * Set the texture reflection matrix used to rotate/transform the reflection.
  108086. * @param value Define the reflection matrix to set
  108087. */
  108088. setReflectionTextureMatrix(value: Matrix): void;
  108089. /**
  108090. * Parses a JSON representation of an HDR Texture in order to create the texture
  108091. * @param parsedTexture Define the JSON representation
  108092. * @param scene Define the scene the texture should be created in
  108093. * @param rootUrl Define the root url in case we need to load relative dependencies
  108094. * @returns the newly created texture after parsing
  108095. */
  108096. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  108097. serialize(): any;
  108098. }
  108099. }
  108100. declare module BABYLON {
  108101. /**
  108102. * Class used to control physics engine
  108103. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108104. */
  108105. export class PhysicsEngine implements IPhysicsEngine {
  108106. private _physicsPlugin;
  108107. /**
  108108. * Global value used to control the smallest number supported by the simulation
  108109. */
  108110. static Epsilon: number;
  108111. private _impostors;
  108112. private _joints;
  108113. /**
  108114. * Gets the gravity vector used by the simulation
  108115. */
  108116. gravity: Vector3;
  108117. /**
  108118. * Factory used to create the default physics plugin.
  108119. * @returns The default physics plugin
  108120. */
  108121. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  108122. /**
  108123. * Creates a new Physics Engine
  108124. * @param gravity defines the gravity vector used by the simulation
  108125. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  108126. */
  108127. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  108128. /**
  108129. * Sets the gravity vector used by the simulation
  108130. * @param gravity defines the gravity vector to use
  108131. */
  108132. setGravity(gravity: Vector3): void;
  108133. /**
  108134. * Set the time step of the physics engine.
  108135. * Default is 1/60.
  108136. * To slow it down, enter 1/600 for example.
  108137. * To speed it up, 1/30
  108138. * @param newTimeStep defines the new timestep to apply to this world.
  108139. */
  108140. setTimeStep(newTimeStep?: number): void;
  108141. /**
  108142. * Get the time step of the physics engine.
  108143. * @returns the current time step
  108144. */
  108145. getTimeStep(): number;
  108146. /**
  108147. * Release all resources
  108148. */
  108149. dispose(): void;
  108150. /**
  108151. * Gets the name of the current physics plugin
  108152. * @returns the name of the plugin
  108153. */
  108154. getPhysicsPluginName(): string;
  108155. /**
  108156. * Adding a new impostor for the impostor tracking.
  108157. * This will be done by the impostor itself.
  108158. * @param impostor the impostor to add
  108159. */
  108160. addImpostor(impostor: PhysicsImpostor): void;
  108161. /**
  108162. * Remove an impostor from the engine.
  108163. * This impostor and its mesh will not longer be updated by the physics engine.
  108164. * @param impostor the impostor to remove
  108165. */
  108166. removeImpostor(impostor: PhysicsImpostor): void;
  108167. /**
  108168. * Add a joint to the physics engine
  108169. * @param mainImpostor defines the main impostor to which the joint is added.
  108170. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  108171. * @param joint defines the joint that will connect both impostors.
  108172. */
  108173. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108174. /**
  108175. * Removes a joint from the simulation
  108176. * @param mainImpostor defines the impostor used with the joint
  108177. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  108178. * @param joint defines the joint to remove
  108179. */
  108180. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108181. /**
  108182. * Called by the scene. No need to call it.
  108183. * @param delta defines the timespam between frames
  108184. */
  108185. _step(delta: number): void;
  108186. /**
  108187. * Gets the current plugin used to run the simulation
  108188. * @returns current plugin
  108189. */
  108190. getPhysicsPlugin(): IPhysicsEnginePlugin;
  108191. /**
  108192. * Gets the list of physic impostors
  108193. * @returns an array of PhysicsImpostor
  108194. */
  108195. getImpostors(): Array<PhysicsImpostor>;
  108196. /**
  108197. * Gets the impostor for a physics enabled object
  108198. * @param object defines the object impersonated by the impostor
  108199. * @returns the PhysicsImpostor or null if not found
  108200. */
  108201. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108202. /**
  108203. * Gets the impostor for a physics body object
  108204. * @param body defines physics body used by the impostor
  108205. * @returns the PhysicsImpostor or null if not found
  108206. */
  108207. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  108208. /**
  108209. * Does a raycast in the physics world
  108210. * @param from when should the ray start?
  108211. * @param to when should the ray end?
  108212. * @returns PhysicsRaycastResult
  108213. */
  108214. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108215. }
  108216. }
  108217. declare module BABYLON {
  108218. /** @hidden */
  108219. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  108220. private _useDeltaForWorldStep;
  108221. world: any;
  108222. name: string;
  108223. private _physicsMaterials;
  108224. private _fixedTimeStep;
  108225. private _cannonRaycastResult;
  108226. private _raycastResult;
  108227. private _removeAfterStep;
  108228. BJSCANNON: any;
  108229. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  108230. setGravity(gravity: Vector3): void;
  108231. setTimeStep(timeStep: number): void;
  108232. getTimeStep(): number;
  108233. executeStep(delta: number): void;
  108234. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108235. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108236. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108237. private _processChildMeshes;
  108238. removePhysicsBody(impostor: PhysicsImpostor): void;
  108239. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108240. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108241. private _addMaterial;
  108242. private _checkWithEpsilon;
  108243. private _createShape;
  108244. private _createHeightmap;
  108245. private _minus90X;
  108246. private _plus90X;
  108247. private _tmpPosition;
  108248. private _tmpDeltaPosition;
  108249. private _tmpUnityRotation;
  108250. private _updatePhysicsBodyTransformation;
  108251. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108252. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108253. isSupported(): boolean;
  108254. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108255. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108256. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108257. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108258. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108259. getBodyMass(impostor: PhysicsImpostor): number;
  108260. getBodyFriction(impostor: PhysicsImpostor): number;
  108261. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108262. getBodyRestitution(impostor: PhysicsImpostor): number;
  108263. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108264. sleepBody(impostor: PhysicsImpostor): void;
  108265. wakeUpBody(impostor: PhysicsImpostor): void;
  108266. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  108267. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108268. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108269. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108270. getRadius(impostor: PhysicsImpostor): number;
  108271. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108272. dispose(): void;
  108273. private _extendNamespace;
  108274. /**
  108275. * Does a raycast in the physics world
  108276. * @param from when should the ray start?
  108277. * @param to when should the ray end?
  108278. * @returns PhysicsRaycastResult
  108279. */
  108280. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108281. }
  108282. }
  108283. declare module BABYLON {
  108284. /** @hidden */
  108285. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  108286. world: any;
  108287. name: string;
  108288. BJSOIMO: any;
  108289. private _raycastResult;
  108290. constructor(iterations?: number, oimoInjection?: any);
  108291. setGravity(gravity: Vector3): void;
  108292. setTimeStep(timeStep: number): void;
  108293. getTimeStep(): number;
  108294. private _tmpImpostorsArray;
  108295. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108296. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108297. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108298. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108299. private _tmpPositionVector;
  108300. removePhysicsBody(impostor: PhysicsImpostor): void;
  108301. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108302. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108303. isSupported(): boolean;
  108304. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108305. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108306. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108307. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108308. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108309. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108310. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108311. getBodyMass(impostor: PhysicsImpostor): number;
  108312. getBodyFriction(impostor: PhysicsImpostor): number;
  108313. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108314. getBodyRestitution(impostor: PhysicsImpostor): number;
  108315. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108316. sleepBody(impostor: PhysicsImpostor): void;
  108317. wakeUpBody(impostor: PhysicsImpostor): void;
  108318. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108319. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  108320. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  108321. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108322. getRadius(impostor: PhysicsImpostor): number;
  108323. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108324. dispose(): void;
  108325. /**
  108326. * Does a raycast in the physics world
  108327. * @param from when should the ray start?
  108328. * @param to when should the ray end?
  108329. * @returns PhysicsRaycastResult
  108330. */
  108331. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108332. }
  108333. }
  108334. declare module BABYLON {
  108335. /**
  108336. * Class containing static functions to help procedurally build meshes
  108337. */
  108338. export class RibbonBuilder {
  108339. /**
  108340. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108341. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  108342. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  108343. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  108344. * * 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
  108345. * * 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
  108346. * * 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
  108347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108349. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108350. * * 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
  108351. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  108352. * * 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
  108353. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  108354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108355. * @param name defines the name of the mesh
  108356. * @param options defines the options used to create the mesh
  108357. * @param scene defines the hosting scene
  108358. * @returns the ribbon mesh
  108359. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  108360. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108361. */
  108362. static CreateRibbon(name: string, options: {
  108363. pathArray: Vector3[][];
  108364. closeArray?: boolean;
  108365. closePath?: boolean;
  108366. offset?: number;
  108367. updatable?: boolean;
  108368. sideOrientation?: number;
  108369. frontUVs?: Vector4;
  108370. backUVs?: Vector4;
  108371. instance?: Mesh;
  108372. invertUV?: boolean;
  108373. uvs?: Vector2[];
  108374. colors?: Color4[];
  108375. }, scene?: Nullable<Scene>): Mesh;
  108376. }
  108377. }
  108378. declare module BABYLON {
  108379. /**
  108380. * Class containing static functions to help procedurally build meshes
  108381. */
  108382. export class ShapeBuilder {
  108383. /**
  108384. * 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.
  108385. * * 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.
  108386. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108387. * * 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.
  108388. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  108389. * * 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
  108390. * * 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
  108391. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  108392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108394. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  108395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108396. * @param name defines the name of the mesh
  108397. * @param options defines the options used to create the mesh
  108398. * @param scene defines the hosting scene
  108399. * @returns the extruded shape mesh
  108400. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108401. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108402. */
  108403. static ExtrudeShape(name: string, options: {
  108404. shape: Vector3[];
  108405. path: Vector3[];
  108406. scale?: number;
  108407. rotation?: number;
  108408. cap?: number;
  108409. updatable?: boolean;
  108410. sideOrientation?: number;
  108411. frontUVs?: Vector4;
  108412. backUVs?: Vector4;
  108413. instance?: Mesh;
  108414. invertUV?: boolean;
  108415. }, scene?: Nullable<Scene>): Mesh;
  108416. /**
  108417. * Creates an custom extruded shape mesh.
  108418. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  108419. * * 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.
  108420. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108421. * * 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
  108422. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  108423. * * 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
  108424. * * It must returns a float value that will be the scale value applied to the shape on each path point
  108425. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108426. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  108427. * * 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
  108428. * * 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
  108429. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  108430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108432. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108434. * @param name defines the name of the mesh
  108435. * @param options defines the options used to create the mesh
  108436. * @param scene defines the hosting scene
  108437. * @returns the custom extruded shape mesh
  108438. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  108439. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108441. */
  108442. static ExtrudeShapeCustom(name: string, options: {
  108443. shape: Vector3[];
  108444. path: Vector3[];
  108445. scaleFunction?: any;
  108446. rotationFunction?: any;
  108447. ribbonCloseArray?: boolean;
  108448. ribbonClosePath?: boolean;
  108449. cap?: number;
  108450. updatable?: boolean;
  108451. sideOrientation?: number;
  108452. frontUVs?: Vector4;
  108453. backUVs?: Vector4;
  108454. instance?: Mesh;
  108455. invertUV?: boolean;
  108456. }, scene?: Nullable<Scene>): Mesh;
  108457. private static _ExtrudeShapeGeneric;
  108458. }
  108459. }
  108460. declare module BABYLON {
  108461. /**
  108462. * AmmoJS Physics plugin
  108463. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108464. * @see https://github.com/kripken/ammo.js/
  108465. */
  108466. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108467. private _useDeltaForWorldStep;
  108468. /**
  108469. * Reference to the Ammo library
  108470. */
  108471. bjsAMMO: any;
  108472. /**
  108473. * Created ammoJS world which physics bodies are added to
  108474. */
  108475. world: any;
  108476. /**
  108477. * Name of the plugin
  108478. */
  108479. name: string;
  108480. private _timeStep;
  108481. private _fixedTimeStep;
  108482. private _maxSteps;
  108483. private _tmpQuaternion;
  108484. private _tmpAmmoTransform;
  108485. private _tmpAmmoQuaternion;
  108486. private _tmpAmmoConcreteContactResultCallback;
  108487. private _collisionConfiguration;
  108488. private _dispatcher;
  108489. private _overlappingPairCache;
  108490. private _solver;
  108491. private _softBodySolver;
  108492. private _tmpAmmoVectorA;
  108493. private _tmpAmmoVectorB;
  108494. private _tmpAmmoVectorC;
  108495. private _tmpAmmoVectorD;
  108496. private _tmpContactCallbackResult;
  108497. private _tmpAmmoVectorRCA;
  108498. private _tmpAmmoVectorRCB;
  108499. private _raycastResult;
  108500. private static readonly DISABLE_COLLISION_FLAG;
  108501. private static readonly KINEMATIC_FLAG;
  108502. private static readonly DISABLE_DEACTIVATION_FLAG;
  108503. /**
  108504. * Initializes the ammoJS plugin
  108505. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108506. * @param ammoInjection can be used to inject your own ammo reference
  108507. */
  108508. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  108509. /**
  108510. * Sets the gravity of the physics world (m/(s^2))
  108511. * @param gravity Gravity to set
  108512. */
  108513. setGravity(gravity: Vector3): void;
  108514. /**
  108515. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108516. * @param timeStep timestep to use in seconds
  108517. */
  108518. setTimeStep(timeStep: number): void;
  108519. /**
  108520. * 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)
  108521. * @param fixedTimeStep fixedTimeStep to use in seconds
  108522. */
  108523. setFixedTimeStep(fixedTimeStep: number): void;
  108524. /**
  108525. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108526. * @param maxSteps the maximum number of steps by the physics engine per frame
  108527. */
  108528. setMaxSteps(maxSteps: number): void;
  108529. /**
  108530. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108531. * @returns the current timestep in seconds
  108532. */
  108533. getTimeStep(): number;
  108534. private _isImpostorInContact;
  108535. private _isImpostorPairInContact;
  108536. private _stepSimulation;
  108537. /**
  108538. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108539. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108540. * After the step the babylon meshes are set to the position of the physics imposters
  108541. * @param delta amount of time to step forward
  108542. * @param impostors array of imposters to update before/after the step
  108543. */
  108544. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108545. /**
  108546. * Update babylon mesh to match physics world object
  108547. * @param impostor imposter to match
  108548. */
  108549. private _afterSoftStep;
  108550. /**
  108551. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108552. * @param impostor imposter to match
  108553. */
  108554. private _ropeStep;
  108555. /**
  108556. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108557. * @param impostor imposter to match
  108558. */
  108559. private _softbodyOrClothStep;
  108560. private _tmpVector;
  108561. private _tmpMatrix;
  108562. /**
  108563. * Applies an impulse on the imposter
  108564. * @param impostor imposter to apply impulse to
  108565. * @param force amount of force to be applied to the imposter
  108566. * @param contactPoint the location to apply the impulse on the imposter
  108567. */
  108568. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108569. /**
  108570. * Applies a force on the imposter
  108571. * @param impostor imposter to apply force
  108572. * @param force amount of force to be applied to the imposter
  108573. * @param contactPoint the location to apply the force on the imposter
  108574. */
  108575. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108576. /**
  108577. * Creates a physics body using the plugin
  108578. * @param impostor the imposter to create the physics body on
  108579. */
  108580. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108581. /**
  108582. * Removes the physics body from the imposter and disposes of the body's memory
  108583. * @param impostor imposter to remove the physics body from
  108584. */
  108585. removePhysicsBody(impostor: PhysicsImpostor): void;
  108586. /**
  108587. * Generates a joint
  108588. * @param impostorJoint the imposter joint to create the joint with
  108589. */
  108590. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108591. /**
  108592. * Removes a joint
  108593. * @param impostorJoint the imposter joint to remove the joint from
  108594. */
  108595. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108596. private _addMeshVerts;
  108597. /**
  108598. * Initialise the soft body vertices to match its object's (mesh) vertices
  108599. * Softbody vertices (nodes) are in world space and to match this
  108600. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  108601. * @param impostor to create the softbody for
  108602. */
  108603. private _softVertexData;
  108604. /**
  108605. * Create an impostor's soft body
  108606. * @param impostor to create the softbody for
  108607. */
  108608. private _createSoftbody;
  108609. /**
  108610. * Create cloth for an impostor
  108611. * @param impostor to create the softbody for
  108612. */
  108613. private _createCloth;
  108614. /**
  108615. * Create rope for an impostor
  108616. * @param impostor to create the softbody for
  108617. */
  108618. private _createRope;
  108619. private _addHullVerts;
  108620. private _createShape;
  108621. /**
  108622. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108623. * @param impostor imposter containing the physics body and babylon object
  108624. */
  108625. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108626. /**
  108627. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108628. * @param impostor imposter containing the physics body and babylon object
  108629. * @param newPosition new position
  108630. * @param newRotation new rotation
  108631. */
  108632. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108633. /**
  108634. * If this plugin is supported
  108635. * @returns true if its supported
  108636. */
  108637. isSupported(): boolean;
  108638. /**
  108639. * Sets the linear velocity of the physics body
  108640. * @param impostor imposter to set the velocity on
  108641. * @param velocity velocity to set
  108642. */
  108643. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108644. /**
  108645. * Sets the angular velocity of the physics body
  108646. * @param impostor imposter to set the velocity on
  108647. * @param velocity velocity to set
  108648. */
  108649. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108650. /**
  108651. * gets the linear velocity
  108652. * @param impostor imposter to get linear velocity from
  108653. * @returns linear velocity
  108654. */
  108655. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108656. /**
  108657. * gets the angular velocity
  108658. * @param impostor imposter to get angular velocity from
  108659. * @returns angular velocity
  108660. */
  108661. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108662. /**
  108663. * Sets the mass of physics body
  108664. * @param impostor imposter to set the mass on
  108665. * @param mass mass to set
  108666. */
  108667. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108668. /**
  108669. * Gets the mass of the physics body
  108670. * @param impostor imposter to get the mass from
  108671. * @returns mass
  108672. */
  108673. getBodyMass(impostor: PhysicsImpostor): number;
  108674. /**
  108675. * Gets friction of the impostor
  108676. * @param impostor impostor to get friction from
  108677. * @returns friction value
  108678. */
  108679. getBodyFriction(impostor: PhysicsImpostor): number;
  108680. /**
  108681. * Sets friction of the impostor
  108682. * @param impostor impostor to set friction on
  108683. * @param friction friction value
  108684. */
  108685. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108686. /**
  108687. * Gets restitution of the impostor
  108688. * @param impostor impostor to get restitution from
  108689. * @returns restitution value
  108690. */
  108691. getBodyRestitution(impostor: PhysicsImpostor): number;
  108692. /**
  108693. * Sets resitution of the impostor
  108694. * @param impostor impostor to set resitution on
  108695. * @param restitution resitution value
  108696. */
  108697. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108698. /**
  108699. * Gets pressure inside the impostor
  108700. * @param impostor impostor to get pressure from
  108701. * @returns pressure value
  108702. */
  108703. getBodyPressure(impostor: PhysicsImpostor): number;
  108704. /**
  108705. * Sets pressure inside a soft body impostor
  108706. * Cloth and rope must remain 0 pressure
  108707. * @param impostor impostor to set pressure on
  108708. * @param pressure pressure value
  108709. */
  108710. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  108711. /**
  108712. * Gets stiffness of the impostor
  108713. * @param impostor impostor to get stiffness from
  108714. * @returns pressure value
  108715. */
  108716. getBodyStiffness(impostor: PhysicsImpostor): number;
  108717. /**
  108718. * Sets stiffness of the impostor
  108719. * @param impostor impostor to set stiffness on
  108720. * @param stiffness stiffness value from 0 to 1
  108721. */
  108722. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  108723. /**
  108724. * Gets velocityIterations of the impostor
  108725. * @param impostor impostor to get velocity iterations from
  108726. * @returns velocityIterations value
  108727. */
  108728. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  108729. /**
  108730. * Sets velocityIterations of the impostor
  108731. * @param impostor impostor to set velocity iterations on
  108732. * @param velocityIterations velocityIterations value
  108733. */
  108734. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  108735. /**
  108736. * Gets positionIterations of the impostor
  108737. * @param impostor impostor to get position iterations from
  108738. * @returns positionIterations value
  108739. */
  108740. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  108741. /**
  108742. * Sets positionIterations of the impostor
  108743. * @param impostor impostor to set position on
  108744. * @param positionIterations positionIterations value
  108745. */
  108746. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  108747. /**
  108748. * Append an anchor to a cloth object
  108749. * @param impostor is the cloth impostor to add anchor to
  108750. * @param otherImpostor is the rigid impostor to anchor to
  108751. * @param width ratio across width from 0 to 1
  108752. * @param height ratio up height from 0 to 1
  108753. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108754. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108755. */
  108756. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108757. /**
  108758. * Append an hook to a rope object
  108759. * @param impostor is the rope impostor to add hook to
  108760. * @param otherImpostor is the rigid impostor to hook to
  108761. * @param length ratio along the rope from 0 to 1
  108762. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  108763. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108764. */
  108765. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108766. /**
  108767. * Sleeps the physics body and stops it from being active
  108768. * @param impostor impostor to sleep
  108769. */
  108770. sleepBody(impostor: PhysicsImpostor): void;
  108771. /**
  108772. * Activates the physics body
  108773. * @param impostor impostor to activate
  108774. */
  108775. wakeUpBody(impostor: PhysicsImpostor): void;
  108776. /**
  108777. * Updates the distance parameters of the joint
  108778. * @param joint joint to update
  108779. * @param maxDistance maximum distance of the joint
  108780. * @param minDistance minimum distance of the joint
  108781. */
  108782. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108783. /**
  108784. * Sets a motor on the joint
  108785. * @param joint joint to set motor on
  108786. * @param speed speed of the motor
  108787. * @param maxForce maximum force of the motor
  108788. * @param motorIndex index of the motor
  108789. */
  108790. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108791. /**
  108792. * Sets the motors limit
  108793. * @param joint joint to set limit on
  108794. * @param upperLimit upper limit
  108795. * @param lowerLimit lower limit
  108796. */
  108797. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108798. /**
  108799. * Syncs the position and rotation of a mesh with the impostor
  108800. * @param mesh mesh to sync
  108801. * @param impostor impostor to update the mesh with
  108802. */
  108803. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108804. /**
  108805. * Gets the radius of the impostor
  108806. * @param impostor impostor to get radius from
  108807. * @returns the radius
  108808. */
  108809. getRadius(impostor: PhysicsImpostor): number;
  108810. /**
  108811. * Gets the box size of the impostor
  108812. * @param impostor impostor to get box size from
  108813. * @param result the resulting box size
  108814. */
  108815. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108816. /**
  108817. * Disposes of the impostor
  108818. */
  108819. dispose(): void;
  108820. /**
  108821. * Does a raycast in the physics world
  108822. * @param from when should the ray start?
  108823. * @param to when should the ray end?
  108824. * @returns PhysicsRaycastResult
  108825. */
  108826. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108827. }
  108828. }
  108829. declare module BABYLON {
  108830. interface AbstractScene {
  108831. /**
  108832. * The list of reflection probes added to the scene
  108833. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108834. */
  108835. reflectionProbes: Array<ReflectionProbe>;
  108836. /**
  108837. * Removes the given reflection probe from this scene.
  108838. * @param toRemove The reflection probe to remove
  108839. * @returns The index of the removed reflection probe
  108840. */
  108841. removeReflectionProbe(toRemove: ReflectionProbe): number;
  108842. /**
  108843. * Adds the given reflection probe to this scene.
  108844. * @param newReflectionProbe The reflection probe to add
  108845. */
  108846. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  108847. }
  108848. /**
  108849. * Class used to generate realtime reflection / refraction cube textures
  108850. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108851. */
  108852. export class ReflectionProbe {
  108853. /** defines the name of the probe */
  108854. name: string;
  108855. private _scene;
  108856. private _renderTargetTexture;
  108857. private _projectionMatrix;
  108858. private _viewMatrix;
  108859. private _target;
  108860. private _add;
  108861. private _attachedMesh;
  108862. private _invertYAxis;
  108863. /** Gets or sets probe position (center of the cube map) */
  108864. position: Vector3;
  108865. /**
  108866. * Creates a new reflection probe
  108867. * @param name defines the name of the probe
  108868. * @param size defines the texture resolution (for each face)
  108869. * @param scene defines the hosting scene
  108870. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  108871. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  108872. */
  108873. constructor(
  108874. /** defines the name of the probe */
  108875. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  108876. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  108877. samples: number;
  108878. /** Gets or sets the refresh rate to use (on every frame by default) */
  108879. refreshRate: number;
  108880. /**
  108881. * Gets the hosting scene
  108882. * @returns a Scene
  108883. */
  108884. getScene(): Scene;
  108885. /** Gets the internal CubeTexture used to render to */
  108886. readonly cubeTexture: RenderTargetTexture;
  108887. /** Gets the list of meshes to render */
  108888. readonly renderList: Nullable<AbstractMesh[]>;
  108889. /**
  108890. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  108891. * @param mesh defines the mesh to attach to
  108892. */
  108893. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108894. /**
  108895. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  108896. * @param renderingGroupId The rendering group id corresponding to its index
  108897. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108898. */
  108899. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  108900. /**
  108901. * Clean all associated resources
  108902. */
  108903. dispose(): void;
  108904. /**
  108905. * Converts the reflection probe information to a readable string for debug purpose.
  108906. * @param fullDetails Supports for multiple levels of logging within scene loading
  108907. * @returns the human readable reflection probe info
  108908. */
  108909. toString(fullDetails?: boolean): string;
  108910. /**
  108911. * Get the class name of the relfection probe.
  108912. * @returns "ReflectionProbe"
  108913. */
  108914. getClassName(): string;
  108915. /**
  108916. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  108917. * @returns The JSON representation of the texture
  108918. */
  108919. serialize(): any;
  108920. /**
  108921. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  108922. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  108923. * @param scene Define the scene the parsed reflection probe should be instantiated in
  108924. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108925. * @returns The parsed reflection probe if successful
  108926. */
  108927. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  108928. }
  108929. }
  108930. declare module BABYLON {
  108931. /** @hidden */
  108932. export var _BabylonLoaderRegistered: boolean;
  108933. }
  108934. declare module BABYLON {
  108935. /**
  108936. * The Physically based simple base material of BJS.
  108937. *
  108938. * This enables better naming and convention enforcements on top of the pbrMaterial.
  108939. * It is used as the base class for both the specGloss and metalRough conventions.
  108940. */
  108941. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  108942. /**
  108943. * Number of Simultaneous lights allowed on the material.
  108944. */
  108945. maxSimultaneousLights: number;
  108946. /**
  108947. * If sets to true, disables all the lights affecting the material.
  108948. */
  108949. disableLighting: boolean;
  108950. /**
  108951. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108952. */
  108953. environmentTexture: BaseTexture;
  108954. /**
  108955. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108956. */
  108957. invertNormalMapX: boolean;
  108958. /**
  108959. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108960. */
  108961. invertNormalMapY: boolean;
  108962. /**
  108963. * Normal map used in the model.
  108964. */
  108965. normalTexture: BaseTexture;
  108966. /**
  108967. * Emissivie color used to self-illuminate the model.
  108968. */
  108969. emissiveColor: Color3;
  108970. /**
  108971. * Emissivie texture used to self-illuminate the model.
  108972. */
  108973. emissiveTexture: BaseTexture;
  108974. /**
  108975. * Occlusion Channel Strenght.
  108976. */
  108977. occlusionStrength: number;
  108978. /**
  108979. * Occlusion Texture of the material (adding extra occlusion effects).
  108980. */
  108981. occlusionTexture: BaseTexture;
  108982. /**
  108983. * Defines the alpha limits in alpha test mode.
  108984. */
  108985. alphaCutOff: number;
  108986. /**
  108987. * Gets the current double sided mode.
  108988. */
  108989. /**
  108990. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108991. */
  108992. doubleSided: boolean;
  108993. /**
  108994. * Stores the pre-calculated light information of a mesh in a texture.
  108995. */
  108996. lightmapTexture: BaseTexture;
  108997. /**
  108998. * If true, the light map contains occlusion information instead of lighting info.
  108999. */
  109000. useLightmapAsShadowmap: boolean;
  109001. /**
  109002. * Instantiates a new PBRMaterial instance.
  109003. *
  109004. * @param name The material name
  109005. * @param scene The scene the material will be use in.
  109006. */
  109007. constructor(name: string, scene: Scene);
  109008. getClassName(): string;
  109009. }
  109010. }
  109011. declare module BABYLON {
  109012. /**
  109013. * The PBR material of BJS following the metal roughness convention.
  109014. *
  109015. * This fits to the PBR convention in the GLTF definition:
  109016. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  109017. */
  109018. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  109019. /**
  109020. * The base color has two different interpretations depending on the value of metalness.
  109021. * When the material is a metal, the base color is the specific measured reflectance value
  109022. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  109023. * of the material.
  109024. */
  109025. baseColor: Color3;
  109026. /**
  109027. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  109028. * well as opacity information in the alpha channel.
  109029. */
  109030. baseTexture: BaseTexture;
  109031. /**
  109032. * Specifies the metallic scalar value of the material.
  109033. * Can also be used to scale the metalness values of the metallic texture.
  109034. */
  109035. metallic: number;
  109036. /**
  109037. * Specifies the roughness scalar value of the material.
  109038. * Can also be used to scale the roughness values of the metallic texture.
  109039. */
  109040. roughness: number;
  109041. /**
  109042. * Texture containing both the metallic value in the B channel and the
  109043. * roughness value in the G channel to keep better precision.
  109044. */
  109045. metallicRoughnessTexture: BaseTexture;
  109046. /**
  109047. * Instantiates a new PBRMetalRoughnessMaterial instance.
  109048. *
  109049. * @param name The material name
  109050. * @param scene The scene the material will be use in.
  109051. */
  109052. constructor(name: string, scene: Scene);
  109053. /**
  109054. * Return the currrent class name of the material.
  109055. */
  109056. getClassName(): string;
  109057. /**
  109058. * Makes a duplicate of the current material.
  109059. * @param name - name to use for the new material.
  109060. */
  109061. clone(name: string): PBRMetallicRoughnessMaterial;
  109062. /**
  109063. * Serialize the material to a parsable JSON object.
  109064. */
  109065. serialize(): any;
  109066. /**
  109067. * Parses a JSON object correponding to the serialize function.
  109068. */
  109069. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  109070. }
  109071. }
  109072. declare module BABYLON {
  109073. /**
  109074. * The PBR material of BJS following the specular glossiness convention.
  109075. *
  109076. * This fits to the PBR convention in the GLTF definition:
  109077. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  109078. */
  109079. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  109080. /**
  109081. * Specifies the diffuse color of the material.
  109082. */
  109083. diffuseColor: Color3;
  109084. /**
  109085. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  109086. * channel.
  109087. */
  109088. diffuseTexture: BaseTexture;
  109089. /**
  109090. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  109091. */
  109092. specularColor: Color3;
  109093. /**
  109094. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  109095. */
  109096. glossiness: number;
  109097. /**
  109098. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  109099. */
  109100. specularGlossinessTexture: BaseTexture;
  109101. /**
  109102. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  109103. *
  109104. * @param name The material name
  109105. * @param scene The scene the material will be use in.
  109106. */
  109107. constructor(name: string, scene: Scene);
  109108. /**
  109109. * Return the currrent class name of the material.
  109110. */
  109111. getClassName(): string;
  109112. /**
  109113. * Makes a duplicate of the current material.
  109114. * @param name - name to use for the new material.
  109115. */
  109116. clone(name: string): PBRSpecularGlossinessMaterial;
  109117. /**
  109118. * Serialize the material to a parsable JSON object.
  109119. */
  109120. serialize(): any;
  109121. /**
  109122. * Parses a JSON object correponding to the serialize function.
  109123. */
  109124. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  109125. }
  109126. }
  109127. declare module BABYLON {
  109128. /**
  109129. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  109130. * It can help converting any input color in a desired output one. This can then be used to create effects
  109131. * from sepia, black and white to sixties or futuristic rendering...
  109132. *
  109133. * The only supported format is currently 3dl.
  109134. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  109135. */
  109136. export class ColorGradingTexture extends BaseTexture {
  109137. /**
  109138. * The current texture matrix. (will always be identity in color grading texture)
  109139. */
  109140. private _textureMatrix;
  109141. /**
  109142. * The texture URL.
  109143. */
  109144. url: string;
  109145. /**
  109146. * Empty line regex stored for GC.
  109147. */
  109148. private static _noneEmptyLineRegex;
  109149. private _engine;
  109150. /**
  109151. * Instantiates a ColorGradingTexture from the following parameters.
  109152. *
  109153. * @param url The location of the color gradind data (currently only supporting 3dl)
  109154. * @param scene The scene the texture will be used in
  109155. */
  109156. constructor(url: string, scene: Scene);
  109157. /**
  109158. * Returns the texture matrix used in most of the material.
  109159. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  109160. */
  109161. getTextureMatrix(): Matrix;
  109162. /**
  109163. * Occurs when the file being loaded is a .3dl LUT file.
  109164. */
  109165. private load3dlTexture;
  109166. /**
  109167. * Starts the loading process of the texture.
  109168. */
  109169. private loadTexture;
  109170. /**
  109171. * Clones the color gradind texture.
  109172. */
  109173. clone(): ColorGradingTexture;
  109174. /**
  109175. * Called during delayed load for textures.
  109176. */
  109177. delayLoad(): void;
  109178. /**
  109179. * Parses a color grading texture serialized by Babylon.
  109180. * @param parsedTexture The texture information being parsedTexture
  109181. * @param scene The scene to load the texture in
  109182. * @param rootUrl The root url of the data assets to load
  109183. * @return A color gradind texture
  109184. */
  109185. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  109186. /**
  109187. * Serializes the LUT texture to json format.
  109188. */
  109189. serialize(): any;
  109190. }
  109191. }
  109192. declare module BABYLON {
  109193. /**
  109194. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  109195. */
  109196. export class EquiRectangularCubeTexture extends BaseTexture {
  109197. /** The six faces of the cube. */
  109198. private static _FacesMapping;
  109199. private _noMipmap;
  109200. private _onLoad;
  109201. private _onError;
  109202. /** The size of the cubemap. */
  109203. private _size;
  109204. /** The buffer of the image. */
  109205. private _buffer;
  109206. /** The width of the input image. */
  109207. private _width;
  109208. /** The height of the input image. */
  109209. private _height;
  109210. /** The URL to the image. */
  109211. url: string;
  109212. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  109213. coordinatesMode: number;
  109214. /**
  109215. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  109216. * @param url The location of the image
  109217. * @param scene The scene the texture will be used in
  109218. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  109219. * @param noMipmap Forces to not generate the mipmap if true
  109220. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  109221. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  109222. * @param onLoad — defines a callback called when texture is loaded
  109223. * @param onError — defines a callback called if there is an error
  109224. */
  109225. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  109226. /**
  109227. * Load the image data, by putting the image on a canvas and extracting its buffer.
  109228. */
  109229. private loadImage;
  109230. /**
  109231. * Convert the image buffer into a cubemap and create a CubeTexture.
  109232. */
  109233. private loadTexture;
  109234. /**
  109235. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  109236. * @param buffer The ArrayBuffer that should be converted.
  109237. * @returns The buffer as Float32Array.
  109238. */
  109239. private getFloat32ArrayFromArrayBuffer;
  109240. /**
  109241. * Get the current class name of the texture useful for serialization or dynamic coding.
  109242. * @returns "EquiRectangularCubeTexture"
  109243. */
  109244. getClassName(): string;
  109245. /**
  109246. * Create a clone of the current EquiRectangularCubeTexture and return it.
  109247. * @returns A clone of the current EquiRectangularCubeTexture.
  109248. */
  109249. clone(): EquiRectangularCubeTexture;
  109250. }
  109251. }
  109252. declare module BABYLON {
  109253. /**
  109254. * Based on jsTGALoader - Javascript loader for TGA file
  109255. * By Vincent Thibault
  109256. * @see http://blog.robrowser.com/javascript-tga-loader.html
  109257. */
  109258. export class TGATools {
  109259. private static _TYPE_INDEXED;
  109260. private static _TYPE_RGB;
  109261. private static _TYPE_GREY;
  109262. private static _TYPE_RLE_INDEXED;
  109263. private static _TYPE_RLE_RGB;
  109264. private static _TYPE_RLE_GREY;
  109265. private static _ORIGIN_MASK;
  109266. private static _ORIGIN_SHIFT;
  109267. private static _ORIGIN_BL;
  109268. private static _ORIGIN_BR;
  109269. private static _ORIGIN_UL;
  109270. private static _ORIGIN_UR;
  109271. /**
  109272. * Gets the header of a TGA file
  109273. * @param data defines the TGA data
  109274. * @returns the header
  109275. */
  109276. static GetTGAHeader(data: Uint8Array): any;
  109277. /**
  109278. * Uploads TGA content to a Babylon Texture
  109279. * @hidden
  109280. */
  109281. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  109282. /** @hidden */
  109283. 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;
  109284. /** @hidden */
  109285. 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;
  109286. /** @hidden */
  109287. 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;
  109288. /** @hidden */
  109289. 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;
  109290. /** @hidden */
  109291. 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;
  109292. /** @hidden */
  109293. 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;
  109294. }
  109295. }
  109296. declare module BABYLON {
  109297. /**
  109298. * Implementation of the TGA Texture Loader.
  109299. * @hidden
  109300. */
  109301. export class _TGATextureLoader implements IInternalTextureLoader {
  109302. /**
  109303. * Defines wether the loader supports cascade loading the different faces.
  109304. */
  109305. readonly supportCascades: boolean;
  109306. /**
  109307. * This returns if the loader support the current file information.
  109308. * @param extension defines the file extension of the file being loaded
  109309. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109310. * @param fallback defines the fallback internal texture if any
  109311. * @param isBase64 defines whether the texture is encoded as a base64
  109312. * @param isBuffer defines whether the texture data are stored as a buffer
  109313. * @returns true if the loader can load the specified file
  109314. */
  109315. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109316. /**
  109317. * Transform the url before loading if required.
  109318. * @param rootUrl the url of the texture
  109319. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109320. * @returns the transformed texture
  109321. */
  109322. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109323. /**
  109324. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109325. * @param rootUrl the url of the texture
  109326. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109327. * @returns the fallback texture
  109328. */
  109329. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109330. /**
  109331. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109332. * @param data contains the texture data
  109333. * @param texture defines the BabylonJS internal texture
  109334. * @param createPolynomials will be true if polynomials have been requested
  109335. * @param onLoad defines the callback to trigger once the texture is ready
  109336. * @param onError defines the callback to trigger in case of error
  109337. */
  109338. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109339. /**
  109340. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109341. * @param data contains the texture data
  109342. * @param texture defines the BabylonJS internal texture
  109343. * @param callback defines the method to call once ready to upload
  109344. */
  109345. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109346. }
  109347. }
  109348. declare module BABYLON {
  109349. /**
  109350. * 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.
  109351. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109352. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109353. */
  109354. export class CustomProceduralTexture extends ProceduralTexture {
  109355. private _animate;
  109356. private _time;
  109357. private _config;
  109358. private _texturePath;
  109359. /**
  109360. * Instantiates a new Custom Procedural Texture.
  109361. * 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.
  109362. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109363. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109364. * @param name Define the name of the texture
  109365. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  109366. * @param size Define the size of the texture to create
  109367. * @param scene Define the scene the texture belongs to
  109368. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  109369. * @param generateMipMaps Define if the texture should creates mip maps or not
  109370. */
  109371. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109372. private _loadJson;
  109373. /**
  109374. * Is the texture ready to be used ? (rendered at least once)
  109375. * @returns true if ready, otherwise, false.
  109376. */
  109377. isReady(): boolean;
  109378. /**
  109379. * Render the texture to its associated render target.
  109380. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  109381. */
  109382. render(useCameraPostProcess?: boolean): void;
  109383. /**
  109384. * Update the list of dependant textures samplers in the shader.
  109385. */
  109386. updateTextures(): void;
  109387. /**
  109388. * Update the uniform values of the procedural texture in the shader.
  109389. */
  109390. updateShaderUniforms(): void;
  109391. /**
  109392. * Define if the texture animates or not.
  109393. */
  109394. animate: boolean;
  109395. }
  109396. }
  109397. declare module BABYLON {
  109398. /** @hidden */
  109399. export var noisePixelShader: {
  109400. name: string;
  109401. shader: string;
  109402. };
  109403. }
  109404. declare module BABYLON {
  109405. /**
  109406. * Class used to generate noise procedural textures
  109407. */
  109408. export class NoiseProceduralTexture extends ProceduralTexture {
  109409. private _time;
  109410. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  109411. brightness: number;
  109412. /** Defines the number of octaves to process */
  109413. octaves: number;
  109414. /** Defines the level of persistence (0.8 by default) */
  109415. persistence: number;
  109416. /** Gets or sets animation speed factor (default is 1) */
  109417. animationSpeedFactor: number;
  109418. /**
  109419. * Creates a new NoiseProceduralTexture
  109420. * @param name defines the name fo the texture
  109421. * @param size defines the size of the texture (default is 256)
  109422. * @param scene defines the hosting scene
  109423. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  109424. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  109425. */
  109426. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109427. private _updateShaderUniforms;
  109428. protected _getDefines(): string;
  109429. /** Generate the current state of the procedural texture */
  109430. render(useCameraPostProcess?: boolean): void;
  109431. /**
  109432. * Serializes this noise procedural texture
  109433. * @returns a serialized noise procedural texture object
  109434. */
  109435. serialize(): any;
  109436. /**
  109437. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  109438. * @param parsedTexture defines parsed texture data
  109439. * @param scene defines the current scene
  109440. * @param rootUrl defines the root URL containing noise procedural texture information
  109441. * @returns a parsed NoiseProceduralTexture
  109442. */
  109443. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  109444. }
  109445. }
  109446. declare module BABYLON {
  109447. /**
  109448. * Raw cube texture where the raw buffers are passed in
  109449. */
  109450. export class RawCubeTexture extends CubeTexture {
  109451. /**
  109452. * Creates a cube texture where the raw buffers are passed in.
  109453. * @param scene defines the scene the texture is attached to
  109454. * @param data defines the array of data to use to create each face
  109455. * @param size defines the size of the textures
  109456. * @param format defines the format of the data
  109457. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  109458. * @param generateMipMaps defines if the engine should generate the mip levels
  109459. * @param invertY defines if data must be stored with Y axis inverted
  109460. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  109461. * @param compression defines the compression used (null by default)
  109462. */
  109463. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  109464. /**
  109465. * Updates the raw cube texture.
  109466. * @param data defines the data to store
  109467. * @param format defines the data format
  109468. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109469. * @param invertY defines if data must be stored with Y axis inverted
  109470. * @param compression defines the compression used (null by default)
  109471. * @param level defines which level of the texture to update
  109472. */
  109473. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  109474. /**
  109475. * Updates a raw cube texture with RGBD encoded data.
  109476. * @param data defines the array of data [mipmap][face] to use to create each face
  109477. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  109478. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109479. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109480. * @returns a promsie that resolves when the operation is complete
  109481. */
  109482. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  109483. /**
  109484. * Clones the raw cube texture.
  109485. * @return a new cube texture
  109486. */
  109487. clone(): CubeTexture;
  109488. /** @hidden */
  109489. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109490. }
  109491. }
  109492. declare module BABYLON {
  109493. /**
  109494. * Class used to store 3D textures containing user data
  109495. */
  109496. export class RawTexture3D extends Texture {
  109497. /** Gets or sets the texture format to use */
  109498. format: number;
  109499. private _engine;
  109500. /**
  109501. * Create a new RawTexture3D
  109502. * @param data defines the data of the texture
  109503. * @param width defines the width of the texture
  109504. * @param height defines the height of the texture
  109505. * @param depth defines the depth of the texture
  109506. * @param format defines the texture format to use
  109507. * @param scene defines the hosting scene
  109508. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  109509. * @param invertY defines if texture must be stored with Y axis inverted
  109510. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109511. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  109512. */
  109513. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  109514. /** Gets or sets the texture format to use */
  109515. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  109516. /**
  109517. * Update the texture with new data
  109518. * @param data defines the data to store in the texture
  109519. */
  109520. update(data: ArrayBufferView): void;
  109521. }
  109522. }
  109523. declare module BABYLON {
  109524. /**
  109525. * Creates a refraction texture used by refraction channel of the standard material.
  109526. * It is like a mirror but to see through a material.
  109527. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109528. */
  109529. export class RefractionTexture extends RenderTargetTexture {
  109530. /**
  109531. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  109532. * 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.
  109533. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109534. */
  109535. refractionPlane: Plane;
  109536. /**
  109537. * Define how deep under the surface we should see.
  109538. */
  109539. depth: number;
  109540. /**
  109541. * Creates a refraction texture used by refraction channel of the standard material.
  109542. * It is like a mirror but to see through a material.
  109543. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109544. * @param name Define the texture name
  109545. * @param size Define the size of the underlying texture
  109546. * @param scene Define the scene the refraction belongs to
  109547. * @param generateMipMaps Define if we need to generate mips level for the refraction
  109548. */
  109549. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  109550. /**
  109551. * Clone the refraction texture.
  109552. * @returns the cloned texture
  109553. */
  109554. clone(): RefractionTexture;
  109555. /**
  109556. * Serialize the texture to a JSON representation you could use in Parse later on
  109557. * @returns the serialized JSON representation
  109558. */
  109559. serialize(): any;
  109560. }
  109561. }
  109562. declare module BABYLON {
  109563. /**
  109564. * Defines the options related to the creation of an HtmlElementTexture
  109565. */
  109566. export interface IHtmlElementTextureOptions {
  109567. /**
  109568. * Defines wether mip maps should be created or not.
  109569. */
  109570. generateMipMaps?: boolean;
  109571. /**
  109572. * Defines the sampling mode of the texture.
  109573. */
  109574. samplingMode?: number;
  109575. /**
  109576. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  109577. */
  109578. engine: Nullable<Engine>;
  109579. /**
  109580. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  109581. */
  109582. scene: Nullable<Scene>;
  109583. }
  109584. /**
  109585. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  109586. * To be as efficient as possible depending on your constraints nothing aside the first upload
  109587. * is automatically managed.
  109588. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  109589. * in your application.
  109590. *
  109591. * As the update is not automatic, you need to call them manually.
  109592. */
  109593. export class HtmlElementTexture extends BaseTexture {
  109594. /**
  109595. * The texture URL.
  109596. */
  109597. element: HTMLVideoElement | HTMLCanvasElement;
  109598. private static readonly DefaultOptions;
  109599. private _textureMatrix;
  109600. private _engine;
  109601. private _isVideo;
  109602. private _generateMipMaps;
  109603. private _samplingMode;
  109604. /**
  109605. * Instantiates a HtmlElementTexture from the following parameters.
  109606. *
  109607. * @param name Defines the name of the texture
  109608. * @param element Defines the video or canvas the texture is filled with
  109609. * @param options Defines the other none mandatory texture creation options
  109610. */
  109611. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  109612. private _createInternalTexture;
  109613. /**
  109614. * Returns the texture matrix used in most of the material.
  109615. */
  109616. getTextureMatrix(): Matrix;
  109617. /**
  109618. * Updates the content of the texture.
  109619. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  109620. */
  109621. update(invertY?: Nullable<boolean>): void;
  109622. }
  109623. }
  109624. declare module BABYLON {
  109625. /**
  109626. * Helper class to push actions to a pool of workers.
  109627. */
  109628. export class WorkerPool implements IDisposable {
  109629. private _workerInfos;
  109630. private _pendingActions;
  109631. /**
  109632. * Constructor
  109633. * @param workers Array of workers to use for actions
  109634. */
  109635. constructor(workers: Array<Worker>);
  109636. /**
  109637. * Terminates all workers and clears any pending actions.
  109638. */
  109639. dispose(): void;
  109640. /**
  109641. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109642. * pended until a worker has completed its action.
  109643. * @param action The action to perform. Call onComplete when the action is complete.
  109644. */
  109645. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109646. private _execute;
  109647. }
  109648. }
  109649. declare module BABYLON {
  109650. /**
  109651. * Configuration for Draco compression
  109652. */
  109653. export interface IDracoCompressionConfiguration {
  109654. /**
  109655. * Configuration for the decoder.
  109656. */
  109657. decoder: {
  109658. /**
  109659. * The url to the WebAssembly module.
  109660. */
  109661. wasmUrl?: string;
  109662. /**
  109663. * The url to the WebAssembly binary.
  109664. */
  109665. wasmBinaryUrl?: string;
  109666. /**
  109667. * The url to the fallback JavaScript module.
  109668. */
  109669. fallbackUrl?: string;
  109670. };
  109671. }
  109672. /**
  109673. * Draco compression (https://google.github.io/draco/)
  109674. *
  109675. * This class wraps the Draco module.
  109676. *
  109677. * **Encoder**
  109678. *
  109679. * The encoder is not currently implemented.
  109680. *
  109681. * **Decoder**
  109682. *
  109683. * 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.
  109684. *
  109685. * To update the configuration, use the following code:
  109686. * ```javascript
  109687. * DracoCompression.Configuration = {
  109688. * decoder: {
  109689. * wasmUrl: "<url to the WebAssembly library>",
  109690. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  109691. * fallbackUrl: "<url to the fallback JavaScript library>",
  109692. * }
  109693. * };
  109694. * ```
  109695. *
  109696. * 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.
  109697. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  109698. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  109699. *
  109700. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  109701. * ```javascript
  109702. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  109703. * ```
  109704. *
  109705. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  109706. */
  109707. export class DracoCompression implements IDisposable {
  109708. private _workerPoolPromise?;
  109709. private _decoderModulePromise?;
  109710. /**
  109711. * The configuration. Defaults to the following urls:
  109712. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  109713. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  109714. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  109715. */
  109716. static Configuration: IDracoCompressionConfiguration;
  109717. /**
  109718. * Returns true if the decoder configuration is available.
  109719. */
  109720. static readonly DecoderAvailable: boolean;
  109721. /**
  109722. * Default number of workers to create when creating the draco compression object.
  109723. */
  109724. static DefaultNumWorkers: number;
  109725. private static GetDefaultNumWorkers;
  109726. private static _Default;
  109727. /**
  109728. * Default instance for the draco compression object.
  109729. */
  109730. static readonly Default: DracoCompression;
  109731. /**
  109732. * Constructor
  109733. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  109734. */
  109735. constructor(numWorkers?: number);
  109736. /**
  109737. * Stop all async operations and release resources.
  109738. */
  109739. dispose(): void;
  109740. /**
  109741. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  109742. * @returns a promise that resolves when ready
  109743. */
  109744. whenReadyAsync(): Promise<void>;
  109745. /**
  109746. * Decode Draco compressed mesh data to vertex data.
  109747. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  109748. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  109749. * @returns A promise that resolves with the decoded vertex data
  109750. */
  109751. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  109752. [kind: string]: number;
  109753. }): Promise<VertexData>;
  109754. }
  109755. }
  109756. declare module BABYLON {
  109757. /**
  109758. * Class for building Constructive Solid Geometry
  109759. */
  109760. export class CSG {
  109761. private polygons;
  109762. /**
  109763. * The world matrix
  109764. */
  109765. matrix: Matrix;
  109766. /**
  109767. * Stores the position
  109768. */
  109769. position: Vector3;
  109770. /**
  109771. * Stores the rotation
  109772. */
  109773. rotation: Vector3;
  109774. /**
  109775. * Stores the rotation quaternion
  109776. */
  109777. rotationQuaternion: Nullable<Quaternion>;
  109778. /**
  109779. * Stores the scaling vector
  109780. */
  109781. scaling: Vector3;
  109782. /**
  109783. * Convert the Mesh to CSG
  109784. * @param mesh The Mesh to convert to CSG
  109785. * @returns A new CSG from the Mesh
  109786. */
  109787. static FromMesh(mesh: Mesh): CSG;
  109788. /**
  109789. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  109790. * @param polygons Polygons used to construct a CSG solid
  109791. */
  109792. private static FromPolygons;
  109793. /**
  109794. * Clones, or makes a deep copy, of the CSG
  109795. * @returns A new CSG
  109796. */
  109797. clone(): CSG;
  109798. /**
  109799. * Unions this CSG with another CSG
  109800. * @param csg The CSG to union against this CSG
  109801. * @returns The unioned CSG
  109802. */
  109803. union(csg: CSG): CSG;
  109804. /**
  109805. * Unions this CSG with another CSG in place
  109806. * @param csg The CSG to union against this CSG
  109807. */
  109808. unionInPlace(csg: CSG): void;
  109809. /**
  109810. * Subtracts this CSG with another CSG
  109811. * @param csg The CSG to subtract against this CSG
  109812. * @returns A new CSG
  109813. */
  109814. subtract(csg: CSG): CSG;
  109815. /**
  109816. * Subtracts this CSG with another CSG in place
  109817. * @param csg The CSG to subtact against this CSG
  109818. */
  109819. subtractInPlace(csg: CSG): void;
  109820. /**
  109821. * Intersect this CSG with another CSG
  109822. * @param csg The CSG to intersect against this CSG
  109823. * @returns A new CSG
  109824. */
  109825. intersect(csg: CSG): CSG;
  109826. /**
  109827. * Intersects this CSG with another CSG in place
  109828. * @param csg The CSG to intersect against this CSG
  109829. */
  109830. intersectInPlace(csg: CSG): void;
  109831. /**
  109832. * Return a new CSG solid with solid and empty space switched. This solid is
  109833. * not modified.
  109834. * @returns A new CSG solid with solid and empty space switched
  109835. */
  109836. inverse(): CSG;
  109837. /**
  109838. * Inverses the CSG in place
  109839. */
  109840. inverseInPlace(): void;
  109841. /**
  109842. * This is used to keep meshes transformations so they can be restored
  109843. * when we build back a Babylon Mesh
  109844. * NB : All CSG operations are performed in world coordinates
  109845. * @param csg The CSG to copy the transform attributes from
  109846. * @returns This CSG
  109847. */
  109848. copyTransformAttributes(csg: CSG): CSG;
  109849. /**
  109850. * Build Raw mesh from CSG
  109851. * Coordinates here are in world space
  109852. * @param name The name of the mesh geometry
  109853. * @param scene The Scene
  109854. * @param keepSubMeshes Specifies if the submeshes should be kept
  109855. * @returns A new Mesh
  109856. */
  109857. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  109858. /**
  109859. * Build Mesh from CSG taking material and transforms into account
  109860. * @param name The name of the Mesh
  109861. * @param material The material of the Mesh
  109862. * @param scene The Scene
  109863. * @param keepSubMeshes Specifies if submeshes should be kept
  109864. * @returns The new Mesh
  109865. */
  109866. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  109867. }
  109868. }
  109869. declare module BABYLON {
  109870. /**
  109871. * Class used to create a trail following a mesh
  109872. */
  109873. export class TrailMesh extends Mesh {
  109874. private _generator;
  109875. private _autoStart;
  109876. private _running;
  109877. private _diameter;
  109878. private _length;
  109879. private _sectionPolygonPointsCount;
  109880. private _sectionVectors;
  109881. private _sectionNormalVectors;
  109882. private _beforeRenderObserver;
  109883. /**
  109884. * @constructor
  109885. * @param name The value used by scene.getMeshByName() to do a lookup.
  109886. * @param generator The mesh to generate a trail.
  109887. * @param scene The scene to add this mesh to.
  109888. * @param diameter Diameter of trailing mesh. Default is 1.
  109889. * @param length Length of trailing mesh. Default is 60.
  109890. * @param autoStart Automatically start trailing mesh. Default true.
  109891. */
  109892. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  109893. /**
  109894. * "TrailMesh"
  109895. * @returns "TrailMesh"
  109896. */
  109897. getClassName(): string;
  109898. private _createMesh;
  109899. /**
  109900. * Start trailing mesh.
  109901. */
  109902. start(): void;
  109903. /**
  109904. * Stop trailing mesh.
  109905. */
  109906. stop(): void;
  109907. /**
  109908. * Update trailing mesh geometry.
  109909. */
  109910. update(): void;
  109911. /**
  109912. * Returns a new TrailMesh object.
  109913. * @param name is a string, the name given to the new mesh
  109914. * @param newGenerator use new generator object for cloned trail mesh
  109915. * @returns a new mesh
  109916. */
  109917. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  109918. /**
  109919. * Serializes this trail mesh
  109920. * @param serializationObject object to write serialization to
  109921. */
  109922. serialize(serializationObject: any): void;
  109923. /**
  109924. * Parses a serialized trail mesh
  109925. * @param parsedMesh the serialized mesh
  109926. * @param scene the scene to create the trail mesh in
  109927. * @returns the created trail mesh
  109928. */
  109929. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  109930. }
  109931. }
  109932. declare module BABYLON {
  109933. /**
  109934. * Class containing static functions to help procedurally build meshes
  109935. */
  109936. export class TorusKnotBuilder {
  109937. /**
  109938. * Creates a torus knot mesh
  109939. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109940. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109941. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109942. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109946. * @param name defines the name of the mesh
  109947. * @param options defines the options used to create the mesh
  109948. * @param scene defines the hosting scene
  109949. * @returns the torus knot mesh
  109950. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109951. */
  109952. static CreateTorusKnot(name: string, options: {
  109953. radius?: number;
  109954. tube?: number;
  109955. radialSegments?: number;
  109956. tubularSegments?: number;
  109957. p?: number;
  109958. q?: number;
  109959. updatable?: boolean;
  109960. sideOrientation?: number;
  109961. frontUVs?: Vector4;
  109962. backUVs?: Vector4;
  109963. }, scene: any): Mesh;
  109964. }
  109965. }
  109966. declare module BABYLON {
  109967. /**
  109968. * Polygon
  109969. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109970. */
  109971. export class Polygon {
  109972. /**
  109973. * Creates a rectangle
  109974. * @param xmin bottom X coord
  109975. * @param ymin bottom Y coord
  109976. * @param xmax top X coord
  109977. * @param ymax top Y coord
  109978. * @returns points that make the resulting rectation
  109979. */
  109980. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  109981. /**
  109982. * Creates a circle
  109983. * @param radius radius of circle
  109984. * @param cx scale in x
  109985. * @param cy scale in y
  109986. * @param numberOfSides number of sides that make up the circle
  109987. * @returns points that make the resulting circle
  109988. */
  109989. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  109990. /**
  109991. * Creates a polygon from input string
  109992. * @param input Input polygon data
  109993. * @returns the parsed points
  109994. */
  109995. static Parse(input: string): Vector2[];
  109996. /**
  109997. * Starts building a polygon from x and y coordinates
  109998. * @param x x coordinate
  109999. * @param y y coordinate
  110000. * @returns the started path2
  110001. */
  110002. static StartingAt(x: number, y: number): Path2;
  110003. }
  110004. /**
  110005. * Builds a polygon
  110006. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  110007. */
  110008. export class PolygonMeshBuilder {
  110009. private _points;
  110010. private _outlinepoints;
  110011. private _holes;
  110012. private _name;
  110013. private _scene;
  110014. private _epoints;
  110015. private _eholes;
  110016. private _addToepoint;
  110017. /**
  110018. * Babylon reference to the earcut plugin.
  110019. */
  110020. bjsEarcut: any;
  110021. /**
  110022. * Creates a PolygonMeshBuilder
  110023. * @param name name of the builder
  110024. * @param contours Path of the polygon
  110025. * @param scene scene to add to when creating the mesh
  110026. * @param earcutInjection can be used to inject your own earcut reference
  110027. */
  110028. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  110029. /**
  110030. * Adds a whole within the polygon
  110031. * @param hole Array of points defining the hole
  110032. * @returns this
  110033. */
  110034. addHole(hole: Vector2[]): PolygonMeshBuilder;
  110035. /**
  110036. * Creates the polygon
  110037. * @param updatable If the mesh should be updatable
  110038. * @param depth The depth of the mesh created
  110039. * @returns the created mesh
  110040. */
  110041. build(updatable?: boolean, depth?: number): Mesh;
  110042. /**
  110043. * Creates the polygon
  110044. * @param depth The depth of the mesh created
  110045. * @returns the created VertexData
  110046. */
  110047. buildVertexData(depth?: number): VertexData;
  110048. /**
  110049. * Adds a side to the polygon
  110050. * @param positions points that make the polygon
  110051. * @param normals normals of the polygon
  110052. * @param uvs uvs of the polygon
  110053. * @param indices indices of the polygon
  110054. * @param bounds bounds of the polygon
  110055. * @param points points of the polygon
  110056. * @param depth depth of the polygon
  110057. * @param flip flip of the polygon
  110058. */
  110059. private addSide;
  110060. }
  110061. }
  110062. declare module BABYLON {
  110063. /**
  110064. * Class containing static functions to help procedurally build meshes
  110065. */
  110066. export class PolygonBuilder {
  110067. /**
  110068. * Creates a polygon mesh
  110069. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110070. * * 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
  110071. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110074. * * Remember you can only change the shape positions, not their number when updating a polygon
  110075. * @param name defines the name of the mesh
  110076. * @param options defines the options used to create the mesh
  110077. * @param scene defines the hosting scene
  110078. * @param earcutInjection can be used to inject your own earcut reference
  110079. * @returns the polygon mesh
  110080. */
  110081. static CreatePolygon(name: string, options: {
  110082. shape: Vector3[];
  110083. holes?: Vector3[][];
  110084. depth?: number;
  110085. faceUV?: Vector4[];
  110086. faceColors?: Color4[];
  110087. updatable?: boolean;
  110088. sideOrientation?: number;
  110089. frontUVs?: Vector4;
  110090. backUVs?: Vector4;
  110091. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110092. /**
  110093. * Creates an extruded polygon mesh, with depth in the Y direction.
  110094. * * 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)
  110095. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110096. * @param name defines the name of the mesh
  110097. * @param options defines the options used to create the mesh
  110098. * @param scene defines the hosting scene
  110099. * @param earcutInjection can be used to inject your own earcut reference
  110100. * @returns the polygon mesh
  110101. */
  110102. static ExtrudePolygon(name: string, options: {
  110103. shape: Vector3[];
  110104. holes?: Vector3[][];
  110105. depth?: number;
  110106. faceUV?: Vector4[];
  110107. faceColors?: Color4[];
  110108. updatable?: boolean;
  110109. sideOrientation?: number;
  110110. frontUVs?: Vector4;
  110111. backUVs?: Vector4;
  110112. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110113. }
  110114. }
  110115. declare module BABYLON {
  110116. /**
  110117. * Class containing static functions to help procedurally build meshes
  110118. */
  110119. export class LatheBuilder {
  110120. /**
  110121. * Creates lathe mesh.
  110122. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110123. * * 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
  110124. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110125. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110126. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110127. * * 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
  110128. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110129. * * 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
  110130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110132. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110134. * @param name defines the name of the mesh
  110135. * @param options defines the options used to create the mesh
  110136. * @param scene defines the hosting scene
  110137. * @returns the lathe mesh
  110138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110139. */
  110140. static CreateLathe(name: string, options: {
  110141. shape: Vector3[];
  110142. radius?: number;
  110143. tessellation?: number;
  110144. clip?: number;
  110145. arc?: number;
  110146. closed?: boolean;
  110147. updatable?: boolean;
  110148. sideOrientation?: number;
  110149. frontUVs?: Vector4;
  110150. backUVs?: Vector4;
  110151. cap?: number;
  110152. invertUV?: boolean;
  110153. }, scene?: Nullable<Scene>): Mesh;
  110154. }
  110155. }
  110156. declare module BABYLON {
  110157. /**
  110158. * Class containing static functions to help procedurally build meshes
  110159. */
  110160. export class TubeBuilder {
  110161. /**
  110162. * Creates a tube mesh.
  110163. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110164. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110165. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110166. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110167. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110168. * * 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)
  110169. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110170. * * 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
  110171. * * 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
  110172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110173. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110174. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110176. * @param name defines the name of the mesh
  110177. * @param options defines the options used to create the mesh
  110178. * @param scene defines the hosting scene
  110179. * @returns the tube mesh
  110180. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110181. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110182. */
  110183. static CreateTube(name: string, options: {
  110184. path: Vector3[];
  110185. radius?: number;
  110186. tessellation?: number;
  110187. radiusFunction?: {
  110188. (i: number, distance: number): number;
  110189. };
  110190. cap?: number;
  110191. arc?: number;
  110192. updatable?: boolean;
  110193. sideOrientation?: number;
  110194. frontUVs?: Vector4;
  110195. backUVs?: Vector4;
  110196. instance?: Mesh;
  110197. invertUV?: boolean;
  110198. }, scene?: Nullable<Scene>): Mesh;
  110199. }
  110200. }
  110201. declare module BABYLON {
  110202. /**
  110203. * Class containing static functions to help procedurally build meshes
  110204. */
  110205. export class IcoSphereBuilder {
  110206. /**
  110207. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110208. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110209. * * 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`)
  110210. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110211. * * 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
  110212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110215. * @param name defines the name of the mesh
  110216. * @param options defines the options used to create the mesh
  110217. * @param scene defines the hosting scene
  110218. * @returns the icosahedron mesh
  110219. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110220. */
  110221. static CreateIcoSphere(name: string, options: {
  110222. radius?: number;
  110223. radiusX?: number;
  110224. radiusY?: number;
  110225. radiusZ?: number;
  110226. flat?: boolean;
  110227. subdivisions?: number;
  110228. sideOrientation?: number;
  110229. frontUVs?: Vector4;
  110230. backUVs?: Vector4;
  110231. updatable?: boolean;
  110232. }, scene?: Nullable<Scene>): Mesh;
  110233. }
  110234. }
  110235. declare module BABYLON {
  110236. /**
  110237. * Class containing static functions to help procedurally build meshes
  110238. */
  110239. export class DecalBuilder {
  110240. /**
  110241. * Creates a decal mesh.
  110242. * 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
  110243. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110244. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110245. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110246. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110247. * @param name defines the name of the mesh
  110248. * @param sourceMesh defines the mesh where the decal must be applied
  110249. * @param options defines the options used to create the mesh
  110250. * @param scene defines the hosting scene
  110251. * @returns the decal mesh
  110252. * @see https://doc.babylonjs.com/how_to/decals
  110253. */
  110254. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110255. position?: Vector3;
  110256. normal?: Vector3;
  110257. size?: Vector3;
  110258. angle?: number;
  110259. }): Mesh;
  110260. }
  110261. }
  110262. declare module BABYLON {
  110263. /**
  110264. * Class containing static functions to help procedurally build meshes
  110265. */
  110266. export class MeshBuilder {
  110267. /**
  110268. * Creates a box mesh
  110269. * * The parameter `size` sets the size (float) of each box side (default 1)
  110270. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110271. * * 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)
  110272. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110276. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110277. * @param name defines the name of the mesh
  110278. * @param options defines the options used to create the mesh
  110279. * @param scene defines the hosting scene
  110280. * @returns the box mesh
  110281. */
  110282. static CreateBox(name: string, options: {
  110283. size?: number;
  110284. width?: number;
  110285. height?: number;
  110286. depth?: number;
  110287. faceUV?: Vector4[];
  110288. faceColors?: Color4[];
  110289. sideOrientation?: number;
  110290. frontUVs?: Vector4;
  110291. backUVs?: Vector4;
  110292. updatable?: boolean;
  110293. }, scene?: Nullable<Scene>): Mesh;
  110294. /**
  110295. * Creates a sphere mesh
  110296. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110297. * * 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`)
  110298. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110299. * * 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
  110300. * * 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)
  110301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110302. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110304. * @param name defines the name of the mesh
  110305. * @param options defines the options used to create the mesh
  110306. * @param scene defines the hosting scene
  110307. * @returns the sphere mesh
  110308. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110309. */
  110310. static CreateSphere(name: string, options: {
  110311. segments?: number;
  110312. diameter?: number;
  110313. diameterX?: number;
  110314. diameterY?: number;
  110315. diameterZ?: number;
  110316. arc?: number;
  110317. slice?: number;
  110318. sideOrientation?: number;
  110319. frontUVs?: Vector4;
  110320. backUVs?: Vector4;
  110321. updatable?: boolean;
  110322. }, scene?: Nullable<Scene>): Mesh;
  110323. /**
  110324. * Creates a plane polygonal mesh. By default, this is a disc
  110325. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110326. * * 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
  110327. * * 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
  110328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110331. * @param name defines the name of the mesh
  110332. * @param options defines the options used to create the mesh
  110333. * @param scene defines the hosting scene
  110334. * @returns the plane polygonal mesh
  110335. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110336. */
  110337. static CreateDisc(name: string, options: {
  110338. radius?: number;
  110339. tessellation?: number;
  110340. arc?: number;
  110341. updatable?: boolean;
  110342. sideOrientation?: number;
  110343. frontUVs?: Vector4;
  110344. backUVs?: Vector4;
  110345. }, scene?: Nullable<Scene>): Mesh;
  110346. /**
  110347. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110348. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110349. * * 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`)
  110350. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110351. * * 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
  110352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110355. * @param name defines the name of the mesh
  110356. * @param options defines the options used to create the mesh
  110357. * @param scene defines the hosting scene
  110358. * @returns the icosahedron mesh
  110359. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110360. */
  110361. static CreateIcoSphere(name: string, options: {
  110362. radius?: number;
  110363. radiusX?: number;
  110364. radiusY?: number;
  110365. radiusZ?: number;
  110366. flat?: boolean;
  110367. subdivisions?: number;
  110368. sideOrientation?: number;
  110369. frontUVs?: Vector4;
  110370. backUVs?: Vector4;
  110371. updatable?: boolean;
  110372. }, scene?: Nullable<Scene>): Mesh;
  110373. /**
  110374. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110375. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  110376. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  110377. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  110378. * * 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
  110379. * * 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
  110380. * * 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
  110381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110383. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110384. * * 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
  110385. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  110386. * * 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
  110387. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  110388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110389. * @param name defines the name of the mesh
  110390. * @param options defines the options used to create the mesh
  110391. * @param scene defines the hosting scene
  110392. * @returns the ribbon mesh
  110393. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  110394. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110395. */
  110396. static CreateRibbon(name: string, options: {
  110397. pathArray: Vector3[][];
  110398. closeArray?: boolean;
  110399. closePath?: boolean;
  110400. offset?: number;
  110401. updatable?: boolean;
  110402. sideOrientation?: number;
  110403. frontUVs?: Vector4;
  110404. backUVs?: Vector4;
  110405. instance?: Mesh;
  110406. invertUV?: boolean;
  110407. uvs?: Vector2[];
  110408. colors?: Color4[];
  110409. }, scene?: Nullable<Scene>): Mesh;
  110410. /**
  110411. * Creates a cylinder or a cone mesh
  110412. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110413. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110414. * * 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.
  110415. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110416. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110417. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110418. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110419. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110420. * * 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).
  110421. * * 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
  110422. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110423. * * 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
  110424. * * 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.
  110425. * * If `enclose` is false, a ring surface is one element.
  110426. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110427. * * 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
  110428. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110429. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110431. * @param name defines the name of the mesh
  110432. * @param options defines the options used to create the mesh
  110433. * @param scene defines the hosting scene
  110434. * @returns the cylinder mesh
  110435. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110436. */
  110437. static CreateCylinder(name: string, options: {
  110438. height?: number;
  110439. diameterTop?: number;
  110440. diameterBottom?: number;
  110441. diameter?: number;
  110442. tessellation?: number;
  110443. subdivisions?: number;
  110444. arc?: number;
  110445. faceColors?: Color4[];
  110446. faceUV?: Vector4[];
  110447. updatable?: boolean;
  110448. hasRings?: boolean;
  110449. enclose?: boolean;
  110450. sideOrientation?: number;
  110451. frontUVs?: Vector4;
  110452. backUVs?: Vector4;
  110453. }, scene?: Nullable<Scene>): Mesh;
  110454. /**
  110455. * Creates a torus mesh
  110456. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110457. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110458. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110462. * @param name defines the name of the mesh
  110463. * @param options defines the options used to create the mesh
  110464. * @param scene defines the hosting scene
  110465. * @returns the torus mesh
  110466. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110467. */
  110468. static CreateTorus(name: string, options: {
  110469. diameter?: number;
  110470. thickness?: number;
  110471. tessellation?: number;
  110472. updatable?: boolean;
  110473. sideOrientation?: number;
  110474. frontUVs?: Vector4;
  110475. backUVs?: Vector4;
  110476. }, scene?: Nullable<Scene>): Mesh;
  110477. /**
  110478. * Creates a torus knot mesh
  110479. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  110480. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  110481. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  110482. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  110483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110484. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110486. * @param name defines the name of the mesh
  110487. * @param options defines the options used to create the mesh
  110488. * @param scene defines the hosting scene
  110489. * @returns the torus knot mesh
  110490. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  110491. */
  110492. static CreateTorusKnot(name: string, options: {
  110493. radius?: number;
  110494. tube?: number;
  110495. radialSegments?: number;
  110496. tubularSegments?: number;
  110497. p?: number;
  110498. q?: number;
  110499. updatable?: boolean;
  110500. sideOrientation?: number;
  110501. frontUVs?: Vector4;
  110502. backUVs?: Vector4;
  110503. }, scene?: Nullable<Scene>): Mesh;
  110504. /**
  110505. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110506. * * 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
  110507. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110508. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110509. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110510. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110511. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110512. * * 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
  110513. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110515. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110516. * @param name defines the name of the new line system
  110517. * @param options defines the options used to create the line system
  110518. * @param scene defines the hosting scene
  110519. * @returns a new line system mesh
  110520. */
  110521. static CreateLineSystem(name: string, options: {
  110522. lines: Vector3[][];
  110523. updatable?: boolean;
  110524. instance?: Nullable<LinesMesh>;
  110525. colors?: Nullable<Color4[][]>;
  110526. useVertexAlpha?: boolean;
  110527. }, scene: Nullable<Scene>): LinesMesh;
  110528. /**
  110529. * Creates a line mesh
  110530. * 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
  110531. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110532. * * The parameter `points` is an array successive Vector3
  110533. * * 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
  110534. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110535. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110536. * * When updating an instance, remember that only point positions can change, not the number of points
  110537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110538. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110539. * @param name defines the name of the new line system
  110540. * @param options defines the options used to create the line system
  110541. * @param scene defines the hosting scene
  110542. * @returns a new line mesh
  110543. */
  110544. static CreateLines(name: string, options: {
  110545. points: Vector3[];
  110546. updatable?: boolean;
  110547. instance?: Nullable<LinesMesh>;
  110548. colors?: Color4[];
  110549. useVertexAlpha?: boolean;
  110550. }, scene?: Nullable<Scene>): LinesMesh;
  110551. /**
  110552. * Creates a dashed line mesh
  110553. * * 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
  110554. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110555. * * The parameter `points` is an array successive Vector3
  110556. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110557. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110558. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110559. * * 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
  110560. * * When updating an instance, remember that only point positions can change, not the number of points
  110561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110562. * @param name defines the name of the mesh
  110563. * @param options defines the options used to create the mesh
  110564. * @param scene defines the hosting scene
  110565. * @returns the dashed line mesh
  110566. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110567. */
  110568. static CreateDashedLines(name: string, options: {
  110569. points: Vector3[];
  110570. dashSize?: number;
  110571. gapSize?: number;
  110572. dashNb?: number;
  110573. updatable?: boolean;
  110574. instance?: LinesMesh;
  110575. }, scene?: Nullable<Scene>): LinesMesh;
  110576. /**
  110577. * 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.
  110578. * * 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.
  110579. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110580. * * 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.
  110581. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  110582. * * 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
  110583. * * 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
  110584. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  110585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110586. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110587. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  110588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110589. * @param name defines the name of the mesh
  110590. * @param options defines the options used to create the mesh
  110591. * @param scene defines the hosting scene
  110592. * @returns the extruded shape mesh
  110593. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110594. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110595. */
  110596. static ExtrudeShape(name: string, options: {
  110597. shape: Vector3[];
  110598. path: Vector3[];
  110599. scale?: number;
  110600. rotation?: number;
  110601. cap?: number;
  110602. updatable?: boolean;
  110603. sideOrientation?: number;
  110604. frontUVs?: Vector4;
  110605. backUVs?: Vector4;
  110606. instance?: Mesh;
  110607. invertUV?: boolean;
  110608. }, scene?: Nullable<Scene>): Mesh;
  110609. /**
  110610. * Creates an custom extruded shape mesh.
  110611. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110612. * * 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.
  110613. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110614. * * 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
  110615. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  110616. * * 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
  110617. * * It must returns a float value that will be the scale value applied to the shape on each path point
  110618. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  110619. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  110620. * * 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
  110621. * * 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
  110622. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  110623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110624. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110625. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110627. * @param name defines the name of the mesh
  110628. * @param options defines the options used to create the mesh
  110629. * @param scene defines the hosting scene
  110630. * @returns the custom extruded shape mesh
  110631. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  110632. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110633. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110634. */
  110635. static ExtrudeShapeCustom(name: string, options: {
  110636. shape: Vector3[];
  110637. path: Vector3[];
  110638. scaleFunction?: any;
  110639. rotationFunction?: any;
  110640. ribbonCloseArray?: boolean;
  110641. ribbonClosePath?: boolean;
  110642. cap?: number;
  110643. updatable?: boolean;
  110644. sideOrientation?: number;
  110645. frontUVs?: Vector4;
  110646. backUVs?: Vector4;
  110647. instance?: Mesh;
  110648. invertUV?: boolean;
  110649. }, scene?: Nullable<Scene>): Mesh;
  110650. /**
  110651. * Creates lathe mesh.
  110652. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110653. * * 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
  110654. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110655. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110656. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110657. * * 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
  110658. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110659. * * 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
  110660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110662. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110664. * @param name defines the name of the mesh
  110665. * @param options defines the options used to create the mesh
  110666. * @param scene defines the hosting scene
  110667. * @returns the lathe mesh
  110668. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110669. */
  110670. static CreateLathe(name: string, options: {
  110671. shape: Vector3[];
  110672. radius?: number;
  110673. tessellation?: number;
  110674. clip?: number;
  110675. arc?: number;
  110676. closed?: boolean;
  110677. updatable?: boolean;
  110678. sideOrientation?: number;
  110679. frontUVs?: Vector4;
  110680. backUVs?: Vector4;
  110681. cap?: number;
  110682. invertUV?: boolean;
  110683. }, scene?: Nullable<Scene>): Mesh;
  110684. /**
  110685. * Creates a plane mesh
  110686. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110687. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110688. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110692. * @param name defines the name of the mesh
  110693. * @param options defines the options used to create the mesh
  110694. * @param scene defines the hosting scene
  110695. * @returns the plane mesh
  110696. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110697. */
  110698. static CreatePlane(name: string, options: {
  110699. size?: number;
  110700. width?: number;
  110701. height?: number;
  110702. sideOrientation?: number;
  110703. frontUVs?: Vector4;
  110704. backUVs?: Vector4;
  110705. updatable?: boolean;
  110706. sourcePlane?: Plane;
  110707. }, scene?: Nullable<Scene>): Mesh;
  110708. /**
  110709. * Creates a ground mesh
  110710. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110711. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110713. * @param name defines the name of the mesh
  110714. * @param options defines the options used to create the mesh
  110715. * @param scene defines the hosting scene
  110716. * @returns the ground mesh
  110717. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110718. */
  110719. static CreateGround(name: string, options: {
  110720. width?: number;
  110721. height?: number;
  110722. subdivisions?: number;
  110723. subdivisionsX?: number;
  110724. subdivisionsY?: number;
  110725. updatable?: boolean;
  110726. }, scene?: Nullable<Scene>): Mesh;
  110727. /**
  110728. * Creates a tiled ground mesh
  110729. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110730. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110731. * * 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
  110732. * * 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
  110733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110734. * @param name defines the name of the mesh
  110735. * @param options defines the options used to create the mesh
  110736. * @param scene defines the hosting scene
  110737. * @returns the tiled ground mesh
  110738. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110739. */
  110740. static CreateTiledGround(name: string, options: {
  110741. xmin: number;
  110742. zmin: number;
  110743. xmax: number;
  110744. zmax: number;
  110745. subdivisions?: {
  110746. w: number;
  110747. h: number;
  110748. };
  110749. precision?: {
  110750. w: number;
  110751. h: number;
  110752. };
  110753. updatable?: boolean;
  110754. }, scene?: Nullable<Scene>): Mesh;
  110755. /**
  110756. * Creates a ground mesh from a height map
  110757. * * The parameter `url` sets the URL of the height map image resource.
  110758. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110759. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110760. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110761. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110762. * * 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.
  110763. * * 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).
  110764. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110766. * @param name defines the name of the mesh
  110767. * @param url defines the url to the height map
  110768. * @param options defines the options used to create the mesh
  110769. * @param scene defines the hosting scene
  110770. * @returns the ground mesh
  110771. * @see https://doc.babylonjs.com/babylon101/height_map
  110772. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110773. */
  110774. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110775. width?: number;
  110776. height?: number;
  110777. subdivisions?: number;
  110778. minHeight?: number;
  110779. maxHeight?: number;
  110780. colorFilter?: Color3;
  110781. alphaFilter?: number;
  110782. updatable?: boolean;
  110783. onReady?: (mesh: GroundMesh) => void;
  110784. }, scene?: Nullable<Scene>): GroundMesh;
  110785. /**
  110786. * Creates a polygon mesh
  110787. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110788. * * 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
  110789. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110792. * * Remember you can only change the shape positions, not their number when updating a polygon
  110793. * @param name defines the name of the mesh
  110794. * @param options defines the options used to create the mesh
  110795. * @param scene defines the hosting scene
  110796. * @param earcutInjection can be used to inject your own earcut reference
  110797. * @returns the polygon mesh
  110798. */
  110799. static CreatePolygon(name: string, options: {
  110800. shape: Vector3[];
  110801. holes?: Vector3[][];
  110802. depth?: number;
  110803. faceUV?: Vector4[];
  110804. faceColors?: Color4[];
  110805. updatable?: boolean;
  110806. sideOrientation?: number;
  110807. frontUVs?: Vector4;
  110808. backUVs?: Vector4;
  110809. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110810. /**
  110811. * Creates an extruded polygon mesh, with depth in the Y direction.
  110812. * * 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)
  110813. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110814. * @param name defines the name of the mesh
  110815. * @param options defines the options used to create the mesh
  110816. * @param scene defines the hosting scene
  110817. * @param earcutInjection can be used to inject your own earcut reference
  110818. * @returns the polygon mesh
  110819. */
  110820. static ExtrudePolygon(name: string, options: {
  110821. shape: Vector3[];
  110822. holes?: Vector3[][];
  110823. depth?: number;
  110824. faceUV?: Vector4[];
  110825. faceColors?: Color4[];
  110826. updatable?: boolean;
  110827. sideOrientation?: number;
  110828. frontUVs?: Vector4;
  110829. backUVs?: Vector4;
  110830. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110831. /**
  110832. * Creates a tube mesh.
  110833. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110834. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110835. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110836. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110837. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110838. * * 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)
  110839. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110840. * * 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
  110841. * * 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
  110842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110843. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110844. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110846. * @param name defines the name of the mesh
  110847. * @param options defines the options used to create the mesh
  110848. * @param scene defines the hosting scene
  110849. * @returns the tube mesh
  110850. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110851. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110852. */
  110853. static CreateTube(name: string, options: {
  110854. path: Vector3[];
  110855. radius?: number;
  110856. tessellation?: number;
  110857. radiusFunction?: {
  110858. (i: number, distance: number): number;
  110859. };
  110860. cap?: number;
  110861. arc?: number;
  110862. updatable?: boolean;
  110863. sideOrientation?: number;
  110864. frontUVs?: Vector4;
  110865. backUVs?: Vector4;
  110866. instance?: Mesh;
  110867. invertUV?: boolean;
  110868. }, scene?: Nullable<Scene>): Mesh;
  110869. /**
  110870. * Creates a polyhedron mesh
  110871. * * 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
  110872. * * The parameter `size` (positive float, default 1) sets the polygon size
  110873. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110874. * * 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`
  110875. * * 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
  110876. * * 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)`)
  110877. * * 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
  110878. * * 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
  110879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110882. * @param name defines the name of the mesh
  110883. * @param options defines the options used to create the mesh
  110884. * @param scene defines the hosting scene
  110885. * @returns the polyhedron mesh
  110886. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110887. */
  110888. static CreatePolyhedron(name: string, options: {
  110889. type?: number;
  110890. size?: number;
  110891. sizeX?: number;
  110892. sizeY?: number;
  110893. sizeZ?: number;
  110894. custom?: any;
  110895. faceUV?: Vector4[];
  110896. faceColors?: Color4[];
  110897. flat?: boolean;
  110898. updatable?: boolean;
  110899. sideOrientation?: number;
  110900. frontUVs?: Vector4;
  110901. backUVs?: Vector4;
  110902. }, scene?: Nullable<Scene>): Mesh;
  110903. /**
  110904. * Creates a decal mesh.
  110905. * 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
  110906. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110907. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110908. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110909. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110910. * @param name defines the name of the mesh
  110911. * @param sourceMesh defines the mesh where the decal must be applied
  110912. * @param options defines the options used to create the mesh
  110913. * @param scene defines the hosting scene
  110914. * @returns the decal mesh
  110915. * @see https://doc.babylonjs.com/how_to/decals
  110916. */
  110917. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110918. position?: Vector3;
  110919. normal?: Vector3;
  110920. size?: Vector3;
  110921. angle?: number;
  110922. }): Mesh;
  110923. }
  110924. }
  110925. declare module BABYLON {
  110926. /**
  110927. * A simplifier interface for future simplification implementations
  110928. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110929. */
  110930. export interface ISimplifier {
  110931. /**
  110932. * Simplification of a given mesh according to the given settings.
  110933. * Since this requires computation, it is assumed that the function runs async.
  110934. * @param settings The settings of the simplification, including quality and distance
  110935. * @param successCallback A callback that will be called after the mesh was simplified.
  110936. * @param errorCallback in case of an error, this callback will be called. optional.
  110937. */
  110938. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  110939. }
  110940. /**
  110941. * Expected simplification settings.
  110942. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  110943. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110944. */
  110945. export interface ISimplificationSettings {
  110946. /**
  110947. * Gets or sets the expected quality
  110948. */
  110949. quality: number;
  110950. /**
  110951. * Gets or sets the distance when this optimized version should be used
  110952. */
  110953. distance: number;
  110954. /**
  110955. * Gets an already optimized mesh
  110956. */
  110957. optimizeMesh?: boolean;
  110958. }
  110959. /**
  110960. * Class used to specify simplification options
  110961. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110962. */
  110963. export class SimplificationSettings implements ISimplificationSettings {
  110964. /** expected quality */
  110965. quality: number;
  110966. /** distance when this optimized version should be used */
  110967. distance: number;
  110968. /** already optimized mesh */
  110969. optimizeMesh?: boolean | undefined;
  110970. /**
  110971. * Creates a SimplificationSettings
  110972. * @param quality expected quality
  110973. * @param distance distance when this optimized version should be used
  110974. * @param optimizeMesh already optimized mesh
  110975. */
  110976. constructor(
  110977. /** expected quality */
  110978. quality: number,
  110979. /** distance when this optimized version should be used */
  110980. distance: number,
  110981. /** already optimized mesh */
  110982. optimizeMesh?: boolean | undefined);
  110983. }
  110984. /**
  110985. * Interface used to define a simplification task
  110986. */
  110987. export interface ISimplificationTask {
  110988. /**
  110989. * Array of settings
  110990. */
  110991. settings: Array<ISimplificationSettings>;
  110992. /**
  110993. * Simplification type
  110994. */
  110995. simplificationType: SimplificationType;
  110996. /**
  110997. * Mesh to simplify
  110998. */
  110999. mesh: Mesh;
  111000. /**
  111001. * Callback called on success
  111002. */
  111003. successCallback?: () => void;
  111004. /**
  111005. * Defines if parallel processing can be used
  111006. */
  111007. parallelProcessing: boolean;
  111008. }
  111009. /**
  111010. * Queue used to order the simplification tasks
  111011. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111012. */
  111013. export class SimplificationQueue {
  111014. private _simplificationArray;
  111015. /**
  111016. * Gets a boolean indicating that the process is still running
  111017. */
  111018. running: boolean;
  111019. /**
  111020. * Creates a new queue
  111021. */
  111022. constructor();
  111023. /**
  111024. * Adds a new simplification task
  111025. * @param task defines a task to add
  111026. */
  111027. addTask(task: ISimplificationTask): void;
  111028. /**
  111029. * Execute next task
  111030. */
  111031. executeNext(): void;
  111032. /**
  111033. * Execute a simplification task
  111034. * @param task defines the task to run
  111035. */
  111036. runSimplification(task: ISimplificationTask): void;
  111037. private getSimplifier;
  111038. }
  111039. /**
  111040. * The implemented types of simplification
  111041. * At the moment only Quadratic Error Decimation is implemented
  111042. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111043. */
  111044. export enum SimplificationType {
  111045. /** Quadratic error decimation */
  111046. QUADRATIC = 0
  111047. }
  111048. }
  111049. declare module BABYLON {
  111050. interface Scene {
  111051. /** @hidden (Backing field) */
  111052. _simplificationQueue: SimplificationQueue;
  111053. /**
  111054. * Gets or sets the simplification queue attached to the scene
  111055. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111056. */
  111057. simplificationQueue: SimplificationQueue;
  111058. }
  111059. interface Mesh {
  111060. /**
  111061. * Simplify the mesh according to the given array of settings.
  111062. * Function will return immediately and will simplify async
  111063. * @param settings a collection of simplification settings
  111064. * @param parallelProcessing should all levels calculate parallel or one after the other
  111065. * @param simplificationType the type of simplification to run
  111066. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  111067. * @returns the current mesh
  111068. */
  111069. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  111070. }
  111071. /**
  111072. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  111073. * created in a scene
  111074. */
  111075. export class SimplicationQueueSceneComponent implements ISceneComponent {
  111076. /**
  111077. * The component name helpfull to identify the component in the list of scene components.
  111078. */
  111079. readonly name: string;
  111080. /**
  111081. * The scene the component belongs to.
  111082. */
  111083. scene: Scene;
  111084. /**
  111085. * Creates a new instance of the component for the given scene
  111086. * @param scene Defines the scene to register the component in
  111087. */
  111088. constructor(scene: Scene);
  111089. /**
  111090. * Registers the component in a given scene
  111091. */
  111092. register(): void;
  111093. /**
  111094. * Rebuilds the elements related to this component in case of
  111095. * context lost for instance.
  111096. */
  111097. rebuild(): void;
  111098. /**
  111099. * Disposes the component and the associated ressources
  111100. */
  111101. dispose(): void;
  111102. private _beforeCameraUpdate;
  111103. }
  111104. }
  111105. declare module BABYLON {
  111106. /**
  111107. * Class used to enable access to IndexedDB
  111108. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  111109. */
  111110. export class Database implements IOfflineProvider {
  111111. private _callbackManifestChecked;
  111112. private _currentSceneUrl;
  111113. private _db;
  111114. private _enableSceneOffline;
  111115. private _enableTexturesOffline;
  111116. private _manifestVersionFound;
  111117. private _mustUpdateRessources;
  111118. private _hasReachedQuota;
  111119. private _isSupported;
  111120. private _idbFactory;
  111121. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  111122. private static IsUASupportingBlobStorage;
  111123. /**
  111124. * Gets a boolean indicating if Database storate is enabled (off by default)
  111125. */
  111126. static IDBStorageEnabled: boolean;
  111127. /**
  111128. * Gets a boolean indicating if scene must be saved in the database
  111129. */
  111130. readonly enableSceneOffline: boolean;
  111131. /**
  111132. * Gets a boolean indicating if textures must be saved in the database
  111133. */
  111134. readonly enableTexturesOffline: boolean;
  111135. /**
  111136. * Creates a new Database
  111137. * @param urlToScene defines the url to load the scene
  111138. * @param callbackManifestChecked defines the callback to use when manifest is checked
  111139. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  111140. */
  111141. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  111142. private static _ParseURL;
  111143. private static _ReturnFullUrlLocation;
  111144. private _checkManifestFile;
  111145. /**
  111146. * Open the database and make it available
  111147. * @param successCallback defines the callback to call on success
  111148. * @param errorCallback defines the callback to call on error
  111149. */
  111150. open(successCallback: () => void, errorCallback: () => void): void;
  111151. /**
  111152. * Loads an image from the database
  111153. * @param url defines the url to load from
  111154. * @param image defines the target DOM image
  111155. */
  111156. loadImage(url: string, image: HTMLImageElement): void;
  111157. private _loadImageFromDBAsync;
  111158. private _saveImageIntoDBAsync;
  111159. private _checkVersionFromDB;
  111160. private _loadVersionFromDBAsync;
  111161. private _saveVersionIntoDBAsync;
  111162. /**
  111163. * Loads a file from database
  111164. * @param url defines the URL to load from
  111165. * @param sceneLoaded defines a callback to call on success
  111166. * @param progressCallBack defines a callback to call when progress changed
  111167. * @param errorCallback defines a callback to call on error
  111168. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  111169. */
  111170. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  111171. private _loadFileAsync;
  111172. private _saveFileAsync;
  111173. /**
  111174. * Validates if xhr data is correct
  111175. * @param xhr defines the request to validate
  111176. * @param dataType defines the expected data type
  111177. * @returns true if data is correct
  111178. */
  111179. private static _ValidateXHRData;
  111180. }
  111181. }
  111182. declare module BABYLON {
  111183. /** @hidden */
  111184. export var gpuUpdateParticlesPixelShader: {
  111185. name: string;
  111186. shader: string;
  111187. };
  111188. }
  111189. declare module BABYLON {
  111190. /** @hidden */
  111191. export var gpuUpdateParticlesVertexShader: {
  111192. name: string;
  111193. shader: string;
  111194. };
  111195. }
  111196. declare module BABYLON {
  111197. /** @hidden */
  111198. export var clipPlaneFragmentDeclaration2: {
  111199. name: string;
  111200. shader: string;
  111201. };
  111202. }
  111203. declare module BABYLON {
  111204. /** @hidden */
  111205. export var gpuRenderParticlesPixelShader: {
  111206. name: string;
  111207. shader: string;
  111208. };
  111209. }
  111210. declare module BABYLON {
  111211. /** @hidden */
  111212. export var clipPlaneVertexDeclaration2: {
  111213. name: string;
  111214. shader: string;
  111215. };
  111216. }
  111217. declare module BABYLON {
  111218. /** @hidden */
  111219. export var gpuRenderParticlesVertexShader: {
  111220. name: string;
  111221. shader: string;
  111222. };
  111223. }
  111224. declare module BABYLON {
  111225. /**
  111226. * This represents a GPU particle system in Babylon
  111227. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  111228. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  111229. */
  111230. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  111231. /**
  111232. * The layer mask we are rendering the particles through.
  111233. */
  111234. layerMask: number;
  111235. private _capacity;
  111236. private _activeCount;
  111237. private _currentActiveCount;
  111238. private _accumulatedCount;
  111239. private _renderEffect;
  111240. private _updateEffect;
  111241. private _buffer0;
  111242. private _buffer1;
  111243. private _spriteBuffer;
  111244. private _updateVAO;
  111245. private _renderVAO;
  111246. private _targetIndex;
  111247. private _sourceBuffer;
  111248. private _targetBuffer;
  111249. private _engine;
  111250. private _currentRenderId;
  111251. private _started;
  111252. private _stopped;
  111253. private _timeDelta;
  111254. private _randomTexture;
  111255. private _randomTexture2;
  111256. private _attributesStrideSize;
  111257. private _updateEffectOptions;
  111258. private _randomTextureSize;
  111259. private _actualFrame;
  111260. private readonly _rawTextureWidth;
  111261. /**
  111262. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  111263. */
  111264. static readonly IsSupported: boolean;
  111265. /**
  111266. * An event triggered when the system is disposed.
  111267. */
  111268. onDisposeObservable: Observable<GPUParticleSystem>;
  111269. /**
  111270. * Gets the maximum number of particles active at the same time.
  111271. * @returns The max number of active particles.
  111272. */
  111273. getCapacity(): number;
  111274. /**
  111275. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  111276. * to override the particles.
  111277. */
  111278. forceDepthWrite: boolean;
  111279. /**
  111280. * Gets or set the number of active particles
  111281. */
  111282. activeParticleCount: number;
  111283. private _preWarmDone;
  111284. /**
  111285. * Is this system ready to be used/rendered
  111286. * @return true if the system is ready
  111287. */
  111288. isReady(): boolean;
  111289. /**
  111290. * Gets if the system has been started. (Note: this will still be true after stop is called)
  111291. * @returns True if it has been started, otherwise false.
  111292. */
  111293. isStarted(): boolean;
  111294. /**
  111295. * Starts the particle system and begins to emit
  111296. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  111297. */
  111298. start(delay?: number): void;
  111299. /**
  111300. * Stops the particle system.
  111301. */
  111302. stop(): void;
  111303. /**
  111304. * Remove all active particles
  111305. */
  111306. reset(): void;
  111307. /**
  111308. * Returns the string "GPUParticleSystem"
  111309. * @returns a string containing the class name
  111310. */
  111311. getClassName(): string;
  111312. private _colorGradientsTexture;
  111313. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  111314. /**
  111315. * Adds a new color gradient
  111316. * @param gradient defines the gradient to use (between 0 and 1)
  111317. * @param color1 defines the color to affect to the specified gradient
  111318. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  111319. * @returns the current particle system
  111320. */
  111321. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  111322. /**
  111323. * Remove a specific color gradient
  111324. * @param gradient defines the gradient to remove
  111325. * @returns the current particle system
  111326. */
  111327. removeColorGradient(gradient: number): GPUParticleSystem;
  111328. private _angularSpeedGradientsTexture;
  111329. private _sizeGradientsTexture;
  111330. private _velocityGradientsTexture;
  111331. private _limitVelocityGradientsTexture;
  111332. private _dragGradientsTexture;
  111333. private _addFactorGradient;
  111334. /**
  111335. * Adds a new size gradient
  111336. * @param gradient defines the gradient to use (between 0 and 1)
  111337. * @param factor defines the size factor to affect to the specified gradient
  111338. * @returns the current particle system
  111339. */
  111340. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  111341. /**
  111342. * Remove a specific size gradient
  111343. * @param gradient defines the gradient to remove
  111344. * @returns the current particle system
  111345. */
  111346. removeSizeGradient(gradient: number): GPUParticleSystem;
  111347. /**
  111348. * Adds a new angular speed gradient
  111349. * @param gradient defines the gradient to use (between 0 and 1)
  111350. * @param factor defines the angular speed to affect to the specified gradient
  111351. * @returns the current particle system
  111352. */
  111353. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  111354. /**
  111355. * Remove a specific angular speed gradient
  111356. * @param gradient defines the gradient to remove
  111357. * @returns the current particle system
  111358. */
  111359. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  111360. /**
  111361. * Adds a new velocity gradient
  111362. * @param gradient defines the gradient to use (between 0 and 1)
  111363. * @param factor defines the velocity to affect to the specified gradient
  111364. * @returns the current particle system
  111365. */
  111366. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111367. /**
  111368. * Remove a specific velocity gradient
  111369. * @param gradient defines the gradient to remove
  111370. * @returns the current particle system
  111371. */
  111372. removeVelocityGradient(gradient: number): GPUParticleSystem;
  111373. /**
  111374. * Adds a new limit velocity gradient
  111375. * @param gradient defines the gradient to use (between 0 and 1)
  111376. * @param factor defines the limit velocity value to affect to the specified gradient
  111377. * @returns the current particle system
  111378. */
  111379. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111380. /**
  111381. * Remove a specific limit velocity gradient
  111382. * @param gradient defines the gradient to remove
  111383. * @returns the current particle system
  111384. */
  111385. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  111386. /**
  111387. * Adds a new drag gradient
  111388. * @param gradient defines the gradient to use (between 0 and 1)
  111389. * @param factor defines the drag value to affect to the specified gradient
  111390. * @returns the current particle system
  111391. */
  111392. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  111393. /**
  111394. * Remove a specific drag gradient
  111395. * @param gradient defines the gradient to remove
  111396. * @returns the current particle system
  111397. */
  111398. removeDragGradient(gradient: number): GPUParticleSystem;
  111399. /**
  111400. * Not supported by GPUParticleSystem
  111401. * @param gradient defines the gradient to use (between 0 and 1)
  111402. * @param factor defines the emit rate value to affect to the specified gradient
  111403. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111404. * @returns the current particle system
  111405. */
  111406. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111407. /**
  111408. * Not supported by GPUParticleSystem
  111409. * @param gradient defines the gradient to remove
  111410. * @returns the current particle system
  111411. */
  111412. removeEmitRateGradient(gradient: number): IParticleSystem;
  111413. /**
  111414. * Not supported by GPUParticleSystem
  111415. * @param gradient defines the gradient to use (between 0 and 1)
  111416. * @param factor defines the start size value to affect to the specified gradient
  111417. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111418. * @returns the current particle system
  111419. */
  111420. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111421. /**
  111422. * Not supported by GPUParticleSystem
  111423. * @param gradient defines the gradient to remove
  111424. * @returns the current particle system
  111425. */
  111426. removeStartSizeGradient(gradient: number): IParticleSystem;
  111427. /**
  111428. * Not supported by GPUParticleSystem
  111429. * @param gradient defines the gradient to use (between 0 and 1)
  111430. * @param min defines the color remap minimal range
  111431. * @param max defines the color remap maximal range
  111432. * @returns the current particle system
  111433. */
  111434. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111435. /**
  111436. * Not supported by GPUParticleSystem
  111437. * @param gradient defines the gradient to remove
  111438. * @returns the current particle system
  111439. */
  111440. removeColorRemapGradient(): IParticleSystem;
  111441. /**
  111442. * Not supported by GPUParticleSystem
  111443. * @param gradient defines the gradient to use (between 0 and 1)
  111444. * @param min defines the alpha remap minimal range
  111445. * @param max defines the alpha remap maximal range
  111446. * @returns the current particle system
  111447. */
  111448. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111449. /**
  111450. * Not supported by GPUParticleSystem
  111451. * @param gradient defines the gradient to remove
  111452. * @returns the current particle system
  111453. */
  111454. removeAlphaRemapGradient(): IParticleSystem;
  111455. /**
  111456. * Not supported by GPUParticleSystem
  111457. * @param gradient defines the gradient to use (between 0 and 1)
  111458. * @param color defines the color to affect to the specified gradient
  111459. * @returns the current particle system
  111460. */
  111461. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  111462. /**
  111463. * Not supported by GPUParticleSystem
  111464. * @param gradient defines the gradient to remove
  111465. * @returns the current particle system
  111466. */
  111467. removeRampGradient(): IParticleSystem;
  111468. /**
  111469. * Not supported by GPUParticleSystem
  111470. * @returns the list of ramp gradients
  111471. */
  111472. getRampGradients(): Nullable<Array<Color3Gradient>>;
  111473. /**
  111474. * Not supported by GPUParticleSystem
  111475. * Gets or sets a boolean indicating that ramp gradients must be used
  111476. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  111477. */
  111478. useRampGradients: boolean;
  111479. /**
  111480. * Not supported by GPUParticleSystem
  111481. * @param gradient defines the gradient to use (between 0 and 1)
  111482. * @param factor defines the life time factor to affect to the specified gradient
  111483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111484. * @returns the current particle system
  111485. */
  111486. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111487. /**
  111488. * Not supported by GPUParticleSystem
  111489. * @param gradient defines the gradient to remove
  111490. * @returns the current particle system
  111491. */
  111492. removeLifeTimeGradient(gradient: number): IParticleSystem;
  111493. /**
  111494. * Instantiates a GPU particle system.
  111495. * 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.
  111496. * @param name The name of the particle system
  111497. * @param options The options used to create the system
  111498. * @param scene The scene the particle system belongs to
  111499. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  111500. */
  111501. constructor(name: string, options: Partial<{
  111502. capacity: number;
  111503. randomTextureSize: number;
  111504. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  111505. protected _reset(): void;
  111506. private _createUpdateVAO;
  111507. private _createRenderVAO;
  111508. private _initialize;
  111509. /** @hidden */
  111510. _recreateUpdateEffect(): void;
  111511. /** @hidden */
  111512. _recreateRenderEffect(): void;
  111513. /**
  111514. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111515. * @param preWarm defines if we are in the pre-warmimg phase
  111516. */
  111517. animate(preWarm?: boolean): void;
  111518. private _createFactorGradientTexture;
  111519. private _createSizeGradientTexture;
  111520. private _createAngularSpeedGradientTexture;
  111521. private _createVelocityGradientTexture;
  111522. private _createLimitVelocityGradientTexture;
  111523. private _createDragGradientTexture;
  111524. private _createColorGradientTexture;
  111525. /**
  111526. * Renders the particle system in its current state
  111527. * @param preWarm defines if the system should only update the particles but not render them
  111528. * @returns the current number of particles
  111529. */
  111530. render(preWarm?: boolean): number;
  111531. /**
  111532. * Rebuilds the particle system
  111533. */
  111534. rebuild(): void;
  111535. private _releaseBuffers;
  111536. private _releaseVAOs;
  111537. /**
  111538. * Disposes the particle system and free the associated resources
  111539. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111540. */
  111541. dispose(disposeTexture?: boolean): void;
  111542. /**
  111543. * Clones the particle system.
  111544. * @param name The name of the cloned object
  111545. * @param newEmitter The new emitter to use
  111546. * @returns the cloned particle system
  111547. */
  111548. clone(name: string, newEmitter: any): GPUParticleSystem;
  111549. /**
  111550. * Serializes the particle system to a JSON object.
  111551. * @returns the JSON object
  111552. */
  111553. serialize(): any;
  111554. /**
  111555. * Parses a JSON object to create a GPU particle system.
  111556. * @param parsedParticleSystem The JSON object to parse
  111557. * @param scene The scene to create the particle system in
  111558. * @param rootUrl The root url to use to load external dependencies like texture
  111559. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111560. * @returns the parsed GPU particle system
  111561. */
  111562. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  111563. }
  111564. }
  111565. declare module BABYLON {
  111566. /**
  111567. * Represents a set of particle systems working together to create a specific effect
  111568. */
  111569. export class ParticleSystemSet implements IDisposable {
  111570. private _emitterCreationOptions;
  111571. private _emitterNode;
  111572. /**
  111573. * Gets the particle system list
  111574. */
  111575. systems: IParticleSystem[];
  111576. /**
  111577. * Gets the emitter node used with this set
  111578. */
  111579. readonly emitterNode: Nullable<TransformNode>;
  111580. /**
  111581. * Creates a new emitter mesh as a sphere
  111582. * @param options defines the options used to create the sphere
  111583. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  111584. * @param scene defines the hosting scene
  111585. */
  111586. setEmitterAsSphere(options: {
  111587. diameter: number;
  111588. segments: number;
  111589. color: Color3;
  111590. }, renderingGroupId: number, scene: Scene): void;
  111591. /**
  111592. * Starts all particle systems of the set
  111593. * @param emitter defines an optional mesh to use as emitter for the particle systems
  111594. */
  111595. start(emitter?: AbstractMesh): void;
  111596. /**
  111597. * Release all associated resources
  111598. */
  111599. dispose(): void;
  111600. /**
  111601. * Serialize the set into a JSON compatible object
  111602. * @returns a JSON compatible representation of the set
  111603. */
  111604. serialize(): any;
  111605. /**
  111606. * Parse a new ParticleSystemSet from a serialized source
  111607. * @param data defines a JSON compatible representation of the set
  111608. * @param scene defines the hosting scene
  111609. * @param gpu defines if we want GPU particles or CPU particles
  111610. * @returns a new ParticleSystemSet
  111611. */
  111612. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  111613. }
  111614. }
  111615. declare module BABYLON {
  111616. /**
  111617. * This class is made for on one-liner static method to help creating particle system set.
  111618. */
  111619. export class ParticleHelper {
  111620. /**
  111621. * Gets or sets base Assets URL
  111622. */
  111623. static BaseAssetsUrl: string;
  111624. /**
  111625. * Create a default particle system that you can tweak
  111626. * @param emitter defines the emitter to use
  111627. * @param capacity defines the system capacity (default is 500 particles)
  111628. * @param scene defines the hosting scene
  111629. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  111630. * @returns the new Particle system
  111631. */
  111632. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  111633. /**
  111634. * This is the main static method (one-liner) of this helper to create different particle systems
  111635. * @param type This string represents the type to the particle system to create
  111636. * @param scene The scene where the particle system should live
  111637. * @param gpu If the system will use gpu
  111638. * @returns the ParticleSystemSet created
  111639. */
  111640. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  111641. /**
  111642. * Static function used to export a particle system to a ParticleSystemSet variable.
  111643. * Please note that the emitter shape is not exported
  111644. * @param systems defines the particle systems to export
  111645. * @returns the created particle system set
  111646. */
  111647. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  111648. }
  111649. }
  111650. declare module BABYLON {
  111651. interface Engine {
  111652. /**
  111653. * Create an effect to use with particle systems.
  111654. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  111655. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  111656. * @param uniformsNames defines a list of attribute names
  111657. * @param samplers defines an array of string used to represent textures
  111658. * @param defines defines the string containing the defines to use to compile the shaders
  111659. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111660. * @param onCompiled defines a function to call when the effect creation is successful
  111661. * @param onError defines a function to call when the effect creation has failed
  111662. * @returns the new Effect
  111663. */
  111664. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  111665. }
  111666. interface Mesh {
  111667. /**
  111668. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  111669. * @returns an array of IParticleSystem
  111670. */
  111671. getEmittedParticleSystems(): IParticleSystem[];
  111672. /**
  111673. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  111674. * @returns an array of IParticleSystem
  111675. */
  111676. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  111677. }
  111678. /**
  111679. * @hidden
  111680. */
  111681. export var _IDoNeedToBeInTheBuild: number;
  111682. }
  111683. declare module BABYLON {
  111684. interface Scene {
  111685. /** @hidden (Backing field) */
  111686. _physicsEngine: Nullable<IPhysicsEngine>;
  111687. /**
  111688. * Gets the current physics engine
  111689. * @returns a IPhysicsEngine or null if none attached
  111690. */
  111691. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  111692. /**
  111693. * Enables physics to the current scene
  111694. * @param gravity defines the scene's gravity for the physics engine
  111695. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111696. * @return a boolean indicating if the physics engine was initialized
  111697. */
  111698. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  111699. /**
  111700. * Disables and disposes the physics engine associated with the scene
  111701. */
  111702. disablePhysicsEngine(): void;
  111703. /**
  111704. * Gets a boolean indicating if there is an active physics engine
  111705. * @returns a boolean indicating if there is an active physics engine
  111706. */
  111707. isPhysicsEnabled(): boolean;
  111708. /**
  111709. * Deletes a physics compound impostor
  111710. * @param compound defines the compound to delete
  111711. */
  111712. deleteCompoundImpostor(compound: any): void;
  111713. /**
  111714. * An event triggered when physic simulation is about to be run
  111715. */
  111716. onBeforePhysicsObservable: Observable<Scene>;
  111717. /**
  111718. * An event triggered when physic simulation has been done
  111719. */
  111720. onAfterPhysicsObservable: Observable<Scene>;
  111721. }
  111722. interface AbstractMesh {
  111723. /** @hidden */
  111724. _physicsImpostor: Nullable<PhysicsImpostor>;
  111725. /**
  111726. * Gets or sets impostor used for physic simulation
  111727. * @see http://doc.babylonjs.com/features/physics_engine
  111728. */
  111729. physicsImpostor: Nullable<PhysicsImpostor>;
  111730. /**
  111731. * Gets the current physics impostor
  111732. * @see http://doc.babylonjs.com/features/physics_engine
  111733. * @returns a physics impostor or null
  111734. */
  111735. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  111736. /** Apply a physic impulse to the mesh
  111737. * @param force defines the force to apply
  111738. * @param contactPoint defines where to apply the force
  111739. * @returns the current mesh
  111740. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111741. */
  111742. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  111743. /**
  111744. * Creates a physic joint between two meshes
  111745. * @param otherMesh defines the other mesh to use
  111746. * @param pivot1 defines the pivot to use on this mesh
  111747. * @param pivot2 defines the pivot to use on the other mesh
  111748. * @param options defines additional options (can be plugin dependent)
  111749. * @returns the current mesh
  111750. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111751. */
  111752. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  111753. /** @hidden */
  111754. _disposePhysicsObserver: Nullable<Observer<Node>>;
  111755. }
  111756. /**
  111757. * Defines the physics engine scene component responsible to manage a physics engine
  111758. */
  111759. export class PhysicsEngineSceneComponent implements ISceneComponent {
  111760. /**
  111761. * The component name helpful to identify the component in the list of scene components.
  111762. */
  111763. readonly name: string;
  111764. /**
  111765. * The scene the component belongs to.
  111766. */
  111767. scene: Scene;
  111768. /**
  111769. * Creates a new instance of the component for the given scene
  111770. * @param scene Defines the scene to register the component in
  111771. */
  111772. constructor(scene: Scene);
  111773. /**
  111774. * Registers the component in a given scene
  111775. */
  111776. register(): void;
  111777. /**
  111778. * Rebuilds the elements related to this component in case of
  111779. * context lost for instance.
  111780. */
  111781. rebuild(): void;
  111782. /**
  111783. * Disposes the component and the associated ressources
  111784. */
  111785. dispose(): void;
  111786. }
  111787. }
  111788. declare module BABYLON {
  111789. /**
  111790. * A helper for physics simulations
  111791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111792. */
  111793. export class PhysicsHelper {
  111794. private _scene;
  111795. private _physicsEngine;
  111796. /**
  111797. * Initializes the Physics helper
  111798. * @param scene Babylon.js scene
  111799. */
  111800. constructor(scene: Scene);
  111801. /**
  111802. * Applies a radial explosion impulse
  111803. * @param origin the origin of the explosion
  111804. * @param radiusOrEventOptions the radius or the options of radial explosion
  111805. * @param strength the explosion strength
  111806. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111807. * @returns A physics radial explosion event, or null
  111808. */
  111809. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111810. /**
  111811. * Applies a radial explosion force
  111812. * @param origin the origin of the explosion
  111813. * @param radiusOrEventOptions the radius or the options of radial explosion
  111814. * @param strength the explosion strength
  111815. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111816. * @returns A physics radial explosion event, or null
  111817. */
  111818. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111819. /**
  111820. * Creates a gravitational field
  111821. * @param origin the origin of the explosion
  111822. * @param radiusOrEventOptions the radius or the options of radial explosion
  111823. * @param strength the explosion strength
  111824. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111825. * @returns A physics gravitational field event, or null
  111826. */
  111827. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  111828. /**
  111829. * Creates a physics updraft event
  111830. * @param origin the origin of the updraft
  111831. * @param radiusOrEventOptions the radius or the options of the updraft
  111832. * @param strength the strength of the updraft
  111833. * @param height the height of the updraft
  111834. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111835. * @returns A physics updraft event, or null
  111836. */
  111837. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  111838. /**
  111839. * Creates a physics vortex event
  111840. * @param origin the of the vortex
  111841. * @param radiusOrEventOptions the radius or the options of the vortex
  111842. * @param strength the strength of the vortex
  111843. * @param height the height of the vortex
  111844. * @returns a Physics vortex event, or null
  111845. * A physics vortex event or null
  111846. */
  111847. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  111848. }
  111849. /**
  111850. * Represents a physics radial explosion event
  111851. */
  111852. class PhysicsRadialExplosionEvent {
  111853. private _scene;
  111854. private _options;
  111855. private _sphere;
  111856. private _dataFetched;
  111857. /**
  111858. * Initializes a radial explosioin event
  111859. * @param _scene BabylonJS scene
  111860. * @param _options The options for the vortex event
  111861. */
  111862. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  111863. /**
  111864. * Returns the data related to the radial explosion event (sphere).
  111865. * @returns The radial explosion event data
  111866. */
  111867. getData(): PhysicsRadialExplosionEventData;
  111868. /**
  111869. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111870. * @param impostor A physics imposter
  111871. * @param origin the origin of the explosion
  111872. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  111873. */
  111874. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  111875. /**
  111876. * Triggers affecterd impostors callbacks
  111877. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  111878. */
  111879. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  111880. /**
  111881. * Disposes the sphere.
  111882. * @param force Specifies if the sphere should be disposed by force
  111883. */
  111884. dispose(force?: boolean): void;
  111885. /*** Helpers ***/
  111886. private _prepareSphere;
  111887. private _intersectsWithSphere;
  111888. }
  111889. /**
  111890. * Represents a gravitational field event
  111891. */
  111892. class PhysicsGravitationalFieldEvent {
  111893. private _physicsHelper;
  111894. private _scene;
  111895. private _origin;
  111896. private _options;
  111897. private _tickCallback;
  111898. private _sphere;
  111899. private _dataFetched;
  111900. /**
  111901. * Initializes the physics gravitational field event
  111902. * @param _physicsHelper A physics helper
  111903. * @param _scene BabylonJS scene
  111904. * @param _origin The origin position of the gravitational field event
  111905. * @param _options The options for the vortex event
  111906. */
  111907. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  111908. /**
  111909. * Returns the data related to the gravitational field event (sphere).
  111910. * @returns A gravitational field event
  111911. */
  111912. getData(): PhysicsGravitationalFieldEventData;
  111913. /**
  111914. * Enables the gravitational field.
  111915. */
  111916. enable(): void;
  111917. /**
  111918. * Disables the gravitational field.
  111919. */
  111920. disable(): void;
  111921. /**
  111922. * Disposes the sphere.
  111923. * @param force The force to dispose from the gravitational field event
  111924. */
  111925. dispose(force?: boolean): void;
  111926. private _tick;
  111927. }
  111928. /**
  111929. * Represents a physics updraft event
  111930. */
  111931. class PhysicsUpdraftEvent {
  111932. private _scene;
  111933. private _origin;
  111934. private _options;
  111935. private _physicsEngine;
  111936. private _originTop;
  111937. private _originDirection;
  111938. private _tickCallback;
  111939. private _cylinder;
  111940. private _cylinderPosition;
  111941. private _dataFetched;
  111942. /**
  111943. * Initializes the physics updraft event
  111944. * @param _scene BabylonJS scene
  111945. * @param _origin The origin position of the updraft
  111946. * @param _options The options for the updraft event
  111947. */
  111948. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  111949. /**
  111950. * Returns the data related to the updraft event (cylinder).
  111951. * @returns A physics updraft event
  111952. */
  111953. getData(): PhysicsUpdraftEventData;
  111954. /**
  111955. * Enables the updraft.
  111956. */
  111957. enable(): void;
  111958. /**
  111959. * Disables the updraft.
  111960. */
  111961. disable(): void;
  111962. /**
  111963. * Disposes the cylinder.
  111964. * @param force Specifies if the updraft should be disposed by force
  111965. */
  111966. dispose(force?: boolean): void;
  111967. private getImpostorHitData;
  111968. private _tick;
  111969. /*** Helpers ***/
  111970. private _prepareCylinder;
  111971. private _intersectsWithCylinder;
  111972. }
  111973. /**
  111974. * Represents a physics vortex event
  111975. */
  111976. class PhysicsVortexEvent {
  111977. private _scene;
  111978. private _origin;
  111979. private _options;
  111980. private _physicsEngine;
  111981. private _originTop;
  111982. private _tickCallback;
  111983. private _cylinder;
  111984. private _cylinderPosition;
  111985. private _dataFetched;
  111986. /**
  111987. * Initializes the physics vortex event
  111988. * @param _scene The BabylonJS scene
  111989. * @param _origin The origin position of the vortex
  111990. * @param _options The options for the vortex event
  111991. */
  111992. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  111993. /**
  111994. * Returns the data related to the vortex event (cylinder).
  111995. * @returns The physics vortex event data
  111996. */
  111997. getData(): PhysicsVortexEventData;
  111998. /**
  111999. * Enables the vortex.
  112000. */
  112001. enable(): void;
  112002. /**
  112003. * Disables the cortex.
  112004. */
  112005. disable(): void;
  112006. /**
  112007. * Disposes the sphere.
  112008. * @param force
  112009. */
  112010. dispose(force?: boolean): void;
  112011. private getImpostorHitData;
  112012. private _tick;
  112013. /*** Helpers ***/
  112014. private _prepareCylinder;
  112015. private _intersectsWithCylinder;
  112016. }
  112017. /**
  112018. * Options fot the radial explosion event
  112019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112020. */
  112021. export class PhysicsRadialExplosionEventOptions {
  112022. /**
  112023. * The radius of the sphere for the radial explosion.
  112024. */
  112025. radius: number;
  112026. /**
  112027. * The strenth of the explosion.
  112028. */
  112029. strength: number;
  112030. /**
  112031. * The strenght of the force in correspondence to the distance of the affected object
  112032. */
  112033. falloff: PhysicsRadialImpulseFalloff;
  112034. /**
  112035. * Sphere options for the radial explosion.
  112036. */
  112037. sphere: {
  112038. segments: number;
  112039. diameter: number;
  112040. };
  112041. /**
  112042. * Sphere options for the radial explosion.
  112043. */
  112044. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  112045. }
  112046. /**
  112047. * Options fot the updraft event
  112048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112049. */
  112050. export class PhysicsUpdraftEventOptions {
  112051. /**
  112052. * The radius of the cylinder for the vortex
  112053. */
  112054. radius: number;
  112055. /**
  112056. * The strenth of the updraft.
  112057. */
  112058. strength: number;
  112059. /**
  112060. * The height of the cylinder for the updraft.
  112061. */
  112062. height: number;
  112063. /**
  112064. * The mode for the the updraft.
  112065. */
  112066. updraftMode: PhysicsUpdraftMode;
  112067. }
  112068. /**
  112069. * Options fot the vortex event
  112070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112071. */
  112072. export class PhysicsVortexEventOptions {
  112073. /**
  112074. * The radius of the cylinder for the vortex
  112075. */
  112076. radius: number;
  112077. /**
  112078. * The strenth of the vortex.
  112079. */
  112080. strength: number;
  112081. /**
  112082. * The height of the cylinder for the vortex.
  112083. */
  112084. height: number;
  112085. /**
  112086. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  112087. */
  112088. centripetalForceThreshold: number;
  112089. /**
  112090. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  112091. */
  112092. centripetalForceMultiplier: number;
  112093. /**
  112094. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  112095. */
  112096. centrifugalForceMultiplier: number;
  112097. /**
  112098. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  112099. */
  112100. updraftForceMultiplier: number;
  112101. }
  112102. /**
  112103. * The strenght of the force in correspondence to the distance of the affected object
  112104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112105. */
  112106. export enum PhysicsRadialImpulseFalloff {
  112107. /** Defines that impulse is constant in strength across it's whole radius */
  112108. Constant = 0,
  112109. /** Defines that impulse gets weaker if it's further from the origin */
  112110. Linear = 1
  112111. }
  112112. /**
  112113. * The strength of the force in correspondence to the distance of the affected object
  112114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112115. */
  112116. export enum PhysicsUpdraftMode {
  112117. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  112118. Center = 0,
  112119. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  112120. Perpendicular = 1
  112121. }
  112122. /**
  112123. * Interface for a physics hit data
  112124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112125. */
  112126. export interface PhysicsHitData {
  112127. /**
  112128. * The force applied at the contact point
  112129. */
  112130. force: Vector3;
  112131. /**
  112132. * The contact point
  112133. */
  112134. contactPoint: Vector3;
  112135. /**
  112136. * The distance from the origin to the contact point
  112137. */
  112138. distanceFromOrigin: number;
  112139. }
  112140. /**
  112141. * Interface for radial explosion event data
  112142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112143. */
  112144. export interface PhysicsRadialExplosionEventData {
  112145. /**
  112146. * A sphere used for the radial explosion event
  112147. */
  112148. sphere: Mesh;
  112149. }
  112150. /**
  112151. * Interface for gravitational field event data
  112152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112153. */
  112154. export interface PhysicsGravitationalFieldEventData {
  112155. /**
  112156. * A sphere mesh used for the gravitational field event
  112157. */
  112158. sphere: Mesh;
  112159. }
  112160. /**
  112161. * Interface for updraft event data
  112162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112163. */
  112164. export interface PhysicsUpdraftEventData {
  112165. /**
  112166. * A cylinder used for the updraft event
  112167. */
  112168. cylinder: Mesh;
  112169. }
  112170. /**
  112171. * Interface for vortex event data
  112172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112173. */
  112174. export interface PhysicsVortexEventData {
  112175. /**
  112176. * A cylinder used for the vortex event
  112177. */
  112178. cylinder: Mesh;
  112179. }
  112180. /**
  112181. * Interface for an affected physics impostor
  112182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112183. */
  112184. export interface PhysicsAffectedImpostorWithData {
  112185. /**
  112186. * The impostor affected by the effect
  112187. */
  112188. impostor: PhysicsImpostor;
  112189. /**
  112190. * The data about the hit/horce from the explosion
  112191. */
  112192. hitData: PhysicsHitData;
  112193. }
  112194. }
  112195. declare module BABYLON {
  112196. /** @hidden */
  112197. export var blackAndWhitePixelShader: {
  112198. name: string;
  112199. shader: string;
  112200. };
  112201. }
  112202. declare module BABYLON {
  112203. /**
  112204. * Post process used to render in black and white
  112205. */
  112206. export class BlackAndWhitePostProcess extends PostProcess {
  112207. /**
  112208. * Linear about to convert he result to black and white (default: 1)
  112209. */
  112210. degree: number;
  112211. /**
  112212. * Creates a black and white post process
  112213. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  112214. * @param name The name of the effect.
  112215. * @param options The required width/height ratio to downsize to before computing the render pass.
  112216. * @param camera The camera to apply the render pass to.
  112217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112218. * @param engine The engine which the post process will be applied. (default: current engine)
  112219. * @param reusable If the post process can be reused on the same frame. (default: false)
  112220. */
  112221. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112222. }
  112223. }
  112224. declare module BABYLON {
  112225. /**
  112226. * This represents a set of one or more post processes in Babylon.
  112227. * A post process can be used to apply a shader to a texture after it is rendered.
  112228. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112229. */
  112230. export class PostProcessRenderEffect {
  112231. private _postProcesses;
  112232. private _getPostProcesses;
  112233. private _singleInstance;
  112234. private _cameras;
  112235. private _indicesForCamera;
  112236. /**
  112237. * Name of the effect
  112238. * @hidden
  112239. */
  112240. _name: string;
  112241. /**
  112242. * Instantiates a post process render effect.
  112243. * A post process can be used to apply a shader to a texture after it is rendered.
  112244. * @param engine The engine the effect is tied to
  112245. * @param name The name of the effect
  112246. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  112247. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  112248. */
  112249. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  112250. /**
  112251. * Checks if all the post processes in the effect are supported.
  112252. */
  112253. readonly isSupported: boolean;
  112254. /**
  112255. * Updates the current state of the effect
  112256. * @hidden
  112257. */
  112258. _update(): void;
  112259. /**
  112260. * Attaches the effect on cameras
  112261. * @param cameras The camera to attach to.
  112262. * @hidden
  112263. */
  112264. _attachCameras(cameras: Camera): void;
  112265. /**
  112266. * Attaches the effect on cameras
  112267. * @param cameras The camera to attach to.
  112268. * @hidden
  112269. */
  112270. _attachCameras(cameras: Camera[]): void;
  112271. /**
  112272. * Detaches the effect on cameras
  112273. * @param cameras The camera to detatch from.
  112274. * @hidden
  112275. */
  112276. _detachCameras(cameras: Camera): void;
  112277. /**
  112278. * Detatches the effect on cameras
  112279. * @param cameras The camera to detatch from.
  112280. * @hidden
  112281. */
  112282. _detachCameras(cameras: Camera[]): void;
  112283. /**
  112284. * Enables the effect on given cameras
  112285. * @param cameras The camera to enable.
  112286. * @hidden
  112287. */
  112288. _enable(cameras: Camera): void;
  112289. /**
  112290. * Enables the effect on given cameras
  112291. * @param cameras The camera to enable.
  112292. * @hidden
  112293. */
  112294. _enable(cameras: Nullable<Camera[]>): void;
  112295. /**
  112296. * Disables the effect on the given cameras
  112297. * @param cameras The camera to disable.
  112298. * @hidden
  112299. */
  112300. _disable(cameras: Camera): void;
  112301. /**
  112302. * Disables the effect on the given cameras
  112303. * @param cameras The camera to disable.
  112304. * @hidden
  112305. */
  112306. _disable(cameras: Nullable<Camera[]>): void;
  112307. /**
  112308. * Gets a list of the post processes contained in the effect.
  112309. * @param camera The camera to get the post processes on.
  112310. * @returns The list of the post processes in the effect.
  112311. */
  112312. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  112313. }
  112314. }
  112315. declare module BABYLON {
  112316. /** @hidden */
  112317. export var extractHighlightsPixelShader: {
  112318. name: string;
  112319. shader: string;
  112320. };
  112321. }
  112322. declare module BABYLON {
  112323. /**
  112324. * 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.
  112325. */
  112326. export class ExtractHighlightsPostProcess extends PostProcess {
  112327. /**
  112328. * The luminance threshold, pixels below this value will be set to black.
  112329. */
  112330. threshold: number;
  112331. /** @hidden */
  112332. _exposure: number;
  112333. /**
  112334. * Post process which has the input texture to be used when performing highlight extraction
  112335. * @hidden
  112336. */
  112337. _inputPostProcess: Nullable<PostProcess>;
  112338. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112339. }
  112340. }
  112341. declare module BABYLON {
  112342. /** @hidden */
  112343. export var bloomMergePixelShader: {
  112344. name: string;
  112345. shader: string;
  112346. };
  112347. }
  112348. declare module BABYLON {
  112349. /**
  112350. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112351. */
  112352. export class BloomMergePostProcess extends PostProcess {
  112353. /** Weight of the bloom to be added to the original input. */
  112354. weight: number;
  112355. /**
  112356. * Creates a new instance of @see BloomMergePostProcess
  112357. * @param name The name of the effect.
  112358. * @param originalFromInput Post process which's input will be used for the merge.
  112359. * @param blurred Blurred highlights post process which's output will be used.
  112360. * @param weight Weight of the bloom to be added to the original input.
  112361. * @param options The required width/height ratio to downsize to before computing the render pass.
  112362. * @param camera The camera to apply the render pass to.
  112363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112364. * @param engine The engine which the post process will be applied. (default: current engine)
  112365. * @param reusable If the post process can be reused on the same frame. (default: false)
  112366. * @param textureType Type of textures used when performing the post process. (default: 0)
  112367. * @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)
  112368. */
  112369. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  112370. /** Weight of the bloom to be added to the original input. */
  112371. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112372. }
  112373. }
  112374. declare module BABYLON {
  112375. /**
  112376. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  112377. */
  112378. export class BloomEffect extends PostProcessRenderEffect {
  112379. private bloomScale;
  112380. /**
  112381. * @hidden Internal
  112382. */
  112383. _effects: Array<PostProcess>;
  112384. /**
  112385. * @hidden Internal
  112386. */
  112387. _downscale: ExtractHighlightsPostProcess;
  112388. private _blurX;
  112389. private _blurY;
  112390. private _merge;
  112391. /**
  112392. * The luminance threshold to find bright areas of the image to bloom.
  112393. */
  112394. threshold: number;
  112395. /**
  112396. * The strength of the bloom.
  112397. */
  112398. weight: number;
  112399. /**
  112400. * Specifies the size of the bloom blur kernel, relative to the final output size
  112401. */
  112402. kernel: number;
  112403. /**
  112404. * Creates a new instance of @see BloomEffect
  112405. * @param scene The scene the effect belongs to.
  112406. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  112407. * @param bloomKernel The size of the kernel to be used when applying the blur.
  112408. * @param bloomWeight The the strength of bloom.
  112409. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112410. * @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)
  112411. */
  112412. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  112413. /**
  112414. * Disposes each of the internal effects for a given camera.
  112415. * @param camera The camera to dispose the effect on.
  112416. */
  112417. disposeEffects(camera: Camera): void;
  112418. /**
  112419. * @hidden Internal
  112420. */
  112421. _updateEffects(): void;
  112422. /**
  112423. * Internal
  112424. * @returns if all the contained post processes are ready.
  112425. * @hidden
  112426. */
  112427. _isReady(): boolean;
  112428. }
  112429. }
  112430. declare module BABYLON {
  112431. /** @hidden */
  112432. export var chromaticAberrationPixelShader: {
  112433. name: string;
  112434. shader: string;
  112435. };
  112436. }
  112437. declare module BABYLON {
  112438. /**
  112439. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  112440. */
  112441. export class ChromaticAberrationPostProcess extends PostProcess {
  112442. /**
  112443. * The amount of seperation of rgb channels (default: 30)
  112444. */
  112445. aberrationAmount: number;
  112446. /**
  112447. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  112448. */
  112449. radialIntensity: number;
  112450. /**
  112451. * 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))
  112452. */
  112453. direction: Vector2;
  112454. /**
  112455. * 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))
  112456. */
  112457. centerPosition: Vector2;
  112458. /**
  112459. * Creates a new instance ChromaticAberrationPostProcess
  112460. * @param name The name of the effect.
  112461. * @param screenWidth The width of the screen to apply the effect on.
  112462. * @param screenHeight The height of the screen to apply the effect on.
  112463. * @param options The required width/height ratio to downsize to before computing the render pass.
  112464. * @param camera The camera to apply the render pass to.
  112465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112466. * @param engine The engine which the post process will be applied. (default: current engine)
  112467. * @param reusable If the post process can be reused on the same frame. (default: false)
  112468. * @param textureType Type of textures used when performing the post process. (default: 0)
  112469. * @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)
  112470. */
  112471. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112472. }
  112473. }
  112474. declare module BABYLON {
  112475. /** @hidden */
  112476. export var circleOfConfusionPixelShader: {
  112477. name: string;
  112478. shader: string;
  112479. };
  112480. }
  112481. declare module BABYLON {
  112482. /**
  112483. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  112484. */
  112485. export class CircleOfConfusionPostProcess extends PostProcess {
  112486. /**
  112487. * 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.
  112488. */
  112489. lensSize: number;
  112490. /**
  112491. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112492. */
  112493. fStop: number;
  112494. /**
  112495. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112496. */
  112497. focusDistance: number;
  112498. /**
  112499. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  112500. */
  112501. focalLength: number;
  112502. private _depthTexture;
  112503. /**
  112504. * Creates a new instance CircleOfConfusionPostProcess
  112505. * @param name The name of the effect.
  112506. * @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.
  112507. * @param options The required width/height ratio to downsize to before computing the render pass.
  112508. * @param camera The camera to apply the render pass to.
  112509. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112510. * @param engine The engine which the post process will be applied. (default: current engine)
  112511. * @param reusable If the post process can be reused on the same frame. (default: false)
  112512. * @param textureType Type of textures used when performing the post process. (default: 0)
  112513. * @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)
  112514. */
  112515. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112516. /**
  112517. * 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.
  112518. */
  112519. depthTexture: RenderTargetTexture;
  112520. }
  112521. }
  112522. declare module BABYLON {
  112523. /** @hidden */
  112524. export var colorCorrectionPixelShader: {
  112525. name: string;
  112526. shader: string;
  112527. };
  112528. }
  112529. declare module BABYLON {
  112530. /**
  112531. *
  112532. * This post-process allows the modification of rendered colors by using
  112533. * a 'look-up table' (LUT). This effect is also called Color Grading.
  112534. *
  112535. * The object needs to be provided an url to a texture containing the color
  112536. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  112537. * Use an image editing software to tweak the LUT to match your needs.
  112538. *
  112539. * For an example of a color LUT, see here:
  112540. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  112541. * For explanations on color grading, see here:
  112542. * @see http://udn.epicgames.com/Three/ColorGrading.html
  112543. *
  112544. */
  112545. export class ColorCorrectionPostProcess extends PostProcess {
  112546. private _colorTableTexture;
  112547. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112548. }
  112549. }
  112550. declare module BABYLON {
  112551. /** @hidden */
  112552. export var convolutionPixelShader: {
  112553. name: string;
  112554. shader: string;
  112555. };
  112556. }
  112557. declare module BABYLON {
  112558. /**
  112559. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  112560. * input texture to perform effects such as edge detection or sharpening
  112561. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112562. */
  112563. export class ConvolutionPostProcess extends PostProcess {
  112564. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112565. kernel: number[];
  112566. /**
  112567. * Creates a new instance ConvolutionPostProcess
  112568. * @param name The name of the effect.
  112569. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  112570. * @param options The required width/height ratio to downsize to before computing the render pass.
  112571. * @param camera The camera to apply the render pass to.
  112572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112573. * @param engine The engine which the post process will be applied. (default: current engine)
  112574. * @param reusable If the post process can be reused on the same frame. (default: false)
  112575. * @param textureType Type of textures used when performing the post process. (default: 0)
  112576. */
  112577. constructor(name: string,
  112578. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112579. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112580. /**
  112581. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112582. */
  112583. static EdgeDetect0Kernel: number[];
  112584. /**
  112585. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112586. */
  112587. static EdgeDetect1Kernel: number[];
  112588. /**
  112589. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112590. */
  112591. static EdgeDetect2Kernel: number[];
  112592. /**
  112593. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112594. */
  112595. static SharpenKernel: number[];
  112596. /**
  112597. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112598. */
  112599. static EmbossKernel: number[];
  112600. /**
  112601. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112602. */
  112603. static GaussianKernel: number[];
  112604. }
  112605. }
  112606. declare module BABYLON {
  112607. /**
  112608. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  112609. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  112610. * based on samples that have a large difference in distance than the center pixel.
  112611. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  112612. */
  112613. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  112614. direction: Vector2;
  112615. /**
  112616. * Creates a new instance CircleOfConfusionPostProcess
  112617. * @param name The name of the effect.
  112618. * @param scene The scene the effect belongs to.
  112619. * @param direction The direction the blur should be applied.
  112620. * @param kernel The size of the kernel used to blur.
  112621. * @param options The required width/height ratio to downsize to before computing the render pass.
  112622. * @param camera The camera to apply the render pass to.
  112623. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  112624. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  112625. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112626. * @param engine The engine which the post process will be applied. (default: current engine)
  112627. * @param reusable If the post process can be reused on the same frame. (default: false)
  112628. * @param textureType Type of textures used when performing the post process. (default: 0)
  112629. * @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)
  112630. */
  112631. 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);
  112632. }
  112633. }
  112634. declare module BABYLON {
  112635. /** @hidden */
  112636. export var depthOfFieldMergePixelShader: {
  112637. name: string;
  112638. shader: string;
  112639. };
  112640. }
  112641. declare module BABYLON {
  112642. /**
  112643. * Options to be set when merging outputs from the default pipeline.
  112644. */
  112645. export class DepthOfFieldMergePostProcessOptions {
  112646. /**
  112647. * The original image to merge on top of
  112648. */
  112649. originalFromInput: PostProcess;
  112650. /**
  112651. * Parameters to perform the merge of the depth of field effect
  112652. */
  112653. depthOfField?: {
  112654. circleOfConfusion: PostProcess;
  112655. blurSteps: Array<PostProcess>;
  112656. };
  112657. /**
  112658. * Parameters to perform the merge of bloom effect
  112659. */
  112660. bloom?: {
  112661. blurred: PostProcess;
  112662. weight: number;
  112663. };
  112664. }
  112665. /**
  112666. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112667. */
  112668. export class DepthOfFieldMergePostProcess extends PostProcess {
  112669. private blurSteps;
  112670. /**
  112671. * Creates a new instance of DepthOfFieldMergePostProcess
  112672. * @param name The name of the effect.
  112673. * @param originalFromInput Post process which's input will be used for the merge.
  112674. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  112675. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  112676. * @param options The required width/height ratio to downsize to before computing the render pass.
  112677. * @param camera The camera to apply the render pass to.
  112678. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112679. * @param engine The engine which the post process will be applied. (default: current engine)
  112680. * @param reusable If the post process can be reused on the same frame. (default: false)
  112681. * @param textureType Type of textures used when performing the post process. (default: 0)
  112682. * @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)
  112683. */
  112684. 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);
  112685. /**
  112686. * Updates the effect with the current post process compile time values and recompiles the shader.
  112687. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  112688. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  112689. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  112690. * @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
  112691. * @param onCompiled Called when the shader has been compiled.
  112692. * @param onError Called if there is an error when compiling a shader.
  112693. */
  112694. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  112695. }
  112696. }
  112697. declare module BABYLON {
  112698. /**
  112699. * Specifies the level of max blur that should be applied when using the depth of field effect
  112700. */
  112701. export enum DepthOfFieldEffectBlurLevel {
  112702. /**
  112703. * Subtle blur
  112704. */
  112705. Low = 0,
  112706. /**
  112707. * Medium blur
  112708. */
  112709. Medium = 1,
  112710. /**
  112711. * Large blur
  112712. */
  112713. High = 2
  112714. }
  112715. /**
  112716. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  112717. */
  112718. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  112719. private _circleOfConfusion;
  112720. /**
  112721. * @hidden Internal, blurs from high to low
  112722. */
  112723. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  112724. private _depthOfFieldBlurY;
  112725. private _dofMerge;
  112726. /**
  112727. * @hidden Internal post processes in depth of field effect
  112728. */
  112729. _effects: Array<PostProcess>;
  112730. /**
  112731. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  112732. */
  112733. focalLength: number;
  112734. /**
  112735. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112736. */
  112737. fStop: number;
  112738. /**
  112739. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112740. */
  112741. focusDistance: number;
  112742. /**
  112743. * 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.
  112744. */
  112745. lensSize: number;
  112746. /**
  112747. * Creates a new instance DepthOfFieldEffect
  112748. * @param scene The scene the effect belongs to.
  112749. * @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.
  112750. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112751. * @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)
  112752. */
  112753. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  112754. /**
  112755. * Get the current class name of the current effet
  112756. * @returns "DepthOfFieldEffect"
  112757. */
  112758. getClassName(): string;
  112759. /**
  112760. * 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.
  112761. */
  112762. depthTexture: RenderTargetTexture;
  112763. /**
  112764. * Disposes each of the internal effects for a given camera.
  112765. * @param camera The camera to dispose the effect on.
  112766. */
  112767. disposeEffects(camera: Camera): void;
  112768. /**
  112769. * @hidden Internal
  112770. */
  112771. _updateEffects(): void;
  112772. /**
  112773. * Internal
  112774. * @returns if all the contained post processes are ready.
  112775. * @hidden
  112776. */
  112777. _isReady(): boolean;
  112778. }
  112779. }
  112780. declare module BABYLON {
  112781. /** @hidden */
  112782. export var displayPassPixelShader: {
  112783. name: string;
  112784. shader: string;
  112785. };
  112786. }
  112787. declare module BABYLON {
  112788. /**
  112789. * DisplayPassPostProcess which produces an output the same as it's input
  112790. */
  112791. export class DisplayPassPostProcess extends PostProcess {
  112792. /**
  112793. * Creates the DisplayPassPostProcess
  112794. * @param name The name of the effect.
  112795. * @param options The required width/height ratio to downsize to before computing the render pass.
  112796. * @param camera The camera to apply the render pass to.
  112797. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112798. * @param engine The engine which the post process will be applied. (default: current engine)
  112799. * @param reusable If the post process can be reused on the same frame. (default: false)
  112800. */
  112801. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112802. }
  112803. }
  112804. declare module BABYLON {
  112805. /** @hidden */
  112806. export var filterPixelShader: {
  112807. name: string;
  112808. shader: string;
  112809. };
  112810. }
  112811. declare module BABYLON {
  112812. /**
  112813. * Applies a kernel filter to the image
  112814. */
  112815. export class FilterPostProcess extends PostProcess {
  112816. /** The matrix to be applied to the image */
  112817. kernelMatrix: Matrix;
  112818. /**
  112819. *
  112820. * @param name The name of the effect.
  112821. * @param kernelMatrix The matrix to be applied to the image
  112822. * @param options The required width/height ratio to downsize to before computing the render pass.
  112823. * @param camera The camera to apply the render pass to.
  112824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112825. * @param engine The engine which the post process will be applied. (default: current engine)
  112826. * @param reusable If the post process can be reused on the same frame. (default: false)
  112827. */
  112828. constructor(name: string,
  112829. /** The matrix to be applied to the image */
  112830. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112831. }
  112832. }
  112833. declare module BABYLON {
  112834. /** @hidden */
  112835. export var fxaaPixelShader: {
  112836. name: string;
  112837. shader: string;
  112838. };
  112839. }
  112840. declare module BABYLON {
  112841. /** @hidden */
  112842. export var fxaaVertexShader: {
  112843. name: string;
  112844. shader: string;
  112845. };
  112846. }
  112847. declare module BABYLON {
  112848. /**
  112849. * Fxaa post process
  112850. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  112851. */
  112852. export class FxaaPostProcess extends PostProcess {
  112853. /** @hidden */
  112854. texelWidth: number;
  112855. /** @hidden */
  112856. texelHeight: number;
  112857. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112858. private _getDefines;
  112859. }
  112860. }
  112861. declare module BABYLON {
  112862. /** @hidden */
  112863. export var grainPixelShader: {
  112864. name: string;
  112865. shader: string;
  112866. };
  112867. }
  112868. declare module BABYLON {
  112869. /**
  112870. * The GrainPostProcess adds noise to the image at mid luminance levels
  112871. */
  112872. export class GrainPostProcess extends PostProcess {
  112873. /**
  112874. * The intensity of the grain added (default: 30)
  112875. */
  112876. intensity: number;
  112877. /**
  112878. * If the grain should be randomized on every frame
  112879. */
  112880. animated: boolean;
  112881. /**
  112882. * Creates a new instance of @see GrainPostProcess
  112883. * @param name The name of the effect.
  112884. * @param options The required width/height ratio to downsize to before computing the render pass.
  112885. * @param camera The camera to apply the render pass to.
  112886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112887. * @param engine The engine which the post process will be applied. (default: current engine)
  112888. * @param reusable If the post process can be reused on the same frame. (default: false)
  112889. * @param textureType Type of textures used when performing the post process. (default: 0)
  112890. * @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)
  112891. */
  112892. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112893. }
  112894. }
  112895. declare module BABYLON {
  112896. /** @hidden */
  112897. export var highlightsPixelShader: {
  112898. name: string;
  112899. shader: string;
  112900. };
  112901. }
  112902. declare module BABYLON {
  112903. /**
  112904. * Extracts highlights from the image
  112905. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112906. */
  112907. export class HighlightsPostProcess extends PostProcess {
  112908. /**
  112909. * Extracts highlights from the image
  112910. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112911. * @param name The name of the effect.
  112912. * @param options The required width/height ratio to downsize to before computing the render pass.
  112913. * @param camera The camera to apply the render pass to.
  112914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112915. * @param engine The engine which the post process will be applied. (default: current engine)
  112916. * @param reusable If the post process can be reused on the same frame. (default: false)
  112917. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  112918. */
  112919. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112920. }
  112921. }
  112922. declare module BABYLON {
  112923. /** @hidden */
  112924. export var mrtFragmentDeclaration: {
  112925. name: string;
  112926. shader: string;
  112927. };
  112928. }
  112929. declare module BABYLON {
  112930. /** @hidden */
  112931. export var geometryPixelShader: {
  112932. name: string;
  112933. shader: string;
  112934. };
  112935. }
  112936. declare module BABYLON {
  112937. /** @hidden */
  112938. export var geometryVertexShader: {
  112939. name: string;
  112940. shader: string;
  112941. };
  112942. }
  112943. declare module BABYLON {
  112944. /**
  112945. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  112946. */
  112947. export class GeometryBufferRenderer {
  112948. /**
  112949. * Constant used to retrieve the position texture index in the G-Buffer textures array
  112950. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  112951. */
  112952. static readonly POSITION_TEXTURE_TYPE: number;
  112953. /**
  112954. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  112955. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  112956. */
  112957. static readonly VELOCITY_TEXTURE_TYPE: number;
  112958. /**
  112959. * Dictionary used to store the previous transformation matrices of each rendered mesh
  112960. * in order to compute objects velocities when enableVelocity is set to "true"
  112961. * @hidden
  112962. */
  112963. _previousTransformationMatrices: {
  112964. [index: number]: Matrix;
  112965. };
  112966. private _scene;
  112967. private _multiRenderTarget;
  112968. private _ratio;
  112969. private _enablePosition;
  112970. private _enableVelocity;
  112971. private _positionIndex;
  112972. private _velocityIndex;
  112973. protected _effect: Effect;
  112974. protected _cachedDefines: string;
  112975. /**
  112976. * Set the render list (meshes to be rendered) used in the G buffer.
  112977. */
  112978. renderList: Mesh[];
  112979. /**
  112980. * Gets wether or not G buffer are supported by the running hardware.
  112981. * This requires draw buffer supports
  112982. */
  112983. readonly isSupported: boolean;
  112984. /**
  112985. * Returns the index of the given texture type in the G-Buffer textures array
  112986. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  112987. * @returns the index of the given texture type in the G-Buffer textures array
  112988. */
  112989. getTextureIndex(textureType: number): number;
  112990. /**
  112991. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  112992. */
  112993. /**
  112994. * Sets whether or not objects positions are enabled for the G buffer.
  112995. */
  112996. enablePosition: boolean;
  112997. /**
  112998. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  112999. */
  113000. /**
  113001. * Sets wether or not objects velocities are enabled for the G buffer.
  113002. */
  113003. enableVelocity: boolean;
  113004. /**
  113005. * Gets the scene associated with the buffer.
  113006. */
  113007. readonly scene: Scene;
  113008. /**
  113009. * Gets the ratio used by the buffer during its creation.
  113010. * How big is the buffer related to the main canvas.
  113011. */
  113012. readonly ratio: number;
  113013. /** @hidden */
  113014. static _SceneComponentInitialization: (scene: Scene) => void;
  113015. /**
  113016. * Creates a new G Buffer for the scene
  113017. * @param scene The scene the buffer belongs to
  113018. * @param ratio How big is the buffer related to the main canvas.
  113019. */
  113020. constructor(scene: Scene, ratio?: number);
  113021. /**
  113022. * Checks wether everything is ready to render a submesh to the G buffer.
  113023. * @param subMesh the submesh to check readiness for
  113024. * @param useInstances is the mesh drawn using instance or not
  113025. * @returns true if ready otherwise false
  113026. */
  113027. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113028. /**
  113029. * Gets the current underlying G Buffer.
  113030. * @returns the buffer
  113031. */
  113032. getGBuffer(): MultiRenderTarget;
  113033. /**
  113034. * Gets the number of samples used to render the buffer (anti aliasing).
  113035. */
  113036. /**
  113037. * Sets the number of samples used to render the buffer (anti aliasing).
  113038. */
  113039. samples: number;
  113040. /**
  113041. * Disposes the renderer and frees up associated resources.
  113042. */
  113043. dispose(): void;
  113044. protected _createRenderTargets(): void;
  113045. }
  113046. }
  113047. declare module BABYLON {
  113048. interface Scene {
  113049. /** @hidden (Backing field) */
  113050. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113051. /**
  113052. * Gets or Sets the current geometry buffer associated to the scene.
  113053. */
  113054. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113055. /**
  113056. * Enables a GeometryBufferRender and associates it with the scene
  113057. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  113058. * @returns the GeometryBufferRenderer
  113059. */
  113060. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  113061. /**
  113062. * Disables the GeometryBufferRender associated with the scene
  113063. */
  113064. disableGeometryBufferRenderer(): void;
  113065. }
  113066. /**
  113067. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  113068. * in several rendering techniques.
  113069. */
  113070. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  113071. /**
  113072. * The component name helpful to identify the component in the list of scene components.
  113073. */
  113074. readonly name: string;
  113075. /**
  113076. * The scene the component belongs to.
  113077. */
  113078. scene: Scene;
  113079. /**
  113080. * Creates a new instance of the component for the given scene
  113081. * @param scene Defines the scene to register the component in
  113082. */
  113083. constructor(scene: Scene);
  113084. /**
  113085. * Registers the component in a given scene
  113086. */
  113087. register(): void;
  113088. /**
  113089. * Rebuilds the elements related to this component in case of
  113090. * context lost for instance.
  113091. */
  113092. rebuild(): void;
  113093. /**
  113094. * Disposes the component and the associated ressources
  113095. */
  113096. dispose(): void;
  113097. private _gatherRenderTargets;
  113098. }
  113099. }
  113100. declare module BABYLON {
  113101. /** @hidden */
  113102. export var motionBlurPixelShader: {
  113103. name: string;
  113104. shader: string;
  113105. };
  113106. }
  113107. declare module BABYLON {
  113108. /**
  113109. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  113110. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  113111. * As an example, all you have to do is to create the post-process:
  113112. * var mb = new BABYLON.MotionBlurPostProcess(
  113113. * 'mb', // The name of the effect.
  113114. * scene, // The scene containing the objects to blur according to their velocity.
  113115. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  113116. * camera // The camera to apply the render pass to.
  113117. * );
  113118. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  113119. */
  113120. export class MotionBlurPostProcess extends PostProcess {
  113121. /**
  113122. * Defines how much the image is blurred by the movement. Default value is equal to 1
  113123. */
  113124. motionStrength: number;
  113125. /**
  113126. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  113127. */
  113128. /**
  113129. * Sets the number of iterations to be used for motion blur quality
  113130. */
  113131. motionBlurSamples: number;
  113132. private _motionBlurSamples;
  113133. private _geometryBufferRenderer;
  113134. /**
  113135. * Creates a new instance MotionBlurPostProcess
  113136. * @param name The name of the effect.
  113137. * @param scene The scene containing the objects to blur according to their velocity.
  113138. * @param options The required width/height ratio to downsize to before computing the render pass.
  113139. * @param camera The camera to apply the render pass to.
  113140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113141. * @param engine The engine which the post process will be applied. (default: current engine)
  113142. * @param reusable If the post process can be reused on the same frame. (default: false)
  113143. * @param textureType Type of textures used when performing the post process. (default: 0)
  113144. * @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)
  113145. */
  113146. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113147. /**
  113148. * Disposes the post process.
  113149. * @param camera The camera to dispose the post process on.
  113150. */
  113151. dispose(camera?: Camera): void;
  113152. }
  113153. }
  113154. declare module BABYLON {
  113155. /** @hidden */
  113156. export var refractionPixelShader: {
  113157. name: string;
  113158. shader: string;
  113159. };
  113160. }
  113161. declare module BABYLON {
  113162. /**
  113163. * Post process which applies a refractin texture
  113164. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113165. */
  113166. export class RefractionPostProcess extends PostProcess {
  113167. /** the base color of the refraction (used to taint the rendering) */
  113168. color: Color3;
  113169. /** simulated refraction depth */
  113170. depth: number;
  113171. /** the coefficient of the base color (0 to remove base color tainting) */
  113172. colorLevel: number;
  113173. private _refTexture;
  113174. private _ownRefractionTexture;
  113175. /**
  113176. * Gets or sets the refraction texture
  113177. * Please note that you are responsible for disposing the texture if you set it manually
  113178. */
  113179. refractionTexture: Texture;
  113180. /**
  113181. * Initializes the RefractionPostProcess
  113182. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113183. * @param name The name of the effect.
  113184. * @param refractionTextureUrl Url of the refraction texture to use
  113185. * @param color the base color of the refraction (used to taint the rendering)
  113186. * @param depth simulated refraction depth
  113187. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  113188. * @param camera The camera to apply the render pass to.
  113189. * @param options The required width/height ratio to downsize to before computing the render pass.
  113190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113191. * @param engine The engine which the post process will be applied. (default: current engine)
  113192. * @param reusable If the post process can be reused on the same frame. (default: false)
  113193. */
  113194. constructor(name: string, refractionTextureUrl: string,
  113195. /** the base color of the refraction (used to taint the rendering) */
  113196. color: Color3,
  113197. /** simulated refraction depth */
  113198. depth: number,
  113199. /** the coefficient of the base color (0 to remove base color tainting) */
  113200. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  113201. /**
  113202. * Disposes of the post process
  113203. * @param camera Camera to dispose post process on
  113204. */
  113205. dispose(camera: Camera): void;
  113206. }
  113207. }
  113208. declare module BABYLON {
  113209. /** @hidden */
  113210. export var sharpenPixelShader: {
  113211. name: string;
  113212. shader: string;
  113213. };
  113214. }
  113215. declare module BABYLON {
  113216. /**
  113217. * The SharpenPostProcess applies a sharpen kernel to every pixel
  113218. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  113219. */
  113220. export class SharpenPostProcess extends PostProcess {
  113221. /**
  113222. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  113223. */
  113224. colorAmount: number;
  113225. /**
  113226. * How much sharpness should be applied (default: 0.3)
  113227. */
  113228. edgeAmount: number;
  113229. /**
  113230. * Creates a new instance ConvolutionPostProcess
  113231. * @param name The name of the effect.
  113232. * @param options The required width/height ratio to downsize to before computing the render pass.
  113233. * @param camera The camera to apply the render pass to.
  113234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113235. * @param engine The engine which the post process will be applied. (default: current engine)
  113236. * @param reusable If the post process can be reused on the same frame. (default: false)
  113237. * @param textureType Type of textures used when performing the post process. (default: 0)
  113238. * @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)
  113239. */
  113240. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113241. }
  113242. }
  113243. declare module BABYLON {
  113244. /**
  113245. * PostProcessRenderPipeline
  113246. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113247. */
  113248. export class PostProcessRenderPipeline {
  113249. private engine;
  113250. private _renderEffects;
  113251. private _renderEffectsForIsolatedPass;
  113252. /**
  113253. * List of inspectable custom properties (used by the Inspector)
  113254. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113255. */
  113256. inspectableCustomProperties: IInspectable[];
  113257. /**
  113258. * @hidden
  113259. */
  113260. protected _cameras: Camera[];
  113261. /** @hidden */
  113262. _name: string;
  113263. /**
  113264. * Gets pipeline name
  113265. */
  113266. readonly name: string;
  113267. /**
  113268. * Initializes a PostProcessRenderPipeline
  113269. * @param engine engine to add the pipeline to
  113270. * @param name name of the pipeline
  113271. */
  113272. constructor(engine: Engine, name: string);
  113273. /**
  113274. * Gets the class name
  113275. * @returns "PostProcessRenderPipeline"
  113276. */
  113277. getClassName(): string;
  113278. /**
  113279. * If all the render effects in the pipeline are supported
  113280. */
  113281. readonly isSupported: boolean;
  113282. /**
  113283. * Adds an effect to the pipeline
  113284. * @param renderEffect the effect to add
  113285. */
  113286. addEffect(renderEffect: PostProcessRenderEffect): void;
  113287. /** @hidden */
  113288. _rebuild(): void;
  113289. /** @hidden */
  113290. _enableEffect(renderEffectName: string, cameras: Camera): void;
  113291. /** @hidden */
  113292. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  113293. /** @hidden */
  113294. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113295. /** @hidden */
  113296. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113297. /** @hidden */
  113298. _attachCameras(cameras: Camera, unique: boolean): void;
  113299. /** @hidden */
  113300. _attachCameras(cameras: Camera[], unique: boolean): void;
  113301. /** @hidden */
  113302. _detachCameras(cameras: Camera): void;
  113303. /** @hidden */
  113304. _detachCameras(cameras: Nullable<Camera[]>): void;
  113305. /** @hidden */
  113306. _update(): void;
  113307. /** @hidden */
  113308. _reset(): void;
  113309. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  113310. /**
  113311. * Disposes of the pipeline
  113312. */
  113313. dispose(): void;
  113314. }
  113315. }
  113316. declare module BABYLON {
  113317. /**
  113318. * PostProcessRenderPipelineManager class
  113319. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113320. */
  113321. export class PostProcessRenderPipelineManager {
  113322. private _renderPipelines;
  113323. /**
  113324. * Initializes a PostProcessRenderPipelineManager
  113325. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113326. */
  113327. constructor();
  113328. /**
  113329. * Gets the list of supported render pipelines
  113330. */
  113331. readonly supportedPipelines: PostProcessRenderPipeline[];
  113332. /**
  113333. * Adds a pipeline to the manager
  113334. * @param renderPipeline The pipeline to add
  113335. */
  113336. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  113337. /**
  113338. * Attaches a camera to the pipeline
  113339. * @param renderPipelineName The name of the pipeline to attach to
  113340. * @param cameras the camera to attach
  113341. * @param unique if the camera can be attached multiple times to the pipeline
  113342. */
  113343. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  113344. /**
  113345. * Detaches a camera from the pipeline
  113346. * @param renderPipelineName The name of the pipeline to detach from
  113347. * @param cameras the camera to detach
  113348. */
  113349. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  113350. /**
  113351. * Enables an effect by name on a pipeline
  113352. * @param renderPipelineName the name of the pipeline to enable the effect in
  113353. * @param renderEffectName the name of the effect to enable
  113354. * @param cameras the cameras that the effect should be enabled on
  113355. */
  113356. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113357. /**
  113358. * Disables an effect by name on a pipeline
  113359. * @param renderPipelineName the name of the pipeline to disable the effect in
  113360. * @param renderEffectName the name of the effect to disable
  113361. * @param cameras the cameras that the effect should be disabled on
  113362. */
  113363. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113364. /**
  113365. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  113366. */
  113367. update(): void;
  113368. /** @hidden */
  113369. _rebuild(): void;
  113370. /**
  113371. * Disposes of the manager and pipelines
  113372. */
  113373. dispose(): void;
  113374. }
  113375. }
  113376. declare module BABYLON {
  113377. interface Scene {
  113378. /** @hidden (Backing field) */
  113379. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113380. /**
  113381. * Gets the postprocess render pipeline manager
  113382. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113383. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113384. */
  113385. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113386. }
  113387. /**
  113388. * Defines the Render Pipeline scene component responsible to rendering pipelines
  113389. */
  113390. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  113391. /**
  113392. * The component name helpfull to identify the component in the list of scene components.
  113393. */
  113394. readonly name: string;
  113395. /**
  113396. * The scene the component belongs to.
  113397. */
  113398. scene: Scene;
  113399. /**
  113400. * Creates a new instance of the component for the given scene
  113401. * @param scene Defines the scene to register the component in
  113402. */
  113403. constructor(scene: Scene);
  113404. /**
  113405. * Registers the component in a given scene
  113406. */
  113407. register(): void;
  113408. /**
  113409. * Rebuilds the elements related to this component in case of
  113410. * context lost for instance.
  113411. */
  113412. rebuild(): void;
  113413. /**
  113414. * Disposes the component and the associated ressources
  113415. */
  113416. dispose(): void;
  113417. private _gatherRenderTargets;
  113418. }
  113419. }
  113420. declare module BABYLON {
  113421. /**
  113422. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113423. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113424. */
  113425. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113426. private _scene;
  113427. private _camerasToBeAttached;
  113428. /**
  113429. * ID of the sharpen post process,
  113430. */
  113431. private readonly SharpenPostProcessId;
  113432. /**
  113433. * @ignore
  113434. * ID of the image processing post process;
  113435. */
  113436. readonly ImageProcessingPostProcessId: string;
  113437. /**
  113438. * @ignore
  113439. * ID of the Fast Approximate Anti-Aliasing post process;
  113440. */
  113441. readonly FxaaPostProcessId: string;
  113442. /**
  113443. * ID of the chromatic aberration post process,
  113444. */
  113445. private readonly ChromaticAberrationPostProcessId;
  113446. /**
  113447. * ID of the grain post process
  113448. */
  113449. private readonly GrainPostProcessId;
  113450. /**
  113451. * Sharpen post process which will apply a sharpen convolution to enhance edges
  113452. */
  113453. sharpen: SharpenPostProcess;
  113454. private _sharpenEffect;
  113455. private bloom;
  113456. /**
  113457. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  113458. */
  113459. depthOfField: DepthOfFieldEffect;
  113460. /**
  113461. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113462. */
  113463. fxaa: FxaaPostProcess;
  113464. /**
  113465. * Image post processing pass used to perform operations such as tone mapping or color grading.
  113466. */
  113467. imageProcessing: ImageProcessingPostProcess;
  113468. /**
  113469. * Chromatic aberration post process which will shift rgb colors in the image
  113470. */
  113471. chromaticAberration: ChromaticAberrationPostProcess;
  113472. private _chromaticAberrationEffect;
  113473. /**
  113474. * Grain post process which add noise to the image
  113475. */
  113476. grain: GrainPostProcess;
  113477. private _grainEffect;
  113478. /**
  113479. * Glow post process which adds a glow to emissive areas of the image
  113480. */
  113481. private _glowLayer;
  113482. /**
  113483. * Animations which can be used to tweak settings over a period of time
  113484. */
  113485. animations: Animation[];
  113486. private _imageProcessingConfigurationObserver;
  113487. private _sharpenEnabled;
  113488. private _bloomEnabled;
  113489. private _depthOfFieldEnabled;
  113490. private _depthOfFieldBlurLevel;
  113491. private _fxaaEnabled;
  113492. private _imageProcessingEnabled;
  113493. private _defaultPipelineTextureType;
  113494. private _bloomScale;
  113495. private _chromaticAberrationEnabled;
  113496. private _grainEnabled;
  113497. private _buildAllowed;
  113498. /**
  113499. * Gets active scene
  113500. */
  113501. readonly scene: Scene;
  113502. /**
  113503. * Enable or disable the sharpen process from the pipeline
  113504. */
  113505. sharpenEnabled: boolean;
  113506. private _resizeObserver;
  113507. private _hardwareScaleLevel;
  113508. private _bloomKernel;
  113509. /**
  113510. * Specifies the size of the bloom blur kernel, relative to the final output size
  113511. */
  113512. bloomKernel: number;
  113513. /**
  113514. * Specifies the weight of the bloom in the final rendering
  113515. */
  113516. private _bloomWeight;
  113517. /**
  113518. * Specifies the luma threshold for the area that will be blurred by the bloom
  113519. */
  113520. private _bloomThreshold;
  113521. private _hdr;
  113522. /**
  113523. * The strength of the bloom.
  113524. */
  113525. bloomWeight: number;
  113526. /**
  113527. * The strength of the bloom.
  113528. */
  113529. bloomThreshold: number;
  113530. /**
  113531. * The scale of the bloom, lower value will provide better performance.
  113532. */
  113533. bloomScale: number;
  113534. /**
  113535. * Enable or disable the bloom from the pipeline
  113536. */
  113537. bloomEnabled: boolean;
  113538. private _rebuildBloom;
  113539. /**
  113540. * If the depth of field is enabled.
  113541. */
  113542. depthOfFieldEnabled: boolean;
  113543. /**
  113544. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113545. */
  113546. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  113547. /**
  113548. * If the anti aliasing is enabled.
  113549. */
  113550. fxaaEnabled: boolean;
  113551. private _samples;
  113552. /**
  113553. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113554. */
  113555. samples: number;
  113556. /**
  113557. * If image processing is enabled.
  113558. */
  113559. imageProcessingEnabled: boolean;
  113560. /**
  113561. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113562. */
  113563. glowLayerEnabled: boolean;
  113564. /**
  113565. * Gets the glow layer (or null if not defined)
  113566. */
  113567. readonly glowLayer: Nullable<GlowLayer>;
  113568. /**
  113569. * Enable or disable the chromaticAberration process from the pipeline
  113570. */
  113571. chromaticAberrationEnabled: boolean;
  113572. /**
  113573. * Enable or disable the grain process from the pipeline
  113574. */
  113575. grainEnabled: boolean;
  113576. /**
  113577. * @constructor
  113578. * @param name - The rendering pipeline name (default: "")
  113579. * @param hdr - If high dynamic range textures should be used (default: true)
  113580. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113581. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113582. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113583. */
  113584. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  113585. /**
  113586. * Get the class name
  113587. * @returns "DefaultRenderingPipeline"
  113588. */
  113589. getClassName(): string;
  113590. /**
  113591. * Force the compilation of the entire pipeline.
  113592. */
  113593. prepare(): void;
  113594. private _hasCleared;
  113595. private _prevPostProcess;
  113596. private _prevPrevPostProcess;
  113597. private _setAutoClearAndTextureSharing;
  113598. private _depthOfFieldSceneObserver;
  113599. private _buildPipeline;
  113600. private _disposePostProcesses;
  113601. /**
  113602. * Adds a camera to the pipeline
  113603. * @param camera the camera to be added
  113604. */
  113605. addCamera(camera: Camera): void;
  113606. /**
  113607. * Removes a camera from the pipeline
  113608. * @param camera the camera to remove
  113609. */
  113610. removeCamera(camera: Camera): void;
  113611. /**
  113612. * Dispose of the pipeline and stop all post processes
  113613. */
  113614. dispose(): void;
  113615. /**
  113616. * Serialize the rendering pipeline (Used when exporting)
  113617. * @returns the serialized object
  113618. */
  113619. serialize(): any;
  113620. /**
  113621. * Parse the serialized pipeline
  113622. * @param source Source pipeline.
  113623. * @param scene The scene to load the pipeline to.
  113624. * @param rootUrl The URL of the serialized pipeline.
  113625. * @returns An instantiated pipeline from the serialized object.
  113626. */
  113627. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  113628. }
  113629. }
  113630. declare module BABYLON {
  113631. /** @hidden */
  113632. export var lensHighlightsPixelShader: {
  113633. name: string;
  113634. shader: string;
  113635. };
  113636. }
  113637. declare module BABYLON {
  113638. /** @hidden */
  113639. export var depthOfFieldPixelShader: {
  113640. name: string;
  113641. shader: string;
  113642. };
  113643. }
  113644. declare module BABYLON {
  113645. /**
  113646. * BABYLON.JS Chromatic Aberration GLSL Shader
  113647. * Author: Olivier Guyot
  113648. * Separates very slightly R, G and B colors on the edges of the screen
  113649. * Inspired by Francois Tarlier & Martins Upitis
  113650. */
  113651. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  113652. /**
  113653. * @ignore
  113654. * The chromatic aberration PostProcess id in the pipeline
  113655. */
  113656. LensChromaticAberrationEffect: string;
  113657. /**
  113658. * @ignore
  113659. * The highlights enhancing PostProcess id in the pipeline
  113660. */
  113661. HighlightsEnhancingEffect: string;
  113662. /**
  113663. * @ignore
  113664. * The depth-of-field PostProcess id in the pipeline
  113665. */
  113666. LensDepthOfFieldEffect: string;
  113667. private _scene;
  113668. private _depthTexture;
  113669. private _grainTexture;
  113670. private _chromaticAberrationPostProcess;
  113671. private _highlightsPostProcess;
  113672. private _depthOfFieldPostProcess;
  113673. private _edgeBlur;
  113674. private _grainAmount;
  113675. private _chromaticAberration;
  113676. private _distortion;
  113677. private _highlightsGain;
  113678. private _highlightsThreshold;
  113679. private _dofDistance;
  113680. private _dofAperture;
  113681. private _dofDarken;
  113682. private _dofPentagon;
  113683. private _blurNoise;
  113684. /**
  113685. * @constructor
  113686. *
  113687. * Effect parameters are as follow:
  113688. * {
  113689. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113690. * edge_blur: number; // from 0 to x (1 for realism)
  113691. * distortion: number; // from 0 to x (1 for realism)
  113692. * grain_amount: number; // from 0 to 1
  113693. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113694. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113695. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113696. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113697. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113698. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113699. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113700. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113701. * }
  113702. * Note: if an effect parameter is unset, effect is disabled
  113703. *
  113704. * @param name The rendering pipeline name
  113705. * @param parameters - An object containing all parameters (see above)
  113706. * @param scene The scene linked to this pipeline
  113707. * @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)
  113708. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113709. */
  113710. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  113711. /**
  113712. * Get the class name
  113713. * @returns "LensRenderingPipeline"
  113714. */
  113715. getClassName(): string;
  113716. /**
  113717. * Gets associated scene
  113718. */
  113719. readonly scene: Scene;
  113720. /**
  113721. * Gets or sets the edge blur
  113722. */
  113723. edgeBlur: number;
  113724. /**
  113725. * Gets or sets the grain amount
  113726. */
  113727. grainAmount: number;
  113728. /**
  113729. * Gets or sets the chromatic aberration amount
  113730. */
  113731. chromaticAberration: number;
  113732. /**
  113733. * Gets or sets the depth of field aperture
  113734. */
  113735. dofAperture: number;
  113736. /**
  113737. * Gets or sets the edge distortion
  113738. */
  113739. edgeDistortion: number;
  113740. /**
  113741. * Gets or sets the depth of field distortion
  113742. */
  113743. dofDistortion: number;
  113744. /**
  113745. * Gets or sets the darken out of focus amount
  113746. */
  113747. darkenOutOfFocus: number;
  113748. /**
  113749. * Gets or sets a boolean indicating if blur noise is enabled
  113750. */
  113751. blurNoise: boolean;
  113752. /**
  113753. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  113754. */
  113755. pentagonBokeh: boolean;
  113756. /**
  113757. * Gets or sets the highlight grain amount
  113758. */
  113759. highlightsGain: number;
  113760. /**
  113761. * Gets or sets the highlight threshold
  113762. */
  113763. highlightsThreshold: number;
  113764. /**
  113765. * Sets the amount of blur at the edges
  113766. * @param amount blur amount
  113767. */
  113768. setEdgeBlur(amount: number): void;
  113769. /**
  113770. * Sets edge blur to 0
  113771. */
  113772. disableEdgeBlur(): void;
  113773. /**
  113774. * Sets the amout of grain
  113775. * @param amount Amount of grain
  113776. */
  113777. setGrainAmount(amount: number): void;
  113778. /**
  113779. * Set grain amount to 0
  113780. */
  113781. disableGrain(): void;
  113782. /**
  113783. * Sets the chromatic aberration amount
  113784. * @param amount amount of chromatic aberration
  113785. */
  113786. setChromaticAberration(amount: number): void;
  113787. /**
  113788. * Sets chromatic aberration amount to 0
  113789. */
  113790. disableChromaticAberration(): void;
  113791. /**
  113792. * Sets the EdgeDistortion amount
  113793. * @param amount amount of EdgeDistortion
  113794. */
  113795. setEdgeDistortion(amount: number): void;
  113796. /**
  113797. * Sets edge distortion to 0
  113798. */
  113799. disableEdgeDistortion(): void;
  113800. /**
  113801. * Sets the FocusDistance amount
  113802. * @param amount amount of FocusDistance
  113803. */
  113804. setFocusDistance(amount: number): void;
  113805. /**
  113806. * Disables depth of field
  113807. */
  113808. disableDepthOfField(): void;
  113809. /**
  113810. * Sets the Aperture amount
  113811. * @param amount amount of Aperture
  113812. */
  113813. setAperture(amount: number): void;
  113814. /**
  113815. * Sets the DarkenOutOfFocus amount
  113816. * @param amount amount of DarkenOutOfFocus
  113817. */
  113818. setDarkenOutOfFocus(amount: number): void;
  113819. private _pentagonBokehIsEnabled;
  113820. /**
  113821. * Creates a pentagon bokeh effect
  113822. */
  113823. enablePentagonBokeh(): void;
  113824. /**
  113825. * Disables the pentagon bokeh effect
  113826. */
  113827. disablePentagonBokeh(): void;
  113828. /**
  113829. * Enables noise blur
  113830. */
  113831. enableNoiseBlur(): void;
  113832. /**
  113833. * Disables noise blur
  113834. */
  113835. disableNoiseBlur(): void;
  113836. /**
  113837. * Sets the HighlightsGain amount
  113838. * @param amount amount of HighlightsGain
  113839. */
  113840. setHighlightsGain(amount: number): void;
  113841. /**
  113842. * Sets the HighlightsThreshold amount
  113843. * @param amount amount of HighlightsThreshold
  113844. */
  113845. setHighlightsThreshold(amount: number): void;
  113846. /**
  113847. * Disables highlights
  113848. */
  113849. disableHighlights(): void;
  113850. /**
  113851. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113852. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113853. */
  113854. dispose(disableDepthRender?: boolean): void;
  113855. private _createChromaticAberrationPostProcess;
  113856. private _createHighlightsPostProcess;
  113857. private _createDepthOfFieldPostProcess;
  113858. private _createGrainTexture;
  113859. }
  113860. }
  113861. declare module BABYLON {
  113862. /** @hidden */
  113863. export var ssao2PixelShader: {
  113864. name: string;
  113865. shader: string;
  113866. };
  113867. }
  113868. declare module BABYLON {
  113869. /** @hidden */
  113870. export var ssaoCombinePixelShader: {
  113871. name: string;
  113872. shader: string;
  113873. };
  113874. }
  113875. declare module BABYLON {
  113876. /**
  113877. * Render pipeline to produce ssao effect
  113878. */
  113879. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  113880. /**
  113881. * @ignore
  113882. * The PassPostProcess id in the pipeline that contains the original scene color
  113883. */
  113884. SSAOOriginalSceneColorEffect: string;
  113885. /**
  113886. * @ignore
  113887. * The SSAO PostProcess id in the pipeline
  113888. */
  113889. SSAORenderEffect: string;
  113890. /**
  113891. * @ignore
  113892. * The horizontal blur PostProcess id in the pipeline
  113893. */
  113894. SSAOBlurHRenderEffect: string;
  113895. /**
  113896. * @ignore
  113897. * The vertical blur PostProcess id in the pipeline
  113898. */
  113899. SSAOBlurVRenderEffect: string;
  113900. /**
  113901. * @ignore
  113902. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113903. */
  113904. SSAOCombineRenderEffect: string;
  113905. /**
  113906. * The output strength of the SSAO post-process. Default value is 1.0.
  113907. */
  113908. totalStrength: number;
  113909. /**
  113910. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  113911. */
  113912. maxZ: number;
  113913. /**
  113914. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  113915. */
  113916. minZAspect: number;
  113917. private _samples;
  113918. /**
  113919. * Number of samples used for the SSAO calculations. Default value is 8
  113920. */
  113921. samples: number;
  113922. private _textureSamples;
  113923. /**
  113924. * Number of samples to use for antialiasing
  113925. */
  113926. textureSamples: number;
  113927. /**
  113928. * Ratio object used for SSAO ratio and blur ratio
  113929. */
  113930. private _ratio;
  113931. /**
  113932. * Dynamically generated sphere sampler.
  113933. */
  113934. private _sampleSphere;
  113935. /**
  113936. * Blur filter offsets
  113937. */
  113938. private _samplerOffsets;
  113939. private _expensiveBlur;
  113940. /**
  113941. * If bilateral blur should be used
  113942. */
  113943. expensiveBlur: boolean;
  113944. /**
  113945. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  113946. */
  113947. radius: number;
  113948. /**
  113949. * The base color of the SSAO post-process
  113950. * The final result is "base + ssao" between [0, 1]
  113951. */
  113952. base: number;
  113953. /**
  113954. * Support test.
  113955. */
  113956. static readonly IsSupported: boolean;
  113957. private _scene;
  113958. private _depthTexture;
  113959. private _normalTexture;
  113960. private _randomTexture;
  113961. private _originalColorPostProcess;
  113962. private _ssaoPostProcess;
  113963. private _blurHPostProcess;
  113964. private _blurVPostProcess;
  113965. private _ssaoCombinePostProcess;
  113966. private _firstUpdate;
  113967. /**
  113968. * Gets active scene
  113969. */
  113970. readonly scene: Scene;
  113971. /**
  113972. * @constructor
  113973. * @param name The rendering pipeline name
  113974. * @param scene The scene linked to this pipeline
  113975. * @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 }
  113976. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113977. */
  113978. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113979. /**
  113980. * Get the class name
  113981. * @returns "SSAO2RenderingPipeline"
  113982. */
  113983. getClassName(): string;
  113984. /**
  113985. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113986. */
  113987. dispose(disableGeometryBufferRenderer?: boolean): void;
  113988. private _createBlurPostProcess;
  113989. /** @hidden */
  113990. _rebuild(): void;
  113991. private _bits;
  113992. private _radicalInverse_VdC;
  113993. private _hammersley;
  113994. private _hemisphereSample_uniform;
  113995. private _generateHemisphere;
  113996. private _createSSAOPostProcess;
  113997. private _createSSAOCombinePostProcess;
  113998. private _createRandomTexture;
  113999. /**
  114000. * Serialize the rendering pipeline (Used when exporting)
  114001. * @returns the serialized object
  114002. */
  114003. serialize(): any;
  114004. /**
  114005. * Parse the serialized pipeline
  114006. * @param source Source pipeline.
  114007. * @param scene The scene to load the pipeline to.
  114008. * @param rootUrl The URL of the serialized pipeline.
  114009. * @returns An instantiated pipeline from the serialized object.
  114010. */
  114011. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  114012. }
  114013. }
  114014. declare module BABYLON {
  114015. /** @hidden */
  114016. export var ssaoPixelShader: {
  114017. name: string;
  114018. shader: string;
  114019. };
  114020. }
  114021. declare module BABYLON {
  114022. /**
  114023. * Render pipeline to produce ssao effect
  114024. */
  114025. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  114026. /**
  114027. * @ignore
  114028. * The PassPostProcess id in the pipeline that contains the original scene color
  114029. */
  114030. SSAOOriginalSceneColorEffect: string;
  114031. /**
  114032. * @ignore
  114033. * The SSAO PostProcess id in the pipeline
  114034. */
  114035. SSAORenderEffect: string;
  114036. /**
  114037. * @ignore
  114038. * The horizontal blur PostProcess id in the pipeline
  114039. */
  114040. SSAOBlurHRenderEffect: string;
  114041. /**
  114042. * @ignore
  114043. * The vertical blur PostProcess id in the pipeline
  114044. */
  114045. SSAOBlurVRenderEffect: string;
  114046. /**
  114047. * @ignore
  114048. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114049. */
  114050. SSAOCombineRenderEffect: string;
  114051. /**
  114052. * The output strength of the SSAO post-process. Default value is 1.0.
  114053. */
  114054. totalStrength: number;
  114055. /**
  114056. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  114057. */
  114058. radius: number;
  114059. /**
  114060. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  114061. * Must not be equal to fallOff and superior to fallOff.
  114062. * Default value is 0.0075
  114063. */
  114064. area: number;
  114065. /**
  114066. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  114067. * Must not be equal to area and inferior to area.
  114068. * Default value is 0.000001
  114069. */
  114070. fallOff: number;
  114071. /**
  114072. * The base color of the SSAO post-process
  114073. * The final result is "base + ssao" between [0, 1]
  114074. */
  114075. base: number;
  114076. private _scene;
  114077. private _depthTexture;
  114078. private _randomTexture;
  114079. private _originalColorPostProcess;
  114080. private _ssaoPostProcess;
  114081. private _blurHPostProcess;
  114082. private _blurVPostProcess;
  114083. private _ssaoCombinePostProcess;
  114084. private _firstUpdate;
  114085. /**
  114086. * Gets active scene
  114087. */
  114088. readonly scene: Scene;
  114089. /**
  114090. * @constructor
  114091. * @param name - The rendering pipeline name
  114092. * @param scene - The scene linked to this pipeline
  114093. * @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 }
  114094. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  114095. */
  114096. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  114097. /**
  114098. * Get the class name
  114099. * @returns "SSAORenderingPipeline"
  114100. */
  114101. getClassName(): string;
  114102. /**
  114103. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114104. */
  114105. dispose(disableDepthRender?: boolean): void;
  114106. private _createBlurPostProcess;
  114107. /** @hidden */
  114108. _rebuild(): void;
  114109. private _createSSAOPostProcess;
  114110. private _createSSAOCombinePostProcess;
  114111. private _createRandomTexture;
  114112. }
  114113. }
  114114. declare module BABYLON {
  114115. /** @hidden */
  114116. export var standardPixelShader: {
  114117. name: string;
  114118. shader: string;
  114119. };
  114120. }
  114121. declare module BABYLON {
  114122. /**
  114123. * Standard rendering pipeline
  114124. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114125. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114126. */
  114127. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  114128. /**
  114129. * Public members
  114130. */
  114131. /**
  114132. * Post-process which contains the original scene color before the pipeline applies all the effects
  114133. */
  114134. originalPostProcess: Nullable<PostProcess>;
  114135. /**
  114136. * Post-process used to down scale an image x4
  114137. */
  114138. downSampleX4PostProcess: Nullable<PostProcess>;
  114139. /**
  114140. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114141. */
  114142. brightPassPostProcess: Nullable<PostProcess>;
  114143. /**
  114144. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114145. */
  114146. blurHPostProcesses: PostProcess[];
  114147. /**
  114148. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114149. */
  114150. blurVPostProcesses: PostProcess[];
  114151. /**
  114152. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114153. */
  114154. textureAdderPostProcess: Nullable<PostProcess>;
  114155. /**
  114156. * Post-process used to create volumetric lighting effect
  114157. */
  114158. volumetricLightPostProcess: Nullable<PostProcess>;
  114159. /**
  114160. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114161. */
  114162. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  114163. /**
  114164. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114165. */
  114166. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  114167. /**
  114168. * Post-process used to merge the volumetric light effect and the real scene color
  114169. */
  114170. volumetricLightMergePostProces: Nullable<PostProcess>;
  114171. /**
  114172. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114173. */
  114174. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  114175. /**
  114176. * Base post-process used to calculate the average luminance of the final image for HDR
  114177. */
  114178. luminancePostProcess: Nullable<PostProcess>;
  114179. /**
  114180. * Post-processes used to create down sample post-processes in order to get
  114181. * the average luminance of the final image for HDR
  114182. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114183. */
  114184. luminanceDownSamplePostProcesses: PostProcess[];
  114185. /**
  114186. * Post-process used to create a HDR effect (light adaptation)
  114187. */
  114188. hdrPostProcess: Nullable<PostProcess>;
  114189. /**
  114190. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114191. */
  114192. textureAdderFinalPostProcess: Nullable<PostProcess>;
  114193. /**
  114194. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114195. */
  114196. lensFlareFinalPostProcess: Nullable<PostProcess>;
  114197. /**
  114198. * Post-process used to merge the final HDR post-process and the real scene color
  114199. */
  114200. hdrFinalPostProcess: Nullable<PostProcess>;
  114201. /**
  114202. * Post-process used to create a lens flare effect
  114203. */
  114204. lensFlarePostProcess: Nullable<PostProcess>;
  114205. /**
  114206. * Post-process that merges the result of the lens flare post-process and the real scene color
  114207. */
  114208. lensFlareComposePostProcess: Nullable<PostProcess>;
  114209. /**
  114210. * Post-process used to create a motion blur effect
  114211. */
  114212. motionBlurPostProcess: Nullable<PostProcess>;
  114213. /**
  114214. * Post-process used to create a depth of field effect
  114215. */
  114216. depthOfFieldPostProcess: Nullable<PostProcess>;
  114217. /**
  114218. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114219. */
  114220. fxaaPostProcess: Nullable<FxaaPostProcess>;
  114221. /**
  114222. * Represents the brightness threshold in order to configure the illuminated surfaces
  114223. */
  114224. brightThreshold: number;
  114225. /**
  114226. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114227. */
  114228. blurWidth: number;
  114229. /**
  114230. * Sets if the blur for highlighted surfaces must be only horizontal
  114231. */
  114232. horizontalBlur: boolean;
  114233. /**
  114234. * Gets the overall exposure used by the pipeline
  114235. */
  114236. /**
  114237. * Sets the overall exposure used by the pipeline
  114238. */
  114239. exposure: number;
  114240. /**
  114241. * Texture used typically to simulate "dirty" on camera lens
  114242. */
  114243. lensTexture: Nullable<Texture>;
  114244. /**
  114245. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114246. */
  114247. volumetricLightCoefficient: number;
  114248. /**
  114249. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114250. */
  114251. volumetricLightPower: number;
  114252. /**
  114253. * Used the set the blur intensity to smooth the volumetric lights
  114254. */
  114255. volumetricLightBlurScale: number;
  114256. /**
  114257. * Light (spot or directional) used to generate the volumetric lights rays
  114258. * The source light must have a shadow generate so the pipeline can get its
  114259. * depth map
  114260. */
  114261. sourceLight: Nullable<SpotLight | DirectionalLight>;
  114262. /**
  114263. * For eye adaptation, represents the minimum luminance the eye can see
  114264. */
  114265. hdrMinimumLuminance: number;
  114266. /**
  114267. * For eye adaptation, represents the decrease luminance speed
  114268. */
  114269. hdrDecreaseRate: number;
  114270. /**
  114271. * For eye adaptation, represents the increase luminance speed
  114272. */
  114273. hdrIncreaseRate: number;
  114274. /**
  114275. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114276. */
  114277. /**
  114278. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114279. */
  114280. hdrAutoExposure: boolean;
  114281. /**
  114282. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114283. */
  114284. lensColorTexture: Nullable<Texture>;
  114285. /**
  114286. * The overall strengh for the lens flare effect
  114287. */
  114288. lensFlareStrength: number;
  114289. /**
  114290. * Dispersion coefficient for lens flare ghosts
  114291. */
  114292. lensFlareGhostDispersal: number;
  114293. /**
  114294. * Main lens flare halo width
  114295. */
  114296. lensFlareHaloWidth: number;
  114297. /**
  114298. * Based on the lens distortion effect, defines how much the lens flare result
  114299. * is distorted
  114300. */
  114301. lensFlareDistortionStrength: number;
  114302. /**
  114303. * Lens star texture must be used to simulate rays on the flares and is available
  114304. * in the documentation
  114305. */
  114306. lensStarTexture: Nullable<Texture>;
  114307. /**
  114308. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114309. * flare effect by taking account of the dirt texture
  114310. */
  114311. lensFlareDirtTexture: Nullable<Texture>;
  114312. /**
  114313. * Represents the focal length for the depth of field effect
  114314. */
  114315. depthOfFieldDistance: number;
  114316. /**
  114317. * Represents the blur intensity for the blurred part of the depth of field effect
  114318. */
  114319. depthOfFieldBlurWidth: number;
  114320. /**
  114321. * For motion blur, defines how much the image is blurred by the movement
  114322. */
  114323. motionStrength: number;
  114324. /**
  114325. * List of animations for the pipeline (IAnimatable implementation)
  114326. */
  114327. animations: Animation[];
  114328. /**
  114329. * Private members
  114330. */
  114331. private _scene;
  114332. private _currentDepthOfFieldSource;
  114333. private _basePostProcess;
  114334. private _fixedExposure;
  114335. private _currentExposure;
  114336. private _hdrAutoExposure;
  114337. private _hdrCurrentLuminance;
  114338. private _floatTextureType;
  114339. private _ratio;
  114340. private _bloomEnabled;
  114341. private _depthOfFieldEnabled;
  114342. private _vlsEnabled;
  114343. private _lensFlareEnabled;
  114344. private _hdrEnabled;
  114345. private _motionBlurEnabled;
  114346. private _fxaaEnabled;
  114347. private _motionBlurSamples;
  114348. private _volumetricLightStepsCount;
  114349. private _samples;
  114350. /**
  114351. * @ignore
  114352. * Specifies if the bloom pipeline is enabled
  114353. */
  114354. BloomEnabled: boolean;
  114355. /**
  114356. * @ignore
  114357. * Specifies if the depth of field pipeline is enabed
  114358. */
  114359. DepthOfFieldEnabled: boolean;
  114360. /**
  114361. * @ignore
  114362. * Specifies if the lens flare pipeline is enabed
  114363. */
  114364. LensFlareEnabled: boolean;
  114365. /**
  114366. * @ignore
  114367. * Specifies if the HDR pipeline is enabled
  114368. */
  114369. HDREnabled: boolean;
  114370. /**
  114371. * @ignore
  114372. * Specifies if the volumetric lights scattering effect is enabled
  114373. */
  114374. VLSEnabled: boolean;
  114375. /**
  114376. * @ignore
  114377. * Specifies if the motion blur effect is enabled
  114378. */
  114379. MotionBlurEnabled: boolean;
  114380. /**
  114381. * Specifies if anti-aliasing is enabled
  114382. */
  114383. fxaaEnabled: boolean;
  114384. /**
  114385. * Specifies the number of steps used to calculate the volumetric lights
  114386. * Typically in interval [50, 200]
  114387. */
  114388. volumetricLightStepsCount: number;
  114389. /**
  114390. * Specifies the number of samples used for the motion blur effect
  114391. * Typically in interval [16, 64]
  114392. */
  114393. motionBlurSamples: number;
  114394. /**
  114395. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  114396. */
  114397. samples: number;
  114398. /**
  114399. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114400. * @constructor
  114401. * @param name The rendering pipeline name
  114402. * @param scene The scene linked to this pipeline
  114403. * @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)
  114404. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114405. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114406. */
  114407. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  114408. private _buildPipeline;
  114409. private _createDownSampleX4PostProcess;
  114410. private _createBrightPassPostProcess;
  114411. private _createBlurPostProcesses;
  114412. private _createTextureAdderPostProcess;
  114413. private _createVolumetricLightPostProcess;
  114414. private _createLuminancePostProcesses;
  114415. private _createHdrPostProcess;
  114416. private _createLensFlarePostProcess;
  114417. private _createDepthOfFieldPostProcess;
  114418. private _createMotionBlurPostProcess;
  114419. private _getDepthTexture;
  114420. private _disposePostProcesses;
  114421. /**
  114422. * Dispose of the pipeline and stop all post processes
  114423. */
  114424. dispose(): void;
  114425. /**
  114426. * Serialize the rendering pipeline (Used when exporting)
  114427. * @returns the serialized object
  114428. */
  114429. serialize(): any;
  114430. /**
  114431. * Parse the serialized pipeline
  114432. * @param source Source pipeline.
  114433. * @param scene The scene to load the pipeline to.
  114434. * @param rootUrl The URL of the serialized pipeline.
  114435. * @returns An instantiated pipeline from the serialized object.
  114436. */
  114437. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  114438. /**
  114439. * Luminance steps
  114440. */
  114441. static LuminanceSteps: number;
  114442. }
  114443. }
  114444. declare module BABYLON {
  114445. /** @hidden */
  114446. export var tonemapPixelShader: {
  114447. name: string;
  114448. shader: string;
  114449. };
  114450. }
  114451. declare module BABYLON {
  114452. /** Defines operator used for tonemapping */
  114453. export enum TonemappingOperator {
  114454. /** Hable */
  114455. Hable = 0,
  114456. /** Reinhard */
  114457. Reinhard = 1,
  114458. /** HejiDawson */
  114459. HejiDawson = 2,
  114460. /** Photographic */
  114461. Photographic = 3
  114462. }
  114463. /**
  114464. * Defines a post process to apply tone mapping
  114465. */
  114466. export class TonemapPostProcess extends PostProcess {
  114467. private _operator;
  114468. /** Defines the required exposure adjustement */
  114469. exposureAdjustment: number;
  114470. /**
  114471. * Creates a new TonemapPostProcess
  114472. * @param name defines the name of the postprocess
  114473. * @param _operator defines the operator to use
  114474. * @param exposureAdjustment defines the required exposure adjustement
  114475. * @param camera defines the camera to use (can be null)
  114476. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  114477. * @param engine defines the hosting engine (can be ignore if camera is set)
  114478. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114479. */
  114480. constructor(name: string, _operator: TonemappingOperator,
  114481. /** Defines the required exposure adjustement */
  114482. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  114483. }
  114484. }
  114485. declare module BABYLON {
  114486. /** @hidden */
  114487. export var depthVertexShader: {
  114488. name: string;
  114489. shader: string;
  114490. };
  114491. }
  114492. declare module BABYLON {
  114493. /** @hidden */
  114494. export var volumetricLightScatteringPixelShader: {
  114495. name: string;
  114496. shader: string;
  114497. };
  114498. }
  114499. declare module BABYLON {
  114500. /** @hidden */
  114501. export var volumetricLightScatteringPassPixelShader: {
  114502. name: string;
  114503. shader: string;
  114504. };
  114505. }
  114506. declare module BABYLON {
  114507. /**
  114508. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  114509. */
  114510. export class VolumetricLightScatteringPostProcess extends PostProcess {
  114511. private _volumetricLightScatteringPass;
  114512. private _volumetricLightScatteringRTT;
  114513. private _viewPort;
  114514. private _screenCoordinates;
  114515. private _cachedDefines;
  114516. /**
  114517. * If not undefined, the mesh position is computed from the attached node position
  114518. */
  114519. attachedNode: {
  114520. position: Vector3;
  114521. };
  114522. /**
  114523. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  114524. */
  114525. customMeshPosition: Vector3;
  114526. /**
  114527. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  114528. */
  114529. useCustomMeshPosition: boolean;
  114530. /**
  114531. * If the post-process should inverse the light scattering direction
  114532. */
  114533. invert: boolean;
  114534. /**
  114535. * The internal mesh used by the post-process
  114536. */
  114537. mesh: Mesh;
  114538. /**
  114539. * @hidden
  114540. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  114541. */
  114542. useDiffuseColor: boolean;
  114543. /**
  114544. * Array containing the excluded meshes not rendered in the internal pass
  114545. */
  114546. excludedMeshes: AbstractMesh[];
  114547. /**
  114548. * Controls the overall intensity of the post-process
  114549. */
  114550. exposure: number;
  114551. /**
  114552. * Dissipates each sample's contribution in range [0, 1]
  114553. */
  114554. decay: number;
  114555. /**
  114556. * Controls the overall intensity of each sample
  114557. */
  114558. weight: number;
  114559. /**
  114560. * Controls the density of each sample
  114561. */
  114562. density: number;
  114563. /**
  114564. * @constructor
  114565. * @param name The post-process name
  114566. * @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)
  114567. * @param camera The camera that the post-process will be attached to
  114568. * @param mesh The mesh used to create the light scattering
  114569. * @param samples The post-process quality, default 100
  114570. * @param samplingModeThe post-process filtering mode
  114571. * @param engine The babylon engine
  114572. * @param reusable If the post-process is reusable
  114573. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  114574. */
  114575. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  114576. /**
  114577. * Returns the string "VolumetricLightScatteringPostProcess"
  114578. * @returns "VolumetricLightScatteringPostProcess"
  114579. */
  114580. getClassName(): string;
  114581. private _isReady;
  114582. /**
  114583. * Sets the new light position for light scattering effect
  114584. * @param position The new custom light position
  114585. */
  114586. setCustomMeshPosition(position: Vector3): void;
  114587. /**
  114588. * Returns the light position for light scattering effect
  114589. * @return Vector3 The custom light position
  114590. */
  114591. getCustomMeshPosition(): Vector3;
  114592. /**
  114593. * Disposes the internal assets and detaches the post-process from the camera
  114594. */
  114595. dispose(camera: Camera): void;
  114596. /**
  114597. * Returns the render target texture used by the post-process
  114598. * @return the render target texture used by the post-process
  114599. */
  114600. getPass(): RenderTargetTexture;
  114601. private _meshExcluded;
  114602. private _createPass;
  114603. private _updateMeshScreenCoordinates;
  114604. /**
  114605. * Creates a default mesh for the Volumeric Light Scattering post-process
  114606. * @param name The mesh name
  114607. * @param scene The scene where to create the mesh
  114608. * @return the default mesh
  114609. */
  114610. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  114611. }
  114612. }
  114613. declare module BABYLON {
  114614. interface Scene {
  114615. /** @hidden (Backing field) */
  114616. _boundingBoxRenderer: BoundingBoxRenderer;
  114617. /** @hidden (Backing field) */
  114618. _forceShowBoundingBoxes: boolean;
  114619. /**
  114620. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  114621. */
  114622. forceShowBoundingBoxes: boolean;
  114623. /**
  114624. * Gets the bounding box renderer associated with the scene
  114625. * @returns a BoundingBoxRenderer
  114626. */
  114627. getBoundingBoxRenderer(): BoundingBoxRenderer;
  114628. }
  114629. interface AbstractMesh {
  114630. /** @hidden (Backing field) */
  114631. _showBoundingBox: boolean;
  114632. /**
  114633. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  114634. */
  114635. showBoundingBox: boolean;
  114636. }
  114637. /**
  114638. * Component responsible of rendering the bounding box of the meshes in a scene.
  114639. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  114640. */
  114641. export class BoundingBoxRenderer implements ISceneComponent {
  114642. /**
  114643. * The component name helpfull to identify the component in the list of scene components.
  114644. */
  114645. readonly name: string;
  114646. /**
  114647. * The scene the component belongs to.
  114648. */
  114649. scene: Scene;
  114650. /**
  114651. * Color of the bounding box lines placed in front of an object
  114652. */
  114653. frontColor: Color3;
  114654. /**
  114655. * Color of the bounding box lines placed behind an object
  114656. */
  114657. backColor: Color3;
  114658. /**
  114659. * Defines if the renderer should show the back lines or not
  114660. */
  114661. showBackLines: boolean;
  114662. /**
  114663. * @hidden
  114664. */
  114665. renderList: SmartArray<BoundingBox>;
  114666. private _colorShader;
  114667. private _vertexBuffers;
  114668. private _indexBuffer;
  114669. /**
  114670. * Instantiates a new bounding box renderer in a scene.
  114671. * @param scene the scene the renderer renders in
  114672. */
  114673. constructor(scene: Scene);
  114674. /**
  114675. * Registers the component in a given scene
  114676. */
  114677. register(): void;
  114678. private _evaluateSubMesh;
  114679. private _activeMesh;
  114680. private _prepareRessources;
  114681. private _createIndexBuffer;
  114682. /**
  114683. * Rebuilds the elements related to this component in case of
  114684. * context lost for instance.
  114685. */
  114686. rebuild(): void;
  114687. /**
  114688. * @hidden
  114689. */
  114690. reset(): void;
  114691. /**
  114692. * Render the bounding boxes of a specific rendering group
  114693. * @param renderingGroupId defines the rendering group to render
  114694. */
  114695. render(renderingGroupId: number): void;
  114696. /**
  114697. * In case of occlusion queries, we can render the occlusion bounding box through this method
  114698. * @param mesh Define the mesh to render the occlusion bounding box for
  114699. */
  114700. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  114701. /**
  114702. * Dispose and release the resources attached to this renderer.
  114703. */
  114704. dispose(): void;
  114705. }
  114706. }
  114707. declare module BABYLON {
  114708. /** @hidden */
  114709. export var depthPixelShader: {
  114710. name: string;
  114711. shader: string;
  114712. };
  114713. }
  114714. declare module BABYLON {
  114715. /**
  114716. * This represents a depth renderer in Babylon.
  114717. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  114718. */
  114719. export class DepthRenderer {
  114720. private _scene;
  114721. private _depthMap;
  114722. private _effect;
  114723. private _cachedDefines;
  114724. private _camera;
  114725. /**
  114726. * Specifiess that the depth renderer will only be used within
  114727. * the camera it is created for.
  114728. * This can help forcing its rendering during the camera processing.
  114729. */
  114730. useOnlyInActiveCamera: boolean;
  114731. /** @hidden */
  114732. static _SceneComponentInitialization: (scene: Scene) => void;
  114733. /**
  114734. * Instantiates a depth renderer
  114735. * @param scene The scene the renderer belongs to
  114736. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  114737. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  114738. */
  114739. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  114740. /**
  114741. * Creates the depth rendering effect and checks if the effect is ready.
  114742. * @param subMesh The submesh to be used to render the depth map of
  114743. * @param useInstances If multiple world instances should be used
  114744. * @returns if the depth renderer is ready to render the depth map
  114745. */
  114746. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114747. /**
  114748. * Gets the texture which the depth map will be written to.
  114749. * @returns The depth map texture
  114750. */
  114751. getDepthMap(): RenderTargetTexture;
  114752. /**
  114753. * Disposes of the depth renderer.
  114754. */
  114755. dispose(): void;
  114756. }
  114757. }
  114758. declare module BABYLON {
  114759. interface Scene {
  114760. /** @hidden (Backing field) */
  114761. _depthRenderer: {
  114762. [id: string]: DepthRenderer;
  114763. };
  114764. /**
  114765. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  114766. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  114767. * @returns the created depth renderer
  114768. */
  114769. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  114770. /**
  114771. * Disables a depth renderer for a given camera
  114772. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  114773. */
  114774. disableDepthRenderer(camera?: Nullable<Camera>): void;
  114775. }
  114776. /**
  114777. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  114778. * in several rendering techniques.
  114779. */
  114780. export class DepthRendererSceneComponent implements ISceneComponent {
  114781. /**
  114782. * The component name helpfull to identify the component in the list of scene components.
  114783. */
  114784. readonly name: string;
  114785. /**
  114786. * The scene the component belongs to.
  114787. */
  114788. scene: Scene;
  114789. /**
  114790. * Creates a new instance of the component for the given scene
  114791. * @param scene Defines the scene to register the component in
  114792. */
  114793. constructor(scene: Scene);
  114794. /**
  114795. * Registers the component in a given scene
  114796. */
  114797. register(): void;
  114798. /**
  114799. * Rebuilds the elements related to this component in case of
  114800. * context lost for instance.
  114801. */
  114802. rebuild(): void;
  114803. /**
  114804. * Disposes the component and the associated ressources
  114805. */
  114806. dispose(): void;
  114807. private _gatherRenderTargets;
  114808. private _gatherActiveCameraRenderTargets;
  114809. }
  114810. }
  114811. declare module BABYLON {
  114812. /** @hidden */
  114813. export var outlinePixelShader: {
  114814. name: string;
  114815. shader: string;
  114816. };
  114817. }
  114818. declare module BABYLON {
  114819. /** @hidden */
  114820. export var outlineVertexShader: {
  114821. name: string;
  114822. shader: string;
  114823. };
  114824. }
  114825. declare module BABYLON {
  114826. interface Scene {
  114827. /** @hidden */
  114828. _outlineRenderer: OutlineRenderer;
  114829. /**
  114830. * Gets the outline renderer associated with the scene
  114831. * @returns a OutlineRenderer
  114832. */
  114833. getOutlineRenderer(): OutlineRenderer;
  114834. }
  114835. interface AbstractMesh {
  114836. /** @hidden (Backing field) */
  114837. _renderOutline: boolean;
  114838. /**
  114839. * Gets or sets a boolean indicating if the outline must be rendered as well
  114840. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  114841. */
  114842. renderOutline: boolean;
  114843. /** @hidden (Backing field) */
  114844. _renderOverlay: boolean;
  114845. /**
  114846. * Gets or sets a boolean indicating if the overlay must be rendered as well
  114847. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  114848. */
  114849. renderOverlay: boolean;
  114850. }
  114851. /**
  114852. * This class is responsible to draw bothe outline/overlay of meshes.
  114853. * It should not be used directly but through the available method on mesh.
  114854. */
  114855. export class OutlineRenderer implements ISceneComponent {
  114856. /**
  114857. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  114858. */
  114859. private static _StencilReference;
  114860. /**
  114861. * The name of the component. Each component must have a unique name.
  114862. */
  114863. name: string;
  114864. /**
  114865. * The scene the component belongs to.
  114866. */
  114867. scene: Scene;
  114868. /**
  114869. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  114870. */
  114871. zOffset: number;
  114872. private _engine;
  114873. private _effect;
  114874. private _cachedDefines;
  114875. private _savedDepthWrite;
  114876. /**
  114877. * Instantiates a new outline renderer. (There could be only one per scene).
  114878. * @param scene Defines the scene it belongs to
  114879. */
  114880. constructor(scene: Scene);
  114881. /**
  114882. * Register the component to one instance of a scene.
  114883. */
  114884. register(): void;
  114885. /**
  114886. * Rebuilds the elements related to this component in case of
  114887. * context lost for instance.
  114888. */
  114889. rebuild(): void;
  114890. /**
  114891. * Disposes the component and the associated ressources.
  114892. */
  114893. dispose(): void;
  114894. /**
  114895. * Renders the outline in the canvas.
  114896. * @param subMesh Defines the sumesh to render
  114897. * @param batch Defines the batch of meshes in case of instances
  114898. * @param useOverlay Defines if the rendering is for the overlay or the outline
  114899. */
  114900. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  114901. /**
  114902. * Returns whether or not the outline renderer is ready for a given submesh.
  114903. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  114904. * @param subMesh Defines the submesh to check readyness for
  114905. * @param useInstances Defines wheter wee are trying to render instances or not
  114906. * @returns true if ready otherwise false
  114907. */
  114908. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114909. private _beforeRenderingMesh;
  114910. private _afterRenderingMesh;
  114911. }
  114912. }
  114913. declare module BABYLON {
  114914. /**
  114915. * Defines the list of states available for a task inside a AssetsManager
  114916. */
  114917. export enum AssetTaskState {
  114918. /**
  114919. * Initialization
  114920. */
  114921. INIT = 0,
  114922. /**
  114923. * Running
  114924. */
  114925. RUNNING = 1,
  114926. /**
  114927. * Done
  114928. */
  114929. DONE = 2,
  114930. /**
  114931. * Error
  114932. */
  114933. ERROR = 3
  114934. }
  114935. /**
  114936. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  114937. */
  114938. export abstract class AbstractAssetTask {
  114939. /**
  114940. * Task name
  114941. */ name: string;
  114942. /**
  114943. * Callback called when the task is successful
  114944. */
  114945. onSuccess: (task: any) => void;
  114946. /**
  114947. * Callback called when the task is not successful
  114948. */
  114949. onError: (task: any, message?: string, exception?: any) => void;
  114950. /**
  114951. * Creates a new AssetsManager
  114952. * @param name defines the name of the task
  114953. */
  114954. constructor(
  114955. /**
  114956. * Task name
  114957. */ name: string);
  114958. private _isCompleted;
  114959. private _taskState;
  114960. private _errorObject;
  114961. /**
  114962. * Get if the task is completed
  114963. */
  114964. readonly isCompleted: boolean;
  114965. /**
  114966. * Gets the current state of the task
  114967. */
  114968. readonly taskState: AssetTaskState;
  114969. /**
  114970. * Gets the current error object (if task is in error)
  114971. */
  114972. readonly errorObject: {
  114973. message?: string;
  114974. exception?: any;
  114975. };
  114976. /**
  114977. * Internal only
  114978. * @hidden
  114979. */
  114980. _setErrorObject(message?: string, exception?: any): void;
  114981. /**
  114982. * Execute the current task
  114983. * @param scene defines the scene where you want your assets to be loaded
  114984. * @param onSuccess is a callback called when the task is successfully executed
  114985. * @param onError is a callback called if an error occurs
  114986. */
  114987. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114988. /**
  114989. * Execute the current task
  114990. * @param scene defines the scene where you want your assets to be loaded
  114991. * @param onSuccess is a callback called when the task is successfully executed
  114992. * @param onError is a callback called if an error occurs
  114993. */
  114994. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114995. /**
  114996. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  114997. * This can be used with failed tasks that have the reason for failure fixed.
  114998. */
  114999. reset(): void;
  115000. private onErrorCallback;
  115001. private onDoneCallback;
  115002. }
  115003. /**
  115004. * Define the interface used by progress events raised during assets loading
  115005. */
  115006. export interface IAssetsProgressEvent {
  115007. /**
  115008. * Defines the number of remaining tasks to process
  115009. */
  115010. remainingCount: number;
  115011. /**
  115012. * Defines the total number of tasks
  115013. */
  115014. totalCount: number;
  115015. /**
  115016. * Defines the task that was just processed
  115017. */
  115018. task: AbstractAssetTask;
  115019. }
  115020. /**
  115021. * Class used to share progress information about assets loading
  115022. */
  115023. export class AssetsProgressEvent implements IAssetsProgressEvent {
  115024. /**
  115025. * Defines the number of remaining tasks to process
  115026. */
  115027. remainingCount: number;
  115028. /**
  115029. * Defines the total number of tasks
  115030. */
  115031. totalCount: number;
  115032. /**
  115033. * Defines the task that was just processed
  115034. */
  115035. task: AbstractAssetTask;
  115036. /**
  115037. * Creates a AssetsProgressEvent
  115038. * @param remainingCount defines the number of remaining tasks to process
  115039. * @param totalCount defines the total number of tasks
  115040. * @param task defines the task that was just processed
  115041. */
  115042. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  115043. }
  115044. /**
  115045. * Define a task used by AssetsManager to load meshes
  115046. */
  115047. export class MeshAssetTask extends AbstractAssetTask {
  115048. /**
  115049. * Defines the name of the task
  115050. */
  115051. name: string;
  115052. /**
  115053. * Defines the list of mesh's names you want to load
  115054. */
  115055. meshesNames: any;
  115056. /**
  115057. * Defines the root url to use as a base to load your meshes and associated resources
  115058. */
  115059. rootUrl: string;
  115060. /**
  115061. * Defines the filename of the scene to load from
  115062. */
  115063. sceneFilename: string;
  115064. /**
  115065. * Gets the list of loaded meshes
  115066. */
  115067. loadedMeshes: Array<AbstractMesh>;
  115068. /**
  115069. * Gets the list of loaded particle systems
  115070. */
  115071. loadedParticleSystems: Array<IParticleSystem>;
  115072. /**
  115073. * Gets the list of loaded skeletons
  115074. */
  115075. loadedSkeletons: Array<Skeleton>;
  115076. /**
  115077. * Gets the list of loaded animation groups
  115078. */
  115079. loadedAnimationGroups: Array<AnimationGroup>;
  115080. /**
  115081. * Callback called when the task is successful
  115082. */
  115083. onSuccess: (task: MeshAssetTask) => void;
  115084. /**
  115085. * Callback called when the task is successful
  115086. */
  115087. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  115088. /**
  115089. * Creates a new MeshAssetTask
  115090. * @param name defines the name of the task
  115091. * @param meshesNames defines the list of mesh's names you want to load
  115092. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  115093. * @param sceneFilename defines the filename of the scene to load from
  115094. */
  115095. constructor(
  115096. /**
  115097. * Defines the name of the task
  115098. */
  115099. name: string,
  115100. /**
  115101. * Defines the list of mesh's names you want to load
  115102. */
  115103. meshesNames: any,
  115104. /**
  115105. * Defines the root url to use as a base to load your meshes and associated resources
  115106. */
  115107. rootUrl: string,
  115108. /**
  115109. * Defines the filename of the scene to load from
  115110. */
  115111. sceneFilename: string);
  115112. /**
  115113. * Execute the current task
  115114. * @param scene defines the scene where you want your assets to be loaded
  115115. * @param onSuccess is a callback called when the task is successfully executed
  115116. * @param onError is a callback called if an error occurs
  115117. */
  115118. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115119. }
  115120. /**
  115121. * Define a task used by AssetsManager to load text content
  115122. */
  115123. export class TextFileAssetTask extends AbstractAssetTask {
  115124. /**
  115125. * Defines the name of the task
  115126. */
  115127. name: string;
  115128. /**
  115129. * Defines the location of the file to load
  115130. */
  115131. url: string;
  115132. /**
  115133. * Gets the loaded text string
  115134. */
  115135. text: string;
  115136. /**
  115137. * Callback called when the task is successful
  115138. */
  115139. onSuccess: (task: TextFileAssetTask) => void;
  115140. /**
  115141. * Callback called when the task is successful
  115142. */
  115143. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  115144. /**
  115145. * Creates a new TextFileAssetTask object
  115146. * @param name defines the name of the task
  115147. * @param url defines the location of the file to load
  115148. */
  115149. constructor(
  115150. /**
  115151. * Defines the name of the task
  115152. */
  115153. name: string,
  115154. /**
  115155. * Defines the location of the file to load
  115156. */
  115157. url: string);
  115158. /**
  115159. * Execute the current task
  115160. * @param scene defines the scene where you want your assets to be loaded
  115161. * @param onSuccess is a callback called when the task is successfully executed
  115162. * @param onError is a callback called if an error occurs
  115163. */
  115164. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115165. }
  115166. /**
  115167. * Define a task used by AssetsManager to load binary data
  115168. */
  115169. export class BinaryFileAssetTask extends AbstractAssetTask {
  115170. /**
  115171. * Defines the name of the task
  115172. */
  115173. name: string;
  115174. /**
  115175. * Defines the location of the file to load
  115176. */
  115177. url: string;
  115178. /**
  115179. * Gets the lodaded data (as an array buffer)
  115180. */
  115181. data: ArrayBuffer;
  115182. /**
  115183. * Callback called when the task is successful
  115184. */
  115185. onSuccess: (task: BinaryFileAssetTask) => void;
  115186. /**
  115187. * Callback called when the task is successful
  115188. */
  115189. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  115190. /**
  115191. * Creates a new BinaryFileAssetTask object
  115192. * @param name defines the name of the new task
  115193. * @param url defines the location of the file to load
  115194. */
  115195. constructor(
  115196. /**
  115197. * Defines the name of the task
  115198. */
  115199. name: string,
  115200. /**
  115201. * Defines the location of the file to load
  115202. */
  115203. url: string);
  115204. /**
  115205. * Execute the current task
  115206. * @param scene defines the scene where you want your assets to be loaded
  115207. * @param onSuccess is a callback called when the task is successfully executed
  115208. * @param onError is a callback called if an error occurs
  115209. */
  115210. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115211. }
  115212. /**
  115213. * Define a task used by AssetsManager to load images
  115214. */
  115215. export class ImageAssetTask extends AbstractAssetTask {
  115216. /**
  115217. * Defines the name of the task
  115218. */
  115219. name: string;
  115220. /**
  115221. * Defines the location of the image to load
  115222. */
  115223. url: string;
  115224. /**
  115225. * Gets the loaded images
  115226. */
  115227. image: HTMLImageElement;
  115228. /**
  115229. * Callback called when the task is successful
  115230. */
  115231. onSuccess: (task: ImageAssetTask) => void;
  115232. /**
  115233. * Callback called when the task is successful
  115234. */
  115235. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  115236. /**
  115237. * Creates a new ImageAssetTask
  115238. * @param name defines the name of the task
  115239. * @param url defines the location of the image to load
  115240. */
  115241. constructor(
  115242. /**
  115243. * Defines the name of the task
  115244. */
  115245. name: string,
  115246. /**
  115247. * Defines the location of the image to load
  115248. */
  115249. url: string);
  115250. /**
  115251. * Execute the current task
  115252. * @param scene defines the scene where you want your assets to be loaded
  115253. * @param onSuccess is a callback called when the task is successfully executed
  115254. * @param onError is a callback called if an error occurs
  115255. */
  115256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115257. }
  115258. /**
  115259. * Defines the interface used by texture loading tasks
  115260. */
  115261. export interface ITextureAssetTask<TEX extends BaseTexture> {
  115262. /**
  115263. * Gets the loaded texture
  115264. */
  115265. texture: TEX;
  115266. }
  115267. /**
  115268. * Define a task used by AssetsManager to load 2D textures
  115269. */
  115270. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  115271. /**
  115272. * Defines the name of the task
  115273. */
  115274. name: string;
  115275. /**
  115276. * Defines the location of the file to load
  115277. */
  115278. url: string;
  115279. /**
  115280. * Defines if mipmap should not be generated (default is false)
  115281. */
  115282. noMipmap?: boolean | undefined;
  115283. /**
  115284. * Defines if texture must be inverted on Y axis (default is false)
  115285. */
  115286. invertY?: boolean | undefined;
  115287. /**
  115288. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115289. */
  115290. samplingMode: number;
  115291. /**
  115292. * Gets the loaded texture
  115293. */
  115294. texture: Texture;
  115295. /**
  115296. * Callback called when the task is successful
  115297. */
  115298. onSuccess: (task: TextureAssetTask) => void;
  115299. /**
  115300. * Callback called when the task is successful
  115301. */
  115302. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  115303. /**
  115304. * Creates a new TextureAssetTask object
  115305. * @param name defines the name of the task
  115306. * @param url defines the location of the file to load
  115307. * @param noMipmap defines if mipmap should not be generated (default is false)
  115308. * @param invertY defines if texture must be inverted on Y axis (default is false)
  115309. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115310. */
  115311. constructor(
  115312. /**
  115313. * Defines the name of the task
  115314. */
  115315. name: string,
  115316. /**
  115317. * Defines the location of the file to load
  115318. */
  115319. url: string,
  115320. /**
  115321. * Defines if mipmap should not be generated (default is false)
  115322. */
  115323. noMipmap?: boolean | undefined,
  115324. /**
  115325. * Defines if texture must be inverted on Y axis (default is false)
  115326. */
  115327. invertY?: boolean | undefined,
  115328. /**
  115329. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115330. */
  115331. samplingMode?: number);
  115332. /**
  115333. * Execute the current task
  115334. * @param scene defines the scene where you want your assets to be loaded
  115335. * @param onSuccess is a callback called when the task is successfully executed
  115336. * @param onError is a callback called if an error occurs
  115337. */
  115338. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115339. }
  115340. /**
  115341. * Define a task used by AssetsManager to load cube textures
  115342. */
  115343. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  115344. /**
  115345. * Defines the name of the task
  115346. */
  115347. name: string;
  115348. /**
  115349. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115350. */
  115351. url: string;
  115352. /**
  115353. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115354. */
  115355. extensions?: string[] | undefined;
  115356. /**
  115357. * Defines if mipmaps should not be generated (default is false)
  115358. */
  115359. noMipmap?: boolean | undefined;
  115360. /**
  115361. * Defines the explicit list of files (undefined by default)
  115362. */
  115363. files?: string[] | undefined;
  115364. /**
  115365. * Gets the loaded texture
  115366. */
  115367. texture: CubeTexture;
  115368. /**
  115369. * Callback called when the task is successful
  115370. */
  115371. onSuccess: (task: CubeTextureAssetTask) => void;
  115372. /**
  115373. * Callback called when the task is successful
  115374. */
  115375. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  115376. /**
  115377. * Creates a new CubeTextureAssetTask
  115378. * @param name defines the name of the task
  115379. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115380. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115381. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115382. * @param files defines the explicit list of files (undefined by default)
  115383. */
  115384. constructor(
  115385. /**
  115386. * Defines the name of the task
  115387. */
  115388. name: string,
  115389. /**
  115390. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115391. */
  115392. url: string,
  115393. /**
  115394. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115395. */
  115396. extensions?: string[] | undefined,
  115397. /**
  115398. * Defines if mipmaps should not be generated (default is false)
  115399. */
  115400. noMipmap?: boolean | undefined,
  115401. /**
  115402. * Defines the explicit list of files (undefined by default)
  115403. */
  115404. files?: string[] | undefined);
  115405. /**
  115406. * Execute the current task
  115407. * @param scene defines the scene where you want your assets to be loaded
  115408. * @param onSuccess is a callback called when the task is successfully executed
  115409. * @param onError is a callback called if an error occurs
  115410. */
  115411. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115412. }
  115413. /**
  115414. * Define a task used by AssetsManager to load HDR cube textures
  115415. */
  115416. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  115417. /**
  115418. * Defines the name of the task
  115419. */
  115420. name: string;
  115421. /**
  115422. * Defines the location of the file to load
  115423. */
  115424. url: string;
  115425. /**
  115426. * Defines the desired size (the more it increases the longer the generation will be)
  115427. */
  115428. size: number;
  115429. /**
  115430. * Defines if mipmaps should not be generated (default is false)
  115431. */
  115432. noMipmap: boolean;
  115433. /**
  115434. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115435. */
  115436. generateHarmonics: boolean;
  115437. /**
  115438. * 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)
  115439. */
  115440. gammaSpace: boolean;
  115441. /**
  115442. * Internal Use Only
  115443. */
  115444. reserved: boolean;
  115445. /**
  115446. * Gets the loaded texture
  115447. */
  115448. texture: HDRCubeTexture;
  115449. /**
  115450. * Callback called when the task is successful
  115451. */
  115452. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  115453. /**
  115454. * Callback called when the task is successful
  115455. */
  115456. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  115457. /**
  115458. * Creates a new HDRCubeTextureAssetTask object
  115459. * @param name defines the name of the task
  115460. * @param url defines the location of the file to load
  115461. * @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.
  115462. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115463. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115464. * @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)
  115465. * @param reserved Internal use only
  115466. */
  115467. constructor(
  115468. /**
  115469. * Defines the name of the task
  115470. */
  115471. name: string,
  115472. /**
  115473. * Defines the location of the file to load
  115474. */
  115475. url: string,
  115476. /**
  115477. * Defines the desired size (the more it increases the longer the generation will be)
  115478. */
  115479. size: number,
  115480. /**
  115481. * Defines if mipmaps should not be generated (default is false)
  115482. */
  115483. noMipmap?: boolean,
  115484. /**
  115485. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115486. */
  115487. generateHarmonics?: boolean,
  115488. /**
  115489. * 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)
  115490. */
  115491. gammaSpace?: boolean,
  115492. /**
  115493. * Internal Use Only
  115494. */
  115495. reserved?: boolean);
  115496. /**
  115497. * Execute the current task
  115498. * @param scene defines the scene where you want your assets to be loaded
  115499. * @param onSuccess is a callback called when the task is successfully executed
  115500. * @param onError is a callback called if an error occurs
  115501. */
  115502. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115503. }
  115504. /**
  115505. * Define a task used by AssetsManager to load Equirectangular cube textures
  115506. */
  115507. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  115508. /**
  115509. * Defines the name of the task
  115510. */
  115511. name: string;
  115512. /**
  115513. * Defines the location of the file to load
  115514. */
  115515. url: string;
  115516. /**
  115517. * Defines the desired size (the more it increases the longer the generation will be)
  115518. */
  115519. size: number;
  115520. /**
  115521. * Defines if mipmaps should not be generated (default is false)
  115522. */
  115523. noMipmap: boolean;
  115524. /**
  115525. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115526. * but the standard material would require them in Gamma space) (default is true)
  115527. */
  115528. gammaSpace: boolean;
  115529. /**
  115530. * Gets the loaded texture
  115531. */
  115532. texture: EquiRectangularCubeTexture;
  115533. /**
  115534. * Callback called when the task is successful
  115535. */
  115536. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  115537. /**
  115538. * Callback called when the task is successful
  115539. */
  115540. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  115541. /**
  115542. * Creates a new EquiRectangularCubeTextureAssetTask object
  115543. * @param name defines the name of the task
  115544. * @param url defines the location of the file to load
  115545. * @param size defines the desired size (the more it increases the longer the generation will be)
  115546. * If the size is omitted this implies you are using a preprocessed cubemap.
  115547. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115548. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  115549. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  115550. * (default is true)
  115551. */
  115552. constructor(
  115553. /**
  115554. * Defines the name of the task
  115555. */
  115556. name: string,
  115557. /**
  115558. * Defines the location of the file to load
  115559. */
  115560. url: string,
  115561. /**
  115562. * Defines the desired size (the more it increases the longer the generation will be)
  115563. */
  115564. size: number,
  115565. /**
  115566. * Defines if mipmaps should not be generated (default is false)
  115567. */
  115568. noMipmap?: boolean,
  115569. /**
  115570. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115571. * but the standard material would require them in Gamma space) (default is true)
  115572. */
  115573. gammaSpace?: boolean);
  115574. /**
  115575. * Execute the current task
  115576. * @param scene defines the scene where you want your assets to be loaded
  115577. * @param onSuccess is a callback called when the task is successfully executed
  115578. * @param onError is a callback called if an error occurs
  115579. */
  115580. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115581. }
  115582. /**
  115583. * This class can be used to easily import assets into a scene
  115584. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  115585. */
  115586. export class AssetsManager {
  115587. private _scene;
  115588. private _isLoading;
  115589. protected _tasks: AbstractAssetTask[];
  115590. protected _waitingTasksCount: number;
  115591. protected _totalTasksCount: number;
  115592. /**
  115593. * Callback called when all tasks are processed
  115594. */
  115595. onFinish: (tasks: AbstractAssetTask[]) => void;
  115596. /**
  115597. * Callback called when a task is successful
  115598. */
  115599. onTaskSuccess: (task: AbstractAssetTask) => void;
  115600. /**
  115601. * Callback called when a task had an error
  115602. */
  115603. onTaskError: (task: AbstractAssetTask) => void;
  115604. /**
  115605. * Callback called when a task is done (whatever the result is)
  115606. */
  115607. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  115608. /**
  115609. * Observable called when all tasks are processed
  115610. */
  115611. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  115612. /**
  115613. * Observable called when a task had an error
  115614. */
  115615. onTaskErrorObservable: Observable<AbstractAssetTask>;
  115616. /**
  115617. * Observable called when all tasks were executed
  115618. */
  115619. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  115620. /**
  115621. * Observable called when a task is done (whatever the result is)
  115622. */
  115623. onProgressObservable: Observable<IAssetsProgressEvent>;
  115624. /**
  115625. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  115626. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115627. */
  115628. useDefaultLoadingScreen: boolean;
  115629. /**
  115630. * Creates a new AssetsManager
  115631. * @param scene defines the scene to work on
  115632. */
  115633. constructor(scene: Scene);
  115634. /**
  115635. * Add a MeshAssetTask to the list of active tasks
  115636. * @param taskName defines the name of the new task
  115637. * @param meshesNames defines the name of meshes to load
  115638. * @param rootUrl defines the root url to use to locate files
  115639. * @param sceneFilename defines the filename of the scene file
  115640. * @returns a new MeshAssetTask object
  115641. */
  115642. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  115643. /**
  115644. * Add a TextFileAssetTask to the list of active tasks
  115645. * @param taskName defines the name of the new task
  115646. * @param url defines the url of the file to load
  115647. * @returns a new TextFileAssetTask object
  115648. */
  115649. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  115650. /**
  115651. * Add a BinaryFileAssetTask to the list of active tasks
  115652. * @param taskName defines the name of the new task
  115653. * @param url defines the url of the file to load
  115654. * @returns a new BinaryFileAssetTask object
  115655. */
  115656. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  115657. /**
  115658. * Add a ImageAssetTask to the list of active tasks
  115659. * @param taskName defines the name of the new task
  115660. * @param url defines the url of the file to load
  115661. * @returns a new ImageAssetTask object
  115662. */
  115663. addImageTask(taskName: string, url: string): ImageAssetTask;
  115664. /**
  115665. * Add a TextureAssetTask to the list of active tasks
  115666. * @param taskName defines the name of the new task
  115667. * @param url defines the url of the file to load
  115668. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115669. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  115670. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115671. * @returns a new TextureAssetTask object
  115672. */
  115673. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  115674. /**
  115675. * Add a CubeTextureAssetTask to the list of active tasks
  115676. * @param taskName defines the name of the new task
  115677. * @param url defines the url of the file to load
  115678. * @param extensions defines the extension to use to load the cube map (can be null)
  115679. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115680. * @param files defines the list of files to load (can be null)
  115681. * @returns a new CubeTextureAssetTask object
  115682. */
  115683. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  115684. /**
  115685. *
  115686. * Add a HDRCubeTextureAssetTask to the list of active tasks
  115687. * @param taskName defines the name of the new task
  115688. * @param url defines the url of the file to load
  115689. * @param size defines the size you want for the cubemap (can be null)
  115690. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115691. * @param generateHarmonics defines if you want to automatically generate (true by default)
  115692. * @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)
  115693. * @param reserved Internal use only
  115694. * @returns a new HDRCubeTextureAssetTask object
  115695. */
  115696. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  115697. /**
  115698. *
  115699. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  115700. * @param taskName defines the name of the new task
  115701. * @param url defines the url of the file to load
  115702. * @param size defines the size you want for the cubemap (can be null)
  115703. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115704. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115705. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115706. * @returns a new EquiRectangularCubeTextureAssetTask object
  115707. */
  115708. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  115709. /**
  115710. * Remove a task from the assets manager.
  115711. * @param task the task to remove
  115712. */
  115713. removeTask(task: AbstractAssetTask): void;
  115714. private _decreaseWaitingTasksCount;
  115715. private _runTask;
  115716. /**
  115717. * Reset the AssetsManager and remove all tasks
  115718. * @return the current instance of the AssetsManager
  115719. */
  115720. reset(): AssetsManager;
  115721. /**
  115722. * Start the loading process
  115723. * @return the current instance of the AssetsManager
  115724. */
  115725. load(): AssetsManager;
  115726. /**
  115727. * Start the loading process as an async operation
  115728. * @return a promise returning the list of failed tasks
  115729. */
  115730. loadAsync(): Promise<void>;
  115731. }
  115732. }
  115733. declare module BABYLON {
  115734. /**
  115735. * Wrapper class for promise with external resolve and reject.
  115736. */
  115737. export class Deferred<T> {
  115738. /**
  115739. * The promise associated with this deferred object.
  115740. */
  115741. readonly promise: Promise<T>;
  115742. private _resolve;
  115743. private _reject;
  115744. /**
  115745. * The resolve method of the promise associated with this deferred object.
  115746. */
  115747. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  115748. /**
  115749. * The reject method of the promise associated with this deferred object.
  115750. */
  115751. readonly reject: (reason?: any) => void;
  115752. /**
  115753. * Constructor for this deferred object.
  115754. */
  115755. constructor();
  115756. }
  115757. }
  115758. declare module BABYLON {
  115759. /**
  115760. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  115761. */
  115762. export class MeshExploder {
  115763. private _centerMesh;
  115764. private _meshes;
  115765. private _meshesOrigins;
  115766. private _toCenterVectors;
  115767. private _scaledDirection;
  115768. private _newPosition;
  115769. private _centerPosition;
  115770. /**
  115771. * Explodes meshes from a center mesh.
  115772. * @param meshes The meshes to explode.
  115773. * @param centerMesh The mesh to be center of explosion.
  115774. */
  115775. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  115776. private _setCenterMesh;
  115777. /**
  115778. * Get class name
  115779. * @returns "MeshExploder"
  115780. */
  115781. getClassName(): string;
  115782. /**
  115783. * "Exploded meshes"
  115784. * @returns Array of meshes with the centerMesh at index 0.
  115785. */
  115786. getMeshes(): Array<Mesh>;
  115787. /**
  115788. * Explodes meshes giving a specific direction
  115789. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  115790. */
  115791. explode(direction?: number): void;
  115792. }
  115793. }
  115794. declare module BABYLON {
  115795. /**
  115796. * Class used to help managing file picking and drag'n'drop
  115797. */
  115798. export class FilesInput {
  115799. /**
  115800. * List of files ready to be loaded
  115801. */
  115802. static readonly FilesToLoad: {
  115803. [key: string]: File;
  115804. };
  115805. /**
  115806. * Callback called when a file is processed
  115807. */
  115808. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  115809. private _engine;
  115810. private _currentScene;
  115811. private _sceneLoadedCallback;
  115812. private _progressCallback;
  115813. private _additionalRenderLoopLogicCallback;
  115814. private _textureLoadingCallback;
  115815. private _startingProcessingFilesCallback;
  115816. private _onReloadCallback;
  115817. private _errorCallback;
  115818. private _elementToMonitor;
  115819. private _sceneFileToLoad;
  115820. private _filesToLoad;
  115821. /**
  115822. * Creates a new FilesInput
  115823. * @param engine defines the rendering engine
  115824. * @param scene defines the hosting scene
  115825. * @param sceneLoadedCallback callback called when scene is loaded
  115826. * @param progressCallback callback called to track progress
  115827. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  115828. * @param textureLoadingCallback callback called when a texture is loading
  115829. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  115830. * @param onReloadCallback callback called when a reload is requested
  115831. * @param errorCallback callback call if an error occurs
  115832. */
  115833. 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);
  115834. private _dragEnterHandler;
  115835. private _dragOverHandler;
  115836. private _dropHandler;
  115837. /**
  115838. * Calls this function to listen to drag'n'drop events on a specific DOM element
  115839. * @param elementToMonitor defines the DOM element to track
  115840. */
  115841. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  115842. /**
  115843. * Release all associated resources
  115844. */
  115845. dispose(): void;
  115846. private renderFunction;
  115847. private drag;
  115848. private drop;
  115849. private _traverseFolder;
  115850. private _processFiles;
  115851. /**
  115852. * Load files from a drop event
  115853. * @param event defines the drop event to use as source
  115854. */
  115855. loadFiles(event: any): void;
  115856. private _processReload;
  115857. /**
  115858. * Reload the current scene from the loaded files
  115859. */
  115860. reload(): void;
  115861. }
  115862. }
  115863. declare module BABYLON {
  115864. /**
  115865. * Defines the root class used to create scene optimization to use with SceneOptimizer
  115866. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115867. */
  115868. export class SceneOptimization {
  115869. /**
  115870. * Defines the priority of this optimization (0 by default which means first in the list)
  115871. */
  115872. priority: number;
  115873. /**
  115874. * Gets a string describing the action executed by the current optimization
  115875. * @returns description string
  115876. */
  115877. getDescription(): string;
  115878. /**
  115879. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115880. * @param scene defines the current scene where to apply this optimization
  115881. * @param optimizer defines the current optimizer
  115882. * @returns true if everything that can be done was applied
  115883. */
  115884. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115885. /**
  115886. * Creates the SceneOptimization object
  115887. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115888. * @param desc defines the description associated with the optimization
  115889. */
  115890. constructor(
  115891. /**
  115892. * Defines the priority of this optimization (0 by default which means first in the list)
  115893. */
  115894. priority?: number);
  115895. }
  115896. /**
  115897. * Defines an optimization used to reduce the size of render target textures
  115898. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115899. */
  115900. export class TextureOptimization extends SceneOptimization {
  115901. /**
  115902. * Defines the priority of this optimization (0 by default which means first in the list)
  115903. */
  115904. priority: number;
  115905. /**
  115906. * 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
  115907. */
  115908. maximumSize: number;
  115909. /**
  115910. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115911. */
  115912. step: number;
  115913. /**
  115914. * Gets a string describing the action executed by the current optimization
  115915. * @returns description string
  115916. */
  115917. getDescription(): string;
  115918. /**
  115919. * Creates the TextureOptimization object
  115920. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115921. * @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
  115922. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115923. */
  115924. constructor(
  115925. /**
  115926. * Defines the priority of this optimization (0 by default which means first in the list)
  115927. */
  115928. priority?: number,
  115929. /**
  115930. * 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
  115931. */
  115932. maximumSize?: number,
  115933. /**
  115934. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115935. */
  115936. step?: number);
  115937. /**
  115938. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115939. * @param scene defines the current scene where to apply this optimization
  115940. * @param optimizer defines the current optimizer
  115941. * @returns true if everything that can be done was applied
  115942. */
  115943. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115944. }
  115945. /**
  115946. * Defines an optimization used to increase or decrease the rendering resolution
  115947. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115948. */
  115949. export class HardwareScalingOptimization extends SceneOptimization {
  115950. /**
  115951. * Defines the priority of this optimization (0 by default which means first in the list)
  115952. */
  115953. priority: number;
  115954. /**
  115955. * Defines the maximum scale to use (2 by default)
  115956. */
  115957. maximumScale: number;
  115958. /**
  115959. * Defines the step to use between two passes (0.5 by default)
  115960. */
  115961. step: number;
  115962. private _currentScale;
  115963. private _directionOffset;
  115964. /**
  115965. * Gets a string describing the action executed by the current optimization
  115966. * @return description string
  115967. */
  115968. getDescription(): string;
  115969. /**
  115970. * Creates the HardwareScalingOptimization object
  115971. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115972. * @param maximumScale defines the maximum scale to use (2 by default)
  115973. * @param step defines the step to use between two passes (0.5 by default)
  115974. */
  115975. constructor(
  115976. /**
  115977. * Defines the priority of this optimization (0 by default which means first in the list)
  115978. */
  115979. priority?: number,
  115980. /**
  115981. * Defines the maximum scale to use (2 by default)
  115982. */
  115983. maximumScale?: number,
  115984. /**
  115985. * Defines the step to use between two passes (0.5 by default)
  115986. */
  115987. step?: number);
  115988. /**
  115989. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115990. * @param scene defines the current scene where to apply this optimization
  115991. * @param optimizer defines the current optimizer
  115992. * @returns true if everything that can be done was applied
  115993. */
  115994. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115995. }
  115996. /**
  115997. * Defines an optimization used to remove shadows
  115998. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115999. */
  116000. export class ShadowsOptimization extends SceneOptimization {
  116001. /**
  116002. * Gets a string describing the action executed by the current optimization
  116003. * @return description string
  116004. */
  116005. getDescription(): string;
  116006. /**
  116007. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116008. * @param scene defines the current scene where to apply this optimization
  116009. * @param optimizer defines the current optimizer
  116010. * @returns true if everything that can be done was applied
  116011. */
  116012. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116013. }
  116014. /**
  116015. * Defines an optimization used to turn post-processes off
  116016. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116017. */
  116018. export class PostProcessesOptimization extends SceneOptimization {
  116019. /**
  116020. * Gets a string describing the action executed by the current optimization
  116021. * @return description string
  116022. */
  116023. getDescription(): string;
  116024. /**
  116025. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116026. * @param scene defines the current scene where to apply this optimization
  116027. * @param optimizer defines the current optimizer
  116028. * @returns true if everything that can be done was applied
  116029. */
  116030. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116031. }
  116032. /**
  116033. * Defines an optimization used to turn lens flares off
  116034. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116035. */
  116036. export class LensFlaresOptimization extends SceneOptimization {
  116037. /**
  116038. * Gets a string describing the action executed by the current optimization
  116039. * @return description string
  116040. */
  116041. getDescription(): string;
  116042. /**
  116043. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116044. * @param scene defines the current scene where to apply this optimization
  116045. * @param optimizer defines the current optimizer
  116046. * @returns true if everything that can be done was applied
  116047. */
  116048. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116049. }
  116050. /**
  116051. * Defines an optimization based on user defined callback.
  116052. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116053. */
  116054. export class CustomOptimization extends SceneOptimization {
  116055. /**
  116056. * Callback called to apply the custom optimization.
  116057. */
  116058. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  116059. /**
  116060. * Callback called to get custom description
  116061. */
  116062. onGetDescription: () => string;
  116063. /**
  116064. * Gets a string describing the action executed by the current optimization
  116065. * @returns description string
  116066. */
  116067. getDescription(): string;
  116068. /**
  116069. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116070. * @param scene defines the current scene where to apply this optimization
  116071. * @param optimizer defines the current optimizer
  116072. * @returns true if everything that can be done was applied
  116073. */
  116074. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116075. }
  116076. /**
  116077. * Defines an optimization used to turn particles off
  116078. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116079. */
  116080. export class ParticlesOptimization extends SceneOptimization {
  116081. /**
  116082. * Gets a string describing the action executed by the current optimization
  116083. * @return description string
  116084. */
  116085. getDescription(): string;
  116086. /**
  116087. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116088. * @param scene defines the current scene where to apply this optimization
  116089. * @param optimizer defines the current optimizer
  116090. * @returns true if everything that can be done was applied
  116091. */
  116092. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116093. }
  116094. /**
  116095. * Defines an optimization used to turn render targets off
  116096. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116097. */
  116098. export class RenderTargetsOptimization extends SceneOptimization {
  116099. /**
  116100. * Gets a string describing the action executed by the current optimization
  116101. * @return description string
  116102. */
  116103. getDescription(): string;
  116104. /**
  116105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116106. * @param scene defines the current scene where to apply this optimization
  116107. * @param optimizer defines the current optimizer
  116108. * @returns true if everything that can be done was applied
  116109. */
  116110. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116111. }
  116112. /**
  116113. * Defines an optimization used to merge meshes with compatible materials
  116114. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116115. */
  116116. export class MergeMeshesOptimization extends SceneOptimization {
  116117. private static _UpdateSelectionTree;
  116118. /**
  116119. * Gets or sets a boolean which defines if optimization octree has to be updated
  116120. */
  116121. /**
  116122. * Gets or sets a boolean which defines if optimization octree has to be updated
  116123. */
  116124. static UpdateSelectionTree: boolean;
  116125. /**
  116126. * Gets a string describing the action executed by the current optimization
  116127. * @return description string
  116128. */
  116129. getDescription(): string;
  116130. private _canBeMerged;
  116131. /**
  116132. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116133. * @param scene defines the current scene where to apply this optimization
  116134. * @param optimizer defines the current optimizer
  116135. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  116136. * @returns true if everything that can be done was applied
  116137. */
  116138. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  116139. }
  116140. /**
  116141. * Defines a list of options used by SceneOptimizer
  116142. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116143. */
  116144. export class SceneOptimizerOptions {
  116145. /**
  116146. * Defines the target frame rate to reach (60 by default)
  116147. */
  116148. targetFrameRate: number;
  116149. /**
  116150. * Defines the interval between two checkes (2000ms by default)
  116151. */
  116152. trackerDuration: number;
  116153. /**
  116154. * Gets the list of optimizations to apply
  116155. */
  116156. optimizations: SceneOptimization[];
  116157. /**
  116158. * Creates a new list of options used by SceneOptimizer
  116159. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  116160. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  116161. */
  116162. constructor(
  116163. /**
  116164. * Defines the target frame rate to reach (60 by default)
  116165. */
  116166. targetFrameRate?: number,
  116167. /**
  116168. * Defines the interval between two checkes (2000ms by default)
  116169. */
  116170. trackerDuration?: number);
  116171. /**
  116172. * Add a new optimization
  116173. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  116174. * @returns the current SceneOptimizerOptions
  116175. */
  116176. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  116177. /**
  116178. * Add a new custom optimization
  116179. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  116180. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  116181. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116182. * @returns the current SceneOptimizerOptions
  116183. */
  116184. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  116185. /**
  116186. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  116187. * @param targetFrameRate defines the target frame rate (60 by default)
  116188. * @returns a SceneOptimizerOptions object
  116189. */
  116190. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116191. /**
  116192. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  116193. * @param targetFrameRate defines the target frame rate (60 by default)
  116194. * @returns a SceneOptimizerOptions object
  116195. */
  116196. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116197. /**
  116198. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  116199. * @param targetFrameRate defines the target frame rate (60 by default)
  116200. * @returns a SceneOptimizerOptions object
  116201. */
  116202. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116203. }
  116204. /**
  116205. * Class used to run optimizations in order to reach a target frame rate
  116206. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116207. */
  116208. export class SceneOptimizer implements IDisposable {
  116209. private _isRunning;
  116210. private _options;
  116211. private _scene;
  116212. private _currentPriorityLevel;
  116213. private _targetFrameRate;
  116214. private _trackerDuration;
  116215. private _currentFrameRate;
  116216. private _sceneDisposeObserver;
  116217. private _improvementMode;
  116218. /**
  116219. * Defines an observable called when the optimizer reaches the target frame rate
  116220. */
  116221. onSuccessObservable: Observable<SceneOptimizer>;
  116222. /**
  116223. * Defines an observable called when the optimizer enables an optimization
  116224. */
  116225. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  116226. /**
  116227. * Defines an observable called when the optimizer is not able to reach the target frame rate
  116228. */
  116229. onFailureObservable: Observable<SceneOptimizer>;
  116230. /**
  116231. * Gets a boolean indicating if the optimizer is in improvement mode
  116232. */
  116233. readonly isInImprovementMode: boolean;
  116234. /**
  116235. * Gets the current priority level (0 at start)
  116236. */
  116237. readonly currentPriorityLevel: number;
  116238. /**
  116239. * Gets the current frame rate checked by the SceneOptimizer
  116240. */
  116241. readonly currentFrameRate: number;
  116242. /**
  116243. * Gets or sets the current target frame rate (60 by default)
  116244. */
  116245. /**
  116246. * Gets or sets the current target frame rate (60 by default)
  116247. */
  116248. targetFrameRate: number;
  116249. /**
  116250. * Gets or sets the current interval between two checks (every 2000ms by default)
  116251. */
  116252. /**
  116253. * Gets or sets the current interval between two checks (every 2000ms by default)
  116254. */
  116255. trackerDuration: number;
  116256. /**
  116257. * Gets the list of active optimizations
  116258. */
  116259. readonly optimizations: SceneOptimization[];
  116260. /**
  116261. * Creates a new SceneOptimizer
  116262. * @param scene defines the scene to work on
  116263. * @param options defines the options to use with the SceneOptimizer
  116264. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  116265. * @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)
  116266. */
  116267. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  116268. /**
  116269. * Stops the current optimizer
  116270. */
  116271. stop(): void;
  116272. /**
  116273. * Reset the optimizer to initial step (current priority level = 0)
  116274. */
  116275. reset(): void;
  116276. /**
  116277. * Start the optimizer. By default it will try to reach a specific framerate
  116278. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  116279. */
  116280. start(): void;
  116281. private _checkCurrentState;
  116282. /**
  116283. * Release all resources
  116284. */
  116285. dispose(): void;
  116286. /**
  116287. * Helper function to create a SceneOptimizer with one single line of code
  116288. * @param scene defines the scene to work on
  116289. * @param options defines the options to use with the SceneOptimizer
  116290. * @param onSuccess defines a callback to call on success
  116291. * @param onFailure defines a callback to call on failure
  116292. * @returns the new SceneOptimizer object
  116293. */
  116294. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  116295. }
  116296. }
  116297. declare module BABYLON {
  116298. /**
  116299. * Class used to serialize a scene into a string
  116300. */
  116301. export class SceneSerializer {
  116302. /**
  116303. * Clear cache used by a previous serialization
  116304. */
  116305. static ClearCache(): void;
  116306. /**
  116307. * Serialize a scene into a JSON compatible object
  116308. * @param scene defines the scene to serialize
  116309. * @returns a JSON compatible object
  116310. */
  116311. static Serialize(scene: Scene): any;
  116312. /**
  116313. * Serialize a mesh into a JSON compatible object
  116314. * @param toSerialize defines the mesh to serialize
  116315. * @param withParents defines if parents must be serialized as well
  116316. * @param withChildren defines if children must be serialized as well
  116317. * @returns a JSON compatible object
  116318. */
  116319. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  116320. }
  116321. }
  116322. declare module BABYLON {
  116323. /**
  116324. * Class used to host texture specific utilities
  116325. */
  116326. export class TextureTools {
  116327. /**
  116328. * Uses the GPU to create a copy texture rescaled at a given size
  116329. * @param texture Texture to copy from
  116330. * @param width defines the desired width
  116331. * @param height defines the desired height
  116332. * @param useBilinearMode defines if bilinear mode has to be used
  116333. * @return the generated texture
  116334. */
  116335. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  116336. }
  116337. }
  116338. declare module BABYLON {
  116339. /**
  116340. * This represents the different options avilable for the video capture.
  116341. */
  116342. export interface VideoRecorderOptions {
  116343. /** Defines the mime type of the video */
  116344. mimeType: string;
  116345. /** Defines the video the video should be recorded at */
  116346. fps: number;
  116347. /** Defines the chunk size for the recording data */
  116348. recordChunckSize: number;
  116349. /** The audio tracks to attach to the record */
  116350. audioTracks?: MediaStreamTrack[];
  116351. }
  116352. /**
  116353. * This can helps recording videos from BabylonJS.
  116354. * This is based on the available WebRTC functionalities of the browser.
  116355. *
  116356. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  116357. */
  116358. export class VideoRecorder {
  116359. private static readonly _defaultOptions;
  116360. /**
  116361. * Returns wehther or not the VideoRecorder is available in your browser.
  116362. * @param engine Defines the Babylon Engine to check the support for
  116363. * @returns true if supported otherwise false
  116364. */
  116365. static IsSupported(engine: Engine): boolean;
  116366. private readonly _options;
  116367. private _canvas;
  116368. private _mediaRecorder;
  116369. private _recordedChunks;
  116370. private _fileName;
  116371. private _resolve;
  116372. private _reject;
  116373. /**
  116374. * True wether a recording is already in progress.
  116375. */
  116376. readonly isRecording: boolean;
  116377. /**
  116378. * Create a new VideoCapture object which can help converting what you see in Babylon to
  116379. * a video file.
  116380. * @param engine Defines the BabylonJS Engine you wish to record
  116381. * @param options Defines options that can be used to customized the capture
  116382. */
  116383. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  116384. /**
  116385. * Stops the current recording before the default capture timeout passed in the startRecording
  116386. * functions.
  116387. */
  116388. stopRecording(): void;
  116389. /**
  116390. * Starts recording the canvas for a max duration specified in parameters.
  116391. * @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.
  116392. * @param maxDuration Defines the maximum recording time in seconds.
  116393. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  116394. * @return a promise callback at the end of the recording with the video data in Blob.
  116395. */
  116396. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  116397. /**
  116398. * Releases internal resources used during the recording.
  116399. */
  116400. dispose(): void;
  116401. private _handleDataAvailable;
  116402. private _handleError;
  116403. private _handleStop;
  116404. }
  116405. }
  116406. declare module BABYLON {
  116407. /**
  116408. * Class containing a set of static utilities functions for screenshots
  116409. */
  116410. export class ScreenshotTools {
  116411. /**
  116412. * Captures a screenshot of the current rendering
  116413. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116414. * @param engine defines the rendering engine
  116415. * @param camera defines the source camera
  116416. * @param size This parameter can be set to a single number or to an object with the
  116417. * following (optional) properties: precision, width, height. If a single number is passed,
  116418. * it will be used for both width and height. If an object is passed, the screenshot size
  116419. * will be derived from the parameters. The precision property is a multiplier allowing
  116420. * rendering at a higher or lower resolution
  116421. * @param successCallback defines the callback receives a single parameter which contains the
  116422. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116423. * src parameter of an <img> to display it
  116424. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116425. * Check your browser for supported MIME types
  116426. */
  116427. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  116428. /**
  116429. * Generates an image screenshot from the specified camera.
  116430. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116431. * @param engine The engine to use for rendering
  116432. * @param camera The camera to use for rendering
  116433. * @param size This parameter can be set to a single number or to an object with the
  116434. * following (optional) properties: precision, width, height. If a single number is passed,
  116435. * it will be used for both width and height. If an object is passed, the screenshot size
  116436. * will be derived from the parameters. The precision property is a multiplier allowing
  116437. * rendering at a higher or lower resolution
  116438. * @param successCallback The callback receives a single parameter which contains the
  116439. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116440. * src parameter of an <img> to display it
  116441. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116442. * Check your browser for supported MIME types
  116443. * @param samples Texture samples (default: 1)
  116444. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116445. * @param fileName A name for for the downloaded file.
  116446. */
  116447. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  116448. }
  116449. }
  116450. declare module BABYLON {
  116451. /**
  116452. * A cursor which tracks a point on a path
  116453. */
  116454. export class PathCursor {
  116455. private path;
  116456. /**
  116457. * Stores path cursor callbacks for when an onchange event is triggered
  116458. */
  116459. private _onchange;
  116460. /**
  116461. * The value of the path cursor
  116462. */
  116463. value: number;
  116464. /**
  116465. * The animation array of the path cursor
  116466. */
  116467. animations: Animation[];
  116468. /**
  116469. * Initializes the path cursor
  116470. * @param path The path to track
  116471. */
  116472. constructor(path: Path2);
  116473. /**
  116474. * Gets the cursor point on the path
  116475. * @returns A point on the path cursor at the cursor location
  116476. */
  116477. getPoint(): Vector3;
  116478. /**
  116479. * Moves the cursor ahead by the step amount
  116480. * @param step The amount to move the cursor forward
  116481. * @returns This path cursor
  116482. */
  116483. moveAhead(step?: number): PathCursor;
  116484. /**
  116485. * Moves the cursor behind by the step amount
  116486. * @param step The amount to move the cursor back
  116487. * @returns This path cursor
  116488. */
  116489. moveBack(step?: number): PathCursor;
  116490. /**
  116491. * Moves the cursor by the step amount
  116492. * If the step amount is greater than one, an exception is thrown
  116493. * @param step The amount to move the cursor
  116494. * @returns This path cursor
  116495. */
  116496. move(step: number): PathCursor;
  116497. /**
  116498. * Ensures that the value is limited between zero and one
  116499. * @returns This path cursor
  116500. */
  116501. private ensureLimits;
  116502. /**
  116503. * Runs onchange callbacks on change (used by the animation engine)
  116504. * @returns This path cursor
  116505. */
  116506. private raiseOnChange;
  116507. /**
  116508. * Executes a function on change
  116509. * @param f A path cursor onchange callback
  116510. * @returns This path cursor
  116511. */
  116512. onchange(f: (cursor: PathCursor) => void): PathCursor;
  116513. }
  116514. }
  116515. declare module BABYLON {
  116516. /** @hidden */
  116517. export var blurPixelShader: {
  116518. name: string;
  116519. shader: string;
  116520. };
  116521. }
  116522. declare module BABYLON {
  116523. /** @hidden */
  116524. export var bones300Declaration: {
  116525. name: string;
  116526. shader: string;
  116527. };
  116528. }
  116529. declare module BABYLON {
  116530. /** @hidden */
  116531. export var instances300Declaration: {
  116532. name: string;
  116533. shader: string;
  116534. };
  116535. }
  116536. declare module BABYLON {
  116537. /** @hidden */
  116538. export var pointCloudVertexDeclaration: {
  116539. name: string;
  116540. shader: string;
  116541. };
  116542. }
  116543. // Mixins
  116544. interface Window {
  116545. mozIndexedDB: IDBFactory;
  116546. webkitIndexedDB: IDBFactory;
  116547. msIndexedDB: IDBFactory;
  116548. webkitURL: typeof URL;
  116549. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  116550. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  116551. WebGLRenderingContext: WebGLRenderingContext;
  116552. MSGesture: MSGesture;
  116553. CANNON: any;
  116554. AudioContext: AudioContext;
  116555. webkitAudioContext: AudioContext;
  116556. PointerEvent: any;
  116557. Math: Math;
  116558. Uint8Array: Uint8ArrayConstructor;
  116559. Float32Array: Float32ArrayConstructor;
  116560. mozURL: typeof URL;
  116561. msURL: typeof URL;
  116562. VRFrameData: any; // WebVR, from specs 1.1
  116563. DracoDecoderModule: any;
  116564. setImmediate(handler: (...args: any[]) => void): number;
  116565. }
  116566. interface HTMLCanvasElement {
  116567. requestPointerLock(): void;
  116568. msRequestPointerLock?(): void;
  116569. mozRequestPointerLock?(): void;
  116570. webkitRequestPointerLock?(): void;
  116571. /** Track wether a record is in progress */
  116572. isRecording: boolean;
  116573. /** Capture Stream method defined by some browsers */
  116574. captureStream(fps?: number): MediaStream;
  116575. }
  116576. interface CanvasRenderingContext2D {
  116577. msImageSmoothingEnabled: boolean;
  116578. }
  116579. interface MouseEvent {
  116580. mozMovementX: number;
  116581. mozMovementY: number;
  116582. webkitMovementX: number;
  116583. webkitMovementY: number;
  116584. msMovementX: number;
  116585. msMovementY: number;
  116586. }
  116587. interface Navigator {
  116588. mozGetVRDevices: (any: any) => any;
  116589. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116590. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116591. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116592. webkitGetGamepads(): Gamepad[];
  116593. msGetGamepads(): Gamepad[];
  116594. webkitGamepads(): Gamepad[];
  116595. }
  116596. interface HTMLVideoElement {
  116597. mozSrcObject: any;
  116598. }
  116599. interface Math {
  116600. fround(x: number): number;
  116601. imul(a: number, b: number): number;
  116602. }
  116603. interface WebGLRenderingContext {
  116604. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  116605. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  116606. vertexAttribDivisor(index: number, divisor: number): void;
  116607. createVertexArray(): any;
  116608. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  116609. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  116610. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  116611. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  116612. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  116613. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  116614. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  116615. // Queries
  116616. createQuery(): WebGLQuery;
  116617. deleteQuery(query: WebGLQuery): void;
  116618. beginQuery(target: number, query: WebGLQuery): void;
  116619. endQuery(target: number): void;
  116620. getQueryParameter(query: WebGLQuery, pname: number): any;
  116621. getQuery(target: number, pname: number): any;
  116622. MAX_SAMPLES: number;
  116623. RGBA8: number;
  116624. READ_FRAMEBUFFER: number;
  116625. DRAW_FRAMEBUFFER: number;
  116626. UNIFORM_BUFFER: number;
  116627. HALF_FLOAT_OES: number;
  116628. RGBA16F: number;
  116629. RGBA32F: number;
  116630. R32F: number;
  116631. RG32F: number;
  116632. RGB32F: number;
  116633. R16F: number;
  116634. RG16F: number;
  116635. RGB16F: number;
  116636. RED: number;
  116637. RG: number;
  116638. R8: number;
  116639. RG8: number;
  116640. UNSIGNED_INT_24_8: number;
  116641. DEPTH24_STENCIL8: number;
  116642. /* Multiple Render Targets */
  116643. drawBuffers(buffers: number[]): void;
  116644. readBuffer(src: number): void;
  116645. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  116646. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  116647. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  116648. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  116649. // Occlusion Query
  116650. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  116651. ANY_SAMPLES_PASSED: number;
  116652. QUERY_RESULT_AVAILABLE: number;
  116653. QUERY_RESULT: number;
  116654. }
  116655. interface WebGLProgram {
  116656. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  116657. }
  116658. interface EXT_disjoint_timer_query {
  116659. QUERY_COUNTER_BITS_EXT: number;
  116660. TIME_ELAPSED_EXT: number;
  116661. TIMESTAMP_EXT: number;
  116662. GPU_DISJOINT_EXT: number;
  116663. QUERY_RESULT_EXT: number;
  116664. QUERY_RESULT_AVAILABLE_EXT: number;
  116665. queryCounterEXT(query: WebGLQuery, target: number): void;
  116666. createQueryEXT(): WebGLQuery;
  116667. beginQueryEXT(target: number, query: WebGLQuery): void;
  116668. endQueryEXT(target: number): void;
  116669. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  116670. deleteQueryEXT(query: WebGLQuery): void;
  116671. }
  116672. interface WebGLUniformLocation {
  116673. _currentState: any;
  116674. }
  116675. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  116676. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  116677. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  116678. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116679. interface WebGLRenderingContext {
  116680. readonly RASTERIZER_DISCARD: number;
  116681. readonly DEPTH_COMPONENT24: number;
  116682. readonly TEXTURE_3D: number;
  116683. readonly TEXTURE_2D_ARRAY: number;
  116684. readonly TEXTURE_COMPARE_FUNC: number;
  116685. readonly TEXTURE_COMPARE_MODE: number;
  116686. readonly COMPARE_REF_TO_TEXTURE: number;
  116687. readonly TEXTURE_WRAP_R: number;
  116688. readonly HALF_FLOAT: number;
  116689. readonly RGB8: number;
  116690. readonly RED_INTEGER: number;
  116691. readonly RG_INTEGER: number;
  116692. readonly RGB_INTEGER: number;
  116693. readonly RGBA_INTEGER: number;
  116694. readonly R8_SNORM: number;
  116695. readonly RG8_SNORM: number;
  116696. readonly RGB8_SNORM: number;
  116697. readonly RGBA8_SNORM: number;
  116698. readonly R8I: number;
  116699. readonly RG8I: number;
  116700. readonly RGB8I: number;
  116701. readonly RGBA8I: number;
  116702. readonly R8UI: number;
  116703. readonly RG8UI: number;
  116704. readonly RGB8UI: number;
  116705. readonly RGBA8UI: number;
  116706. readonly R16I: number;
  116707. readonly RG16I: number;
  116708. readonly RGB16I: number;
  116709. readonly RGBA16I: number;
  116710. readonly R16UI: number;
  116711. readonly RG16UI: number;
  116712. readonly RGB16UI: number;
  116713. readonly RGBA16UI: number;
  116714. readonly R32I: number;
  116715. readonly RG32I: number;
  116716. readonly RGB32I: number;
  116717. readonly RGBA32I: number;
  116718. readonly R32UI: number;
  116719. readonly RG32UI: number;
  116720. readonly RGB32UI: number;
  116721. readonly RGBA32UI: number;
  116722. readonly RGB10_A2UI: number;
  116723. readonly R11F_G11F_B10F: number;
  116724. readonly RGB9_E5: number;
  116725. readonly RGB10_A2: number;
  116726. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  116727. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  116728. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  116729. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116730. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  116731. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  116732. 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;
  116733. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  116734. readonly TRANSFORM_FEEDBACK: number;
  116735. readonly INTERLEAVED_ATTRIBS: number;
  116736. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  116737. createTransformFeedback(): WebGLTransformFeedback;
  116738. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  116739. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  116740. beginTransformFeedback(primitiveMode: number): void;
  116741. endTransformFeedback(): void;
  116742. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  116743. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116744. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116745. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116746. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  116747. }
  116748. interface ImageBitmap {
  116749. readonly width: number;
  116750. readonly height: number;
  116751. close(): void;
  116752. }
  116753. interface WebGLQuery extends WebGLObject {
  116754. }
  116755. declare var WebGLQuery: {
  116756. prototype: WebGLQuery;
  116757. new(): WebGLQuery;
  116758. };
  116759. interface WebGLSampler extends WebGLObject {
  116760. }
  116761. declare var WebGLSampler: {
  116762. prototype: WebGLSampler;
  116763. new(): WebGLSampler;
  116764. };
  116765. interface WebGLSync extends WebGLObject {
  116766. }
  116767. declare var WebGLSync: {
  116768. prototype: WebGLSync;
  116769. new(): WebGLSync;
  116770. };
  116771. interface WebGLTransformFeedback extends WebGLObject {
  116772. }
  116773. declare var WebGLTransformFeedback: {
  116774. prototype: WebGLTransformFeedback;
  116775. new(): WebGLTransformFeedback;
  116776. };
  116777. interface WebGLVertexArrayObject extends WebGLObject {
  116778. }
  116779. declare var WebGLVertexArrayObject: {
  116780. prototype: WebGLVertexArrayObject;
  116781. new(): WebGLVertexArrayObject;
  116782. };
  116783. // Type definitions for WebVR API
  116784. // Project: https://w3c.github.io/webvr/
  116785. // Definitions by: six a <https://github.com/lostfictions>
  116786. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116787. interface VRDisplay extends EventTarget {
  116788. /**
  116789. * Dictionary of capabilities describing the VRDisplay.
  116790. */
  116791. readonly capabilities: VRDisplayCapabilities;
  116792. /**
  116793. * z-depth defining the far plane of the eye view frustum
  116794. * enables mapping of values in the render target depth
  116795. * attachment to scene coordinates. Initially set to 10000.0.
  116796. */
  116797. depthFar: number;
  116798. /**
  116799. * z-depth defining the near plane of the eye view frustum
  116800. * enables mapping of values in the render target depth
  116801. * attachment to scene coordinates. Initially set to 0.01.
  116802. */
  116803. depthNear: number;
  116804. /**
  116805. * An identifier for this distinct VRDisplay. Used as an
  116806. * association point in the Gamepad API.
  116807. */
  116808. readonly displayId: number;
  116809. /**
  116810. * A display name, a user-readable name identifying it.
  116811. */
  116812. readonly displayName: string;
  116813. readonly isConnected: boolean;
  116814. readonly isPresenting: boolean;
  116815. /**
  116816. * If this VRDisplay supports room-scale experiences, the optional
  116817. * stage attribute contains details on the room-scale parameters.
  116818. */
  116819. readonly stageParameters: VRStageParameters | null;
  116820. /**
  116821. * Passing the value returned by `requestAnimationFrame` to
  116822. * `cancelAnimationFrame` will unregister the callback.
  116823. * @param handle Define the hanle of the request to cancel
  116824. */
  116825. cancelAnimationFrame(handle: number): void;
  116826. /**
  116827. * Stops presenting to the VRDisplay.
  116828. * @returns a promise to know when it stopped
  116829. */
  116830. exitPresent(): Promise<void>;
  116831. /**
  116832. * Return the current VREyeParameters for the given eye.
  116833. * @param whichEye Define the eye we want the parameter for
  116834. * @returns the eye parameters
  116835. */
  116836. getEyeParameters(whichEye: string): VREyeParameters;
  116837. /**
  116838. * Populates the passed VRFrameData with the information required to render
  116839. * the current frame.
  116840. * @param frameData Define the data structure to populate
  116841. * @returns true if ok otherwise false
  116842. */
  116843. getFrameData(frameData: VRFrameData): boolean;
  116844. /**
  116845. * Get the layers currently being presented.
  116846. * @returns the list of VR layers
  116847. */
  116848. getLayers(): VRLayer[];
  116849. /**
  116850. * Return a VRPose containing the future predicted pose of the VRDisplay
  116851. * when the current frame will be presented. The value returned will not
  116852. * change until JavaScript has returned control to the browser.
  116853. *
  116854. * The VRPose will contain the position, orientation, velocity,
  116855. * and acceleration of each of these properties.
  116856. * @returns the pose object
  116857. */
  116858. getPose(): VRPose;
  116859. /**
  116860. * Return the current instantaneous pose of the VRDisplay, with no
  116861. * prediction applied.
  116862. * @returns the current instantaneous pose
  116863. */
  116864. getImmediatePose(): VRPose;
  116865. /**
  116866. * The callback passed to `requestAnimationFrame` will be called
  116867. * any time a new frame should be rendered. When the VRDisplay is
  116868. * presenting the callback will be called at the native refresh
  116869. * rate of the HMD. When not presenting this function acts
  116870. * identically to how window.requestAnimationFrame acts. Content should
  116871. * make no assumptions of frame rate or vsync behavior as the HMD runs
  116872. * asynchronously from other displays and at differing refresh rates.
  116873. * @param callback Define the eaction to run next frame
  116874. * @returns the request handle it
  116875. */
  116876. requestAnimationFrame(callback: FrameRequestCallback): number;
  116877. /**
  116878. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  116879. * Repeat calls while already presenting will update the VRLayers being displayed.
  116880. * @param layers Define the list of layer to present
  116881. * @returns a promise to know when the request has been fulfilled
  116882. */
  116883. requestPresent(layers: VRLayer[]): Promise<void>;
  116884. /**
  116885. * Reset the pose for this display, treating its current position and
  116886. * orientation as the "origin/zero" values. VRPose.position,
  116887. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  116888. * updated when calling resetPose(). This should be called in only
  116889. * sitting-space experiences.
  116890. */
  116891. resetPose(): void;
  116892. /**
  116893. * The VRLayer provided to the VRDisplay will be captured and presented
  116894. * in the HMD. Calling this function has the same effect on the source
  116895. * canvas as any other operation that uses its source image, and canvases
  116896. * created without preserveDrawingBuffer set to true will be cleared.
  116897. * @param pose Define the pose to submit
  116898. */
  116899. submitFrame(pose?: VRPose): void;
  116900. }
  116901. declare var VRDisplay: {
  116902. prototype: VRDisplay;
  116903. new(): VRDisplay;
  116904. };
  116905. interface VRLayer {
  116906. leftBounds?: number[] | Float32Array | null;
  116907. rightBounds?: number[] | Float32Array | null;
  116908. source?: HTMLCanvasElement | null;
  116909. }
  116910. interface VRDisplayCapabilities {
  116911. readonly canPresent: boolean;
  116912. readonly hasExternalDisplay: boolean;
  116913. readonly hasOrientation: boolean;
  116914. readonly hasPosition: boolean;
  116915. readonly maxLayers: number;
  116916. }
  116917. interface VREyeParameters {
  116918. /** @deprecated */
  116919. readonly fieldOfView: VRFieldOfView;
  116920. readonly offset: Float32Array;
  116921. readonly renderHeight: number;
  116922. readonly renderWidth: number;
  116923. }
  116924. interface VRFieldOfView {
  116925. readonly downDegrees: number;
  116926. readonly leftDegrees: number;
  116927. readonly rightDegrees: number;
  116928. readonly upDegrees: number;
  116929. }
  116930. interface VRFrameData {
  116931. readonly leftProjectionMatrix: Float32Array;
  116932. readonly leftViewMatrix: Float32Array;
  116933. readonly pose: VRPose;
  116934. readonly rightProjectionMatrix: Float32Array;
  116935. readonly rightViewMatrix: Float32Array;
  116936. readonly timestamp: number;
  116937. }
  116938. interface VRPose {
  116939. readonly angularAcceleration: Float32Array | null;
  116940. readonly angularVelocity: Float32Array | null;
  116941. readonly linearAcceleration: Float32Array | null;
  116942. readonly linearVelocity: Float32Array | null;
  116943. readonly orientation: Float32Array | null;
  116944. readonly position: Float32Array | null;
  116945. readonly timestamp: number;
  116946. }
  116947. interface VRStageParameters {
  116948. sittingToStandingTransform?: Float32Array;
  116949. sizeX?: number;
  116950. sizeY?: number;
  116951. }
  116952. interface Navigator {
  116953. getVRDisplays(): Promise<VRDisplay[]>;
  116954. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  116955. }
  116956. interface Window {
  116957. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  116958. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  116959. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  116960. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116961. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116962. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  116963. }
  116964. interface Gamepad {
  116965. readonly displayId: number;
  116966. }
  116967. interface XRDevice {
  116968. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  116969. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  116970. }
  116971. interface XRSession {
  116972. getInputSources(): Array<any>;
  116973. baseLayer: XRWebGLLayer;
  116974. requestFrameOfReference(type: string): Promise<void>;
  116975. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  116976. end(): Promise<void>;
  116977. requestAnimationFrame: Function;
  116978. addEventListener: Function;
  116979. }
  116980. interface XRSessionCreationOptions {
  116981. outputContext?: WebGLRenderingContext | null;
  116982. immersive?: boolean;
  116983. environmentIntegration?: boolean;
  116984. }
  116985. interface XRLayer {
  116986. getViewport: Function;
  116987. framebufferWidth: number;
  116988. framebufferHeight: number;
  116989. }
  116990. interface XRView {
  116991. projectionMatrix: Float32Array;
  116992. }
  116993. interface XRFrame {
  116994. getDevicePose: Function;
  116995. getInputPose: Function;
  116996. views: Array<XRView>;
  116997. baseLayer: XRLayer;
  116998. }
  116999. interface XRFrameOfReference {
  117000. }
  117001. interface XRWebGLLayer extends XRLayer {
  117002. framebuffer: WebGLFramebuffer;
  117003. }
  117004. declare var XRWebGLLayer: {
  117005. prototype: XRWebGLLayer;
  117006. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  117007. };